my midi test

Dependencies:   USBDevice mbed

Committer:
kb10uy
Date:
Sun Dec 28 12:04:32 2014 +0000
Revision:
0:4fc8ef3908b1
Child:
1:a17d202e9a68
initial commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kb10uy 0:4fc8ef3908b1 1 #include "mbed.h"
kb10uy 0:4fc8ef3908b1 2 #include "USBMIDI.h"
kb10uy 0:4fc8ef3908b1 3
kb10uy 0:4fc8ef3908b1 4 DigitalOut myled(LED1);
kb10uy 0:4fc8ef3908b1 5 USBMIDI midi;
kb10uy 0:4fc8ef3908b1 6
kb10uy 0:4fc8ef3908b1 7 /*string str;*/
kb10uy 0:4fc8ef3908b1 8 bool val = false;
kb10uy 0:4fc8ef3908b1 9
kb10uy 0:4fc8ef3908b1 10 void mm(MIDIMessage m) {
kb10uy 0:4fc8ef3908b1 11 //ostringstream os;
kb10uy 0:4fc8ef3908b1 12 /*
kb10uy 0:4fc8ef3908b1 13 switch(m.type()) {
kb10uy 0:4fc8ef3908b1 14 case MIDIMessage::NoteOnType:
kb10uy 0:4fc8ef3908b1 15 os << "note on ch" << m.channel() << " key" << m.key();
kb10uy 0:4fc8ef3908b1 16 break;
kb10uy 0:4fc8ef3908b1 17 case MIDIMessage::NoteOffType:
kb10uy 0:4fc8ef3908b1 18 os << "note off ch" << m.channel() << " key" << m.key();
kb10uy 0:4fc8ef3908b1 19 break;
kb10uy 0:4fc8ef3908b1 20 case MIDIMessage::ControlChangeType:
kb10uy 0:4fc8ef3908b1 21 os << "note ctrl chg ch" << m.channel() << " key" << m.key();
kb10uy 0:4fc8ef3908b1 22 break;
kb10uy 0:4fc8ef3908b1 23 case MIDIMessage::ProgramChangeType:
kb10uy 0:4fc8ef3908b1 24 os << "note prog chg ch" << m.channel() << " key" << m.key();
kb10uy 0:4fc8ef3908b1 25 break;
kb10uy 0:4fc8ef3908b1 26 case MIDIMessage::AllNotesOffType:
kb10uy 0:4fc8ef3908b1 27 os << "all notes off";
kb10uy 0:4fc8ef3908b1 28 break;
kb10uy 0:4fc8ef3908b1 29 }*/
kb10uy 0:4fc8ef3908b1 30 //str="received";//os.str();
kb10uy 0:4fc8ef3908b1 31 val=true;
kb10uy 0:4fc8ef3908b1 32 }
kb10uy 0:4fc8ef3908b1 33
kb10uy 0:4fc8ef3908b1 34 int main() {
kb10uy 0:4fc8ef3908b1 35 midi.attach(&mm);
kb10uy 0:4fc8ef3908b1 36 while(1) {
kb10uy 0:4fc8ef3908b1 37 if (val) {
kb10uy 0:4fc8ef3908b1 38 val=!val;
kb10uy 0:4fc8ef3908b1 39 //printf("%s\r\n",/*str.c_str()*/);
kb10uy 0:4fc8ef3908b1 40 }
kb10uy 0:4fc8ef3908b1 41 wait_ms(1);
kb10uy 0:4fc8ef3908b1 42 }
kb10uy 0:4fc8ef3908b1 43 }