Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE USBHostMIDI mbed
Fork of USBHostMIDI_example by
Revision 0:78ea62ee7eab, committed 2013-12-05
- Comitter:
- kshoji
- Date:
- Thu Dec 05 09:45:08 2013 +0000
- Child:
- 1:01305cc0e2a2
- Commit message:
- wrote example code.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBHostMIDI.lib Thu Dec 05 09:45:08 2013 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/kshoji/code/USBHostMIDI/#bf09452b8f26
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Dec 05 09:45:08 2013 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "USBHostMIDI.h"
+
+void noteOn(unsigned char channel, unsigned char note, unsigned char velocity) {
+ printf("note on channel: %d, note: %d, velocity: %d\r\n", channel, note, velocity);
+}
+
+void noteOff(unsigned char channel, unsigned char note, unsigned char velocity) {
+ printf("note off channel: %d, note: %d, velocity: %d\r\n", channel, note, velocity);
+}
+
+void controlChange(unsigned char channel, unsigned char key, unsigned char value) {
+ printf("control change channel: %d, key: %d, value: %d\r\n", channel, key, value);
+}
+
+void programChange(unsigned char channel, unsigned char program) {
+ printf("progaram change channel: %d, program: %d\r\n", channel, program);
+}
+
+void pitchBend(unsigned char channel, unsigned int value) {
+ printf("pitch bend channel: %d, value: %d\r\n", channel, value);
+}
+
+void midi_task(void const*) {
+ USBHostMIDI midi;
+
+ // attach midi event callbacks
+ midi.attachNoteOn(noteOn);
+ midi.attachNoteOff(noteOff);
+ midi.attachControlChange(controlChange);
+ midi.attachProgramChange(programChange);
+ midi.attachPitchBend(pitchBend);
+
+ while(1) {
+ // try to connect a midi device
+ while(!midi.connect())
+ Thread::wait(500);
+
+ // if the device is disconnected, we try to connect it again
+ while (1) {
+ // if device disconnected, try to connect it again
+ if (!midi.connected())
+ break;
+
+ Thread::wait(50);
+ }
+ }
+}
+
+int main() {
+ Thread midiTask(midi_task, NULL, osPriorityNormal, 256 * 4);
+ while(1) {
+ Thread::wait(500);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Dec 05 09:45:08 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4096f863f923 \ No newline at end of file
