![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Framed Laser Harp Implementation with MBed, that allows interface with MIDI synthesizers software.
Fork of LaserHarpProj by
main.cpp@0:4b55d56b6b61, 2011-02-20 (annotated)
- Committer:
- simon
- Date:
- Sun Feb 20 13:15:46 2011 +0000
- Revision:
- 0:4b55d56b6b61
- Child:
- 1:2b551cb862fe
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:4b55d56b6b61 | 1 | // Hello World example for the USBMIDI library |
simon | 0:4b55d56b6b61 | 2 | |
simon | 0:4b55d56b6b61 | 3 | #include "mbed.h" |
simon | 0:4b55d56b6b61 | 4 | #include "USBMIDI.h" |
simon | 0:4b55d56b6b61 | 5 | |
simon | 0:4b55d56b6b61 | 6 | void show_message(MIDIMessage msg) { |
simon | 0:4b55d56b6b61 | 7 | switch (msg.type()) { |
simon | 0:4b55d56b6b61 | 8 | case MIDIMessage::NoteOnType: |
simon | 0:4b55d56b6b61 | 9 | printf("NoteOn key:%d, velocity: %d, channel: %d\n", msg.key(), msg.velocity(), msg.channel()); |
simon | 0:4b55d56b6b61 | 10 | break; |
simon | 0:4b55d56b6b61 | 11 | case MIDIMessage::NoteOffType: |
simon | 0:4b55d56b6b61 | 12 | printf("NoteOff key:%d, velocity: %d, channel: %d\n", msg.key(), msg.velocity(), msg.channel()); |
simon | 0:4b55d56b6b61 | 13 | break; |
simon | 0:4b55d56b6b61 | 14 | case MIDIMessage::ControlChangeType: |
simon | 0:4b55d56b6b61 | 15 | printf("ControlChange controller: %d, data: %d\n", msg.controller(), msg.value()); |
simon | 0:4b55d56b6b61 | 16 | break; |
simon | 0:4b55d56b6b61 | 17 | case MIDIMessage::PitchWheelType: |
simon | 0:4b55d56b6b61 | 18 | printf("PitchWheel channel: %d, pitch: %d\n", msg.channel(), msg.pitch()); |
simon | 0:4b55d56b6b61 | 19 | break; |
simon | 0:4b55d56b6b61 | 20 | default: |
simon | 0:4b55d56b6b61 | 21 | printf("Another message\n"); |
simon | 0:4b55d56b6b61 | 22 | } |
simon | 0:4b55d56b6b61 | 23 | } |
simon | 0:4b55d56b6b61 | 24 | |
simon | 0:4b55d56b6b61 | 25 | USBMIDI midi; |
simon | 0:4b55d56b6b61 | 26 | |
simon | 0:4b55d56b6b61 | 27 | int main() { |
simon | 0:4b55d56b6b61 | 28 | midi.attach(show_message); // call back for messages received |
simon | 0:4b55d56b6b61 | 29 | while (1) { |
simon | 0:4b55d56b6b61 | 30 | for(int i=48; i<83; i++) { // send some messages! |
simon | 0:4b55d56b6b61 | 31 | midi.write(MIDIMessage::NoteOn(i)); |
simon | 0:4b55d56b6b61 | 32 | wait(0.25); |
simon | 0:4b55d56b6b61 | 33 | midi.write(MIDIMessage::NoteOff(i)); |
simon | 0:4b55d56b6b61 | 34 | wait(0.5); |
simon | 0:4b55d56b6b61 | 35 | } |
simon | 0:4b55d56b6b61 | 36 | } |
simon | 0:4b55d56b6b61 | 37 | } |