-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Midi routing to multiple devices #26
Comments
Hi, You can just open several output devices and call var outputDevices = new[]
{
OutputDevice.GetByName("Output Device 1"),
OutputDevice.GetByName("Output Device 2"),
OutputDevice.GetByName("Output Device 3")
};
//
var inputDevice = InputDevice.GetByName("Input Device");
inputDevice.StartEventsListening();
inputDevice.EventReceived += (sender, args) =>
{
foreach (var outputDevice in outputDevices)
{
outputDevice.SendEvent(args.Event);
}
};
//
inputDevice.Dispose();
foreach (var outputDevice in outputDevices)
{
outputDevice.Dispose();
} Also there is the foreach (var outputDevice in outputDevices)
{
var deviceConnector = inputDevice.Connect(outputDevice);
} |
Hi, i will try the first aproach. |
I've created simple test which works on virtual MIDI ports: var inputDevice = InputDevice.GetByName("MIDI A");
var inputDeviceOutput = OutputDevice.GetByName("MIDI A");
var outputDevice = OutputDevice.GetByName("MIDI B");
var outputDeviceInput = InputDevice.GetByName("MIDI B");
var devicesConnector = inputDevice.Connect(outputDevice);
inputDevice.StartEventsListening();
outputDeviceInput.StartEventsListening();
outputDeviceInput.EventReceived += (sender, args) =>
{
// Program falls into this place with Note On event
};
inputDeviceOutput.SendEvent(new NoteOnEvent()); |
Hi, i am trying to understand your code, but i dont get it how to adapt this code to this scenario:
|
Hi, Please try this code: var inputDevice = InputDevice.GetByName("MIDI Controller Name");
var outputDevice1 = OutputDevice.GetByName("MIDI Out 1");
var outputDevice2 = OutputDevice.GetByName("MIDI Out 2");
var devicesConnector1 = inputDevice.Connect(outputDevice1);
var devicesConnector2 = inputDevice.Connect(outputDevice2);
inputDevice.StartEventsListening(); But I think the second |
I have tried your code, unfortunately it doesn´t work even with just one output device. I think there is something wrong in the DeviceConnector. |
It seems it's difficult to make it work as expected in real scenarios. I'll try to get rid of Thanks for reporting your use case and new ideas! |
Ok melanchall. |
Workaround is the approach I've suggested in my first comment. Of course |
I've refactored |
Hi Melanchall, what does that mean exactly? The functionality is different now? What should I expect now? |
It's just refactoring. Purpose of the |
With last change you can write: var inputDevice = InputDevice.GetByName("MIDI In");
var outputDevice1 = OutputDevice.GetByName("MIDI Out 1");
var outputDevice2 = OutputDevice.GetByName("MIDI Out 2");
var devicesConnector = inputDevice.Connect(outputDevice1, outputDevice2);
inputDevice.StartEventsListening(); After that all events from |
@eriveraa I'm closing the issue. If you have new questions regarding this issue, reopen it. |
Hi Melanchall: is it possible to send received midi events to multiple outputDevices? (Midi Routing) If so, could you provide an example or reference please?.
Thanks.
The text was updated successfully, but these errors were encountered: