my midi test

Dependencies:   USBDevice mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "USBMIDI.h"
00003 //#include <string>
00004 //#include <sstream>
00005 
00006 DigitalOut myled(LED1);
00007 USBMIDI midi;
00008 
00009 /*string str;*/
00010 bool valid = false;
00011 
00012 void mm(MIDIMessage m) {
00013     //ostringstream os;
00014     /*
00015     switch(m.type()) {
00016         case MIDIMessage::NoteOnType:
00017             os << "note on ch" << m.channel() << " key" << m.key();
00018             break;
00019         case MIDIMessage::NoteOffType:
00020             os << "note off ch" << m.channel() << " key" << m.key();
00021             break;
00022         case MIDIMessage::ControlChangeType:
00023             os << "note ctrl chg ch" << m.channel() << " key" << m.key();
00024             break;
00025         case MIDIMessage::ProgramChangeType:
00026             os << "note prog chg ch" << m.channel() << " key" << m.key();
00027             break;
00028         case MIDIMessage::AllNotesOffType:
00029             os << "all notes off";
00030             break;
00031     }*/
00032     //str="received";//os.str();
00033     val=true;
00034 }
00035 
00036 int main() {
00037     midi.attach(&mm);
00038     while(1) {
00039         if (valid) {
00040             valid=false;
00041             //printf("%s\r\n",/*str.c_str()*/);
00042         }
00043         wait_ms(1);
00044     }
00045 }