ChordJoy is a keyboard application that accepts chordal input from a set of digital ports, outputting letters and the chords that correspond to the piano keyboard keys the user has pressed.

Dependencies:   PinDetect_KL25Z mbed-rtos mbed

Fork of ChordJoy by Interactive Device Design

Revision:
4:400a042e762a
Parent:
3:ed89297af2ce
Child:
5:1186eb1f3c2b
--- a/main.cpp	Mon Sep 22 02:12:29 2014 +0000
+++ b/main.cpp	Mon Sep 22 02:15:15 2014 +0000
@@ -75,21 +75,18 @@
     {1, 3, 6}
 };
 
-void playAllChords(void) {
-    for (int i = 0; i < LETTERS; i++) {
-        int *chord = chords[i];
-        for (int j = 0; j < BUZZERS; j++) {
-            int noteIndex = chord[j];
-            if (noteIndex == 7) {
-                buzzers[j] = 0;
-            }
-            else {
-                buzzers[j] = .5f;
-                int period = notePeriods[noteIndex];
-                buzzers[j].period_us(period);
-            }
+void playChord(int chordIndex) {
+    int *chord = chords[chordIndex];
+    for (int i = 0; i < BUZZERS; i++) {
+        int noteIndex = chord[i];
+        if (noteIndex == 7) {
+            buzzers[i] = 0;
         }
-        wait_ms(10000);
+        else {
+            buzzers[i] = .5f;
+            int period = notePeriods[noteIndex];
+            buzzers[i].period_us(period);
+        }
     }
 }
 
@@ -151,6 +148,9 @@
             collectionTimer.stop();
             collectionTimer.reset();
             int chordIndex = readChord();
+            if (chordIndex != -1) {
+                playChord(chordIndex);   
+            }
         }
         wait_ms(10);
     }