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.
Fork of USBMIDI by
main.cpp
- Committer:
- simon
- Date:
- 2011-02-06
- Revision:
- 0:56b095524cf2
File content as of revision 0:56b095524cf2:
#include "mbed.h"
#include "USBMIDI.h"
USBMIDI midi;
int main() {
// send some notes
for(int i=0; i<127; i++) {
midi.write(MIDIMessage::NoteOn(i));
wait(0.25);
midi.write(MIDIMessage::NoteOff(i));
wait(0.5);
}
// recieve notes
while(1) {
if(midi.readable()) {
MIDIMessage msg = midi.read();
switch(msg.type()) {
case MIDIMessage::NoteOnType:
printf("NoteOn key:%d, velocity: %d, channel: %d\n", msg.key(), msg.velocity(), msg.channel());
break;
case MIDIMessage::NoteOffType:
printf("NoteOff key:%d, velocity: %d, channel: %d\n", msg.key(), msg.velocity(), msg.channel());
break;
case MIDIMessage::ControlChangeType:
printf("ControlChange controller: %d, data: %d\n", msg.controller(), msg.value());
break;
case MIDIMessage::PitchWheelType:
printf("PitchWheel channel: %d, pitch: %d\n", msg.channel(), msg.pitch());
break;
default:
printf("Another message\n");
}
}
}
}
