A MIDI piano synthesizer that implements the Karplus Strong physical modeling algorithm.
Dependencies: mbed USBDevice PinDetect
Diff: main.cpp
- Revision:
- 2:e21bd39bdf46
- Parent:
- 0:cad8dafb22be
- Child:
- 6:688698f814c0
--- a/main.cpp Wed Apr 06 18:54:51 2016 +0000 +++ b/main.cpp Sun Apr 10 22:06:25 2016 +0000 @@ -1,36 +1,48 @@ -// Hello World example for the USBMIDI library +/* Karplus Strong MIDI synthesizer. + * + * @author Austin Suszek + * @author Nick Delfino + */ +#include "Constants.h" #include "mbed.h" #include "USBMIDI.h" Serial pc(USBTX, USBRX); -DigitalOut led(LED1); - 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) { - pc.printf("Message Received\r\n"); - led = !led; + #ifdef DEBUG + printf("Message Received\r\n"); + #endif switch (message.type()) { case MIDIMessage::NoteOnType: - pc.printf("\tType: Note On\r\n"); - pc.printf("\tNote: %d\r\n", message.key()); + #ifdef DEBUG + printf("\tType: Note On\r\n"); + printf("\tNote: %d\r\n", message.key()); + #endif break; case MIDIMessage::NoteOffType: - pc.printf("\tType: Note Off\r\n"); + #ifdef DEBUG + printf("\tType: Note Off\r\n"); + #endif break; default: - pc.printf("\tType: Other\r\n"); + // no-op + break; } } -int main() { - pc.printf("In Main\r\n"); - midi.attach(midiMessageReceived); - led = 1; - - while (1) { - } -} -