HostedMidiInputDeviceInstance Object that sends Midi Notes to Audio Track

How could i got about using HostedMidiInputDeviceInstance to build a fake midi device?
I cant quite grasp the way in which it is used.

I would like to have 1 fake device per track and have 8 tracks. Each device would be able to pass midi notes and/or midi messages to an Track

I think you’d just call DeviceManager::createVirtualMidiDevice with some dummy names and then assign them to each of your tracks. Does that work?

Yes that works, and then im guessing i used it in a manner im not suppose too. Is there a better way of passing midiNotes to the VirtualMidiDevice ?
Using midi recording demo

           //in constructtor
          if (engine.getDeviceManager().getDefaultMidiInDevice() == nullptr)
           engine.getDeviceManager().createVirtualMidiDevice("Virtual");

          //in create tracks
           int trackNum = 0;
           for (auto instance : edit->getAllInputDevices())
           {
               if (instance->getInputDevice().getDeviceType() == te::InputDevice::physicalMidiDevice || instance->getInputDevice().getDeviceType() == te::InputDevice::virtualMidiDevice)
               {
                   if (auto t = EngineHelpers::getOrInsertAudioTrackAt(*edit, trackNum))
                   {
                       instance->setTargetTrack(*t, 0, true);
                       instance->setRecordingEnabled(*t, true);

                       trackNum++;
                   }
               }
           }


        //just on click button for now
        tracktion_engine::MidiInputDevice* dev = engine.getDeviceManager().getDefaultMidiInDevice();

        if (on)
            dev->keyboardState.noteOn(1, 77, 1.0);
        else
            dev->keyboardState.noteOff(1, 77, 1.0);

            on = !on;

I think handleIncommingMidiMessage is probably the best method to use?

Hmm handleIncommingMidiMessage didnt seem to work am i missing something. This is the part i changed.

        tracktion_engine::MidiInputDevice* dev = engine.getDeviceManager().getDefaultMidiInDevice();
        MidiMessage mm;
        if (on)
            mm.noteOn(1, 77, (float) 1.0);
        else
            mm.noteOff(1, 77);

        dev->handleIncomingMidiMessage(mm);
        on = !on;

Are you sure that doesn’t work? Can you trace through the call to handleIncomingMidiMessage and see where the message ends up? It should get passed to the audio playback graph and then on to the plugin nodes.