12-polyphonic "chiptune" MIDI synthesizer for LPC1768 (Standalone version)

Dependencies:   ClockControl PowerControl mbed

Revision:
5:7bc917d03bd6
Parent:
4:b2423ad4b248
--- a/events.cpp	Tue Dec 09 15:04:13 2014 +0000
+++ b/events.cpp	Tue Dec 09 16:13:06 2014 +0000
@@ -280,7 +280,30 @@
     }
 }
 
+void resetAllControllers(char messageBytes[3]) {
+    uint8_t channel = messageBytes[0] & 0x0f;
+    
+    for (uint8_t i = 0; i < 16; i++) {
+        ch.setVolume(channel, 100);
+        ch.setExpression(channel, 127);
+        ch.setPitchBend(channel, 0);
+    }
+    
+    if (dumpMode == DUMP_INST || dumpMode == DUMP_INST_DETAIL) {
+        console.printf("%-12s", "Reset all ct");
+        dumpInstrumentList();
+    }
+}
+
 void sendSystemReset() {
+    // Reset channel controller/programs
+    for (uint8_t i = 0; i < 16; i++) {
+        ch.setVolume(i, 100);
+        ch.setExpression(i, 127);
+        ch.setPitchBend(i, 0);
+        ch.setWave(i, Wavetable::waveDefList[0]);
+    }
+    // Initialize all notes
     for (uint16_t i = 0; i < NUM_INSTRUMENT; i++) {
         noteSent[i].noteOnMs = 0;
         noteSent[i].channel = 0;
@@ -292,7 +315,7 @@
         console.printf("%-12s", "System reset");
         dumpInstrumentList();
     }
-    for (uint8_t i = 0; i < NUM_INSTRUMENT; i++) {
+    for (uint16_t i = 0; i < NUM_INSTRUMENT; i++) {
         gemCore.noteOff(i);
         gemCore.volume(i, 100);
         gemCore.expression(i, 127);