Add Uint8Array to MIDIOutput send

The spec for Web MIDI API MIDIOutput.send at:
https://webaudio.github.io/web-midi-api/#dom-midioutput-send
suggests that both number[] and Uint8Array are acceptable types
for sending data on a MIDI output port.

The relevant text that allows for Uint8Array states:
"... while still enabling use of Uint8Arrays for efficiency in large ..."

An obvious use case is to forward MIDI events received on MIDIInputs as
these are already in the form of a Uint8Array types.

Tested with Chrome 60.0.3112.113 on Mac OS 10.12.6.
This commit is contained in:
James Kelly
2017-09-02 20:02:33 +10:00
parent 10f72f108f
commit 49fe06fc5e
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ declare namespace WebMidi {
* to zero (or another time in the past), the data is to be sent as soon as
* possible.
*/
send(data: number[], timestamp?: number): void;
send(data: number[] | Uint8Array, timestamp?: number): void;
/**
* Clears any pending send data that has not yet been sent from the MIDIOutput 's
+1
View File
@@ -20,6 +20,7 @@ const onFulfilled = (item: WebMidi.MIDIAccess) => {
for (const op of outputs) {
this._outputs.push(op);
op.send([ 0x90, 0x45, 0x7f ]);
op.send(new Uint8Array([ 0x90, 0x45, 0x7f ]));
}
for (const input of this._inputs) {