Routing Tracks Midi output to another Track

Anybody has any pointers how to “Route Midi from Track” to another Track? I only would like to get Midi events on Track 2, but keep Output device on Track 1 to play through “Default audio device”.

Just like it’s done in Waveform

Just figured it out.

    auto& midiInput = inputTrack->getMidiInputDevice();
    // Make the track's InputDeviceInstance visible to the EditPlaybackContext

    if(auto epc = edit->getCurrentPlaybackContext())
        if (auto sourceTrackInputDeviceInstance = epc->getInputFor(&midiInput)) 
            sourceTrackInputDeviceInstance->setTargetTrack(*destTrack, 0, true);