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.
Dependencies: mbed USBDevice PinDetect
main.cpp
- Committer:
- asuszek
- Date:
- 2016-04-10
- Revision:
- 2:e21bd39bdf46
- Parent:
- 0:cad8dafb22be
- Child:
- 6:688698f814c0
File content as of revision 2:e21bd39bdf46:
/* Karplus Strong MIDI synthesizer.
*
* @author Austin Suszek
* @author Nick Delfino
*/
#include "Constants.h"
#include "mbed.h"
#include "USBMIDI.h"
Serial pc(USBTX, USBRX);
USBMIDI midi;
void midiMessageReceived(MIDIMessage message);
int main() {
// Attach the function to handle all incoming MIDI events.
midi.attach(midiMessageReceived);
while (1) {}
}
/*
* The handler for all incoming MIDI messages.
*/
void midiMessageReceived(MIDIMessage message) {
#ifdef DEBUG
printf("Message Received\r\n");
#endif
switch (message.type()) {
case MIDIMessage::NoteOnType:
#ifdef DEBUG
printf("\tType: Note On\r\n");
printf("\tNote: %d\r\n", message.key());
#endif
break;
case MIDIMessage::NoteOffType:
#ifdef DEBUG
printf("\tType: Note Off\r\n");
#endif
break;
default:
// no-op
break;
}
}
