atsushieno / managed-midi

[Past project] Cross-platform MIDI processing library for mono and .NET (ALSA, CoreMIDI, Android, WinMM and UWP).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Midi Routing

eriveraa opened this issue · comments

Hi, I have two questions:

  1. Is there any feature in the library that allows to do midi routing (receiving from midiport and send to one/many output ports)???
  2. I went ahead and implement my own midi routing as follows:
    I have an input port with an event attached:
    private void Result_MessageReceived(object sender, MidiReceivedEventArgs e)
    {
    var inputPort = (IMidiInput)sender;
    string debugMessage = $"Input from '{inputPort.Details.Name}' / Start: {e.Start} / Length: {e.Length} / Data: {e.Data[0]} {e.Data[1]} {e.Data[2]}";
    Console.WriteLine(debugMessage);
    // Routing (Copying the midi message)
    _TestOutputPort1.Send(e.Data, e.Start, e.Length, e.Timestamp);
    }

_TestOutputPort1 is an output port already opened. So i would like to know if that´s the proper way to implement midi routing or is there any other way (and better).
Thanks for your comments!

If you opened the port which _TestOutputPort1 is trying to open somewhere else, then Windows does not allow opening one port twice - it can be only exclusively used. It does not apply to other OSes.

But if you don't open the output port anywhere else, your code above would just work. Chances are that your code is trying to open the output many times. (Check port-opening part with your debugger.)

The port-opening is already taken care. However i was really interested on answer to question 1.
Thanks.

Nothing dedicated for that, I believe it can be implement quite easily like what you wrote above.

Excelent!, Thanks.