From 49fe06fc5e2b2dc4c3b7317c62097b5c09bedd57 Mon Sep 17 00:00:00 2001 From: James Kelly Date: Sat, 2 Sep 2017 20:02:33 +1000 Subject: [PATCH] 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. --- types/webmidi/index.d.ts | 2 +- types/webmidi/webmidi-tests.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/webmidi/index.d.ts b/types/webmidi/index.d.ts index b1f3cb0f61..0d64baaaa7 100644 --- a/types/webmidi/index.d.ts +++ b/types/webmidi/index.d.ts @@ -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 diff --git a/types/webmidi/webmidi-tests.ts b/types/webmidi/webmidi-tests.ts index da4dca38c2..99335204fa 100644 --- a/types/webmidi/webmidi-tests.ts +++ b/types/webmidi/webmidi-tests.ts @@ -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) {