atsushieno / managed-midi

[Past project] Cross-platform MIDI processing library for mono and .NET (ALSA, CoreMIDI, Android, WinMM and UWP).
MIT License
194 stars 26 forks source link

Midi Routing #47

Closed eriveraa closed 5 years ago

eriveraa commented 5 years ago

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!

atsushieno commented 5 years ago

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.)

eriveraa commented 5 years ago

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

atsushieno commented 5 years ago

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

eriveraa commented 5 years ago

Excelent!, Thanks.