MIDI support in simulator (#1332)

* gluing to support MIDI devices in the simulator

* sim support for midi

* simplify interface

* ensure helper function does not show up in TS

* bump pxt
This commit is contained in:
Peli de Halleux 2018-10-03 11:32:29 -07:00 committed by GitHub
parent 710abd50cb
commit 1a9235e333
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 1 deletions

View File

@ -302,4 +302,13 @@ namespace control {
int deviceSerialNumber() {
return microbit_serial_number();
}
/**
* Informs simulator/runtime of a MIDI message
* Internal function to support the simulator.
*/
//% part=midioutput block
void __midiSend(Buffer buffer) {
// this is a stub to support the simulator
}
}

View File

@ -431,6 +431,13 @@ declare namespace control {
//% blockId="control_device_serial_number" block="device serial number" weight=9
//% advanced=true shim=control::deviceSerialNumber
function deviceSerialNumber(): int32;
/**
* Informs simulator/runtime of a MIDI message
* Internal function to support the simulator.
*/
//% part=midioutput block shim=control::__midiSend
function __midiSend(buffer: Buffer): void;
}

View File

@ -42,6 +42,6 @@
},
"dependencies": {
"pxt-common-packages": "0.23.57",
"pxt-core": "4.1.12"
"pxt-core": "4.1.13"
}
}

7
sim/state/midi.ts Normal file
View File

@ -0,0 +1,7 @@
namespace pxsim.control {
export function __midiSend(data: RefBuffer) {
const b = board();
pxsim.AudioContextManager.sendMidiMessageAsync(data)
.done();
}
}