   }
 
   int delayAnalog = analogRead(0);
-  int delayAmt = map(delayAnalog, 0,1023, 0, 50);
+  int delayAmt = map(delayAnalog, 0, 1023, 0, 50);
   if (chord != NULL) {
     for (int i = 0; i < 6; i++) {
-      strings[i] -> noteOn(tune_frequencies2_PGM[keyOffset + root + chord[i]], random(20, 40) / 100.0);
+      int note = gKeyOffset + root + chord[i];
+      if (note >= 40) {
+        strings[i] -> noteOn(tune_frequencies2_PGM[note], random(20, 40) / 100.0);
+      } else {
+        //red-flag that a note is being attempted that can't be sounded?
+      }
       delay(delayAmt);
     }
   }

#include <Wire.h>
#include <synth_simple_drum.h>

//A simple chord player for teensy + audio which allows 
// selection of the most common chords in pop 
// (e.g. I, ii, IV, V, vi) with some decorations.

// Hardware setup: 
// * 4 potentiometers A0 - A3.  A3 could be logarithmic, as it is for volume.
// * 4 buttons connecting p3-p6 to ground (configures them to use internal pullup resistors)


AudioControlSGTL5000     sgtl5000_1;     //xy=638,468
// GUItool: end automatically generated code

AudioSynthKarplusStrong *strings [] = { &string1, &string2, &string3, &string4, &string5, &string6 };

int major7[6] = {48, 59, 64, 67, 71, 76};
