Virtual Midi Output

Hello

I’m writing a program that can send out MIDI messages to other software, like DAWs and other audio applications. What I want to do is essentially create a virtual MIDI output for my program.

I’m currently just using the Midi Through Output, that is always available on Linux - it works just fine, I just select Midi Through as my input in my DAW as well, and it just passes it through - but I noticed that whenever I run my program, a ‘Juce Midi Output’ device shows up in my Midi device list (in my DAW), and everything I send from my app over Midi Through, is also sent over Juce Midi Output. (see image)
However, this output does not show up in the MidiOutput::getDevices() list.

This seems to be the behavior of the MidiOutput::createNewDevice() function, but I don’t call it anywhere in my code. All I’m doing right now (related to Midi) is this:

MidiOutput* midithrough = MidiOutput::openDevice(0);
if(type == 0x90)
    midithrough->sendMessageNow(MidiMessage::noteOn(channel,note,(float)velocity/127));
if(type == 0x80)
    midithrough->sendMessageNow(MidiMessage::noteOff(channel,note,(float)velocity/127));

Is it possible to get rid of the Midi Through, and directly send it out from the Juce Midi Output that is created?
Will this work on all three OSs? I read that the MidiOutput::createNewDevice() function is not available on Windows, does this have anything to do with this virtual device?

Thanks in advance
Pieter

Yeah, it works on OSX and Linux, but Windows just doesn’t make it possible to create a virtual device. The only way to do it is to write an actual MIDI driver and install it.

Thanks for the reply
This doesn’t explain, however, why the same Midi message is sent twice, over two different (virtual) output devices. Why does it do that? (Well I guess it doesn’t really matter, but it just seems a bit weird to me, especially since the same message appears on Midi Through first, and then on Juce Midi Output.)