Simon Ford
/
USBMIDI_DrumExample
Simple example for triggering actuators based on midi signals
Revision 0:040c2c8ca5eb, committed 2011-02-20
- Comitter:
- simon
- Date:
- Sun Feb 20 16:48:11 2011 +0000
- Commit message:
Changed in this revision
diff -r 000000000000 -r 040c2c8ca5eb USBMIDI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBMIDI.lib Sun Feb 20 16:48:11 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/USBMIDI/#10d694d6ccdc
diff -r 000000000000 -r 040c2c8ca5eb main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Feb 20 16:48:11 2011 +0000 @@ -0,0 +1,29 @@ +// Drums via MIDI! +#include "mbed.h" +#include "USBMIDI.h" + +DigitalOut drum[] = {p5, p6, p7, p8}; // the four outputs + +void drums(int id, bool on) { + if(id >= 0 && id <= 3) { + drum[id] = on; + } +} + +void do_message(MIDIMessage msg) { + switch (msg.type()) { + case MIDIMessage::NoteOnType: + drums(msg.key() - 64, msg.velocity() != 0); + break; + case MIDIMessage::NoteOffType: + drums(msg.key() - 64, 0); + break; + } +} + +USBMIDI midi; + +int main() { + midi.attach(do_message); // call back for messages received + while (1); +}
diff -r 000000000000 -r 040c2c8ca5eb mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Feb 20 16:48:11 2011 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e