Closed d-kersten closed 3 years ago
The ability to route messages has been requested quite a few times and will be integrated into v3. Meanwhile, you can do the following:
WebMidi.inputs[0].addListener("noteon", "all", function (e) {
console.log(e);
WebMidi.outputs[0].send(e.data[0], [e.data[1], e.data[2]]);
})
The first element of the e.data
array is the so-called status byte. It is followed by 0 or more data bytes. The fact that the property is called data is a bit confusing. I will try to address that in v3.
Thank you, that makes sense and will make things easier and more error proof I guess.
Hey there, thanks for making this!
I would like to implement routing capabilities and forward all messages from an input device to another output device.
What would be the easiest way to do so? I thought I could use the
midimessage
event on the input (https://webmidijs.org/docs/v2.5.3/classes/Input.html#event_midimessage) and thesend
method (https://webmidijs.org/docs/v2.5.3/classes/Output.html#method_send) on the output.But the
send
method requires astatus
parameter which is not available from themidimessage
input event.I'm currently trying to capture all possible event types individually and map them to the appropriate send methods but I face some discrepancies and fear I'll miss something – so I thought there might be an easier 'catch all' way to do it.
Thanks!