A synthesizer that is controlled by a USB MIDI Keyboard. Also displays corresponding frequencies via a simple spectrum analyzer on a LCD. Uses a watchdog timer to reset Mbed in case it freezes.
Dependencies: 4DGL-uLCD-SE USBHostMIDI mbed
Fork of USBHostMIDI_example by
Diff: main.cpp
- Revision:
- 3:d48372c1347e
- Parent:
- 2:5366ce17fe55
--- a/main.cpp Wed Dec 13 03:31:09 2017 +0000 +++ b/main.cpp Wed Dec 13 17:17:07 2017 +0000 @@ -11,14 +11,8 @@ - -//void notesound_t(unsigned char note, unsigned char velocity, volatile int time_us) { -// myspeaker.PlayNote(note, velocity, time_us); -//} - - void noteOn(unsigned char channel, unsigned char note, unsigned char velocity) { - wdt.kick(3.0); + wdt.kick(3.0); //start watchdog timer myled = 1.0; //turn on LED1 on note press myspeaker.PlayNote(note, velocity); //uLCD.printf("\nkey: %d, velocity: %d\r\n", note, velocity); @@ -60,24 +54,18 @@ } int main() { - if ((LPC_WDT->WDMOD >> 2) & 1) + if ((LPC_WDT->WDMOD >> 2) & 1) //indicate if watchdog timer has not been kicked, and resets mbed myled4 = 1; else myled3 = 1; - //wdt.kick(3.0); //use watchdog timer to reset mbed after 2 seconds without kick uLCD.background_color(BLUE); //set background for spectrum analyzer uLCD.cls(); uLCD.line(5,110,120,110,WHITE); // x-axis uLCD.line(5,5,5,110, WHITE); //y-axis - //uLCD.fill(65,35,55,1,graphAxesColor); - //uLCD.fill(65,35,1,85,graphAxesColor); Thread midiTask(midi_task, NULL, osPriorityNormal, 256 * 4); while(1) { Thread::wait(50); //wdt.kick(); - myled4=!myled4; - //uLCD.printf("This is a test\n"); - //myspeaker.PlayNote(60, 127, 1.0); - + myled4=!myled4; //blink LED4 to indicate that mbed is ready to receive input from keyboard } } \ No newline at end of file