![](/media/cache/profiles/4cd5792cc3ccd04bcd11a0ed7b114410.jpg.50x50_q85.png)
my midi test
main.cpp@1:a17d202e9a68, 2014-12-28 (annotated)
- Committer:
- kb10uy
- Date:
- Sun Dec 28 12:06:50 2014 +0000
- Revision:
- 1:a17d202e9a68
- Parent:
- 0:4fc8ef3908b1
add includes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kb10uy | 0:4fc8ef3908b1 | 1 | #include "mbed.h" |
kb10uy | 0:4fc8ef3908b1 | 2 | #include "USBMIDI.h" |
kb10uy | 1:a17d202e9a68 | 3 | //#include <string> |
kb10uy | 1:a17d202e9a68 | 4 | //#include <sstream> |
kb10uy | 0:4fc8ef3908b1 | 5 | |
kb10uy | 0:4fc8ef3908b1 | 6 | DigitalOut myled(LED1); |
kb10uy | 0:4fc8ef3908b1 | 7 | USBMIDI midi; |
kb10uy | 0:4fc8ef3908b1 | 8 | |
kb10uy | 0:4fc8ef3908b1 | 9 | /*string str;*/ |
kb10uy | 1:a17d202e9a68 | 10 | bool valid = false; |
kb10uy | 0:4fc8ef3908b1 | 11 | |
kb10uy | 0:4fc8ef3908b1 | 12 | void mm(MIDIMessage m) { |
kb10uy | 0:4fc8ef3908b1 | 13 | //ostringstream os; |
kb10uy | 0:4fc8ef3908b1 | 14 | /* |
kb10uy | 0:4fc8ef3908b1 | 15 | switch(m.type()) { |
kb10uy | 0:4fc8ef3908b1 | 16 | case MIDIMessage::NoteOnType: |
kb10uy | 0:4fc8ef3908b1 | 17 | os << "note on ch" << m.channel() << " key" << m.key(); |
kb10uy | 0:4fc8ef3908b1 | 18 | break; |
kb10uy | 0:4fc8ef3908b1 | 19 | case MIDIMessage::NoteOffType: |
kb10uy | 0:4fc8ef3908b1 | 20 | os << "note off ch" << m.channel() << " key" << m.key(); |
kb10uy | 0:4fc8ef3908b1 | 21 | break; |
kb10uy | 0:4fc8ef3908b1 | 22 | case MIDIMessage::ControlChangeType: |
kb10uy | 0:4fc8ef3908b1 | 23 | os << "note ctrl chg ch" << m.channel() << " key" << m.key(); |
kb10uy | 0:4fc8ef3908b1 | 24 | break; |
kb10uy | 0:4fc8ef3908b1 | 25 | case MIDIMessage::ProgramChangeType: |
kb10uy | 0:4fc8ef3908b1 | 26 | os << "note prog chg ch" << m.channel() << " key" << m.key(); |
kb10uy | 0:4fc8ef3908b1 | 27 | break; |
kb10uy | 0:4fc8ef3908b1 | 28 | case MIDIMessage::AllNotesOffType: |
kb10uy | 0:4fc8ef3908b1 | 29 | os << "all notes off"; |
kb10uy | 0:4fc8ef3908b1 | 30 | break; |
kb10uy | 0:4fc8ef3908b1 | 31 | }*/ |
kb10uy | 0:4fc8ef3908b1 | 32 | //str="received";//os.str(); |
kb10uy | 0:4fc8ef3908b1 | 33 | val=true; |
kb10uy | 0:4fc8ef3908b1 | 34 | } |
kb10uy | 0:4fc8ef3908b1 | 35 | |
kb10uy | 0:4fc8ef3908b1 | 36 | int main() { |
kb10uy | 0:4fc8ef3908b1 | 37 | midi.attach(&mm); |
kb10uy | 0:4fc8ef3908b1 | 38 | while(1) { |
kb10uy | 1:a17d202e9a68 | 39 | if (valid) { |
kb10uy | 1:a17d202e9a68 | 40 | valid=false; |
kb10uy | 0:4fc8ef3908b1 | 41 | //printf("%s\r\n",/*str.c_str()*/); |
kb10uy | 0:4fc8ef3908b1 | 42 | } |
kb10uy | 0:4fc8ef3908b1 | 43 | wait_ms(1); |
kb10uy | 0:4fc8ef3908b1 | 44 | } |
kb10uy | 0:4fc8ef3908b1 | 45 | } |