 
 (def aof-subject '([:d4 2] [:a4 2] [:f4 2] [:d4 2] [:c#4 2] [:d4 1]
                    [:e4 1] [:f4 2.5] [:g4 0.5] [:f4 0.5] [:e4 0.5] [:d4 1]))
-(def major '([:c4 1] [:d4 1] [:e4 1] [:f4 1] [:g4 1] [:a4 1] [:b4 1] [:c5 1]))
-(def minor '([:c4 1] [:d4 1] [:eb4 1] [:f4 1] [:g4 1] [:ab4 1] [:bb4 1] [:c5 1]))
+(def major
+  (let [half '([:c4 1] [:d4 1] [:e4 1] [:f4 1] [:g4 1] [:a4 1] [:b4 1] [:c5 1])
+        rev (drop 1 (reverse half))]
+    (concat half rev)))
+(def minor
+  (let [half '([:c4 1] [:d4 1] [:d#4 1] [:f4 1] [:g4 1] [:a4 1] [:b4 1] [:c5 1])
+        rev (concat '([:a#4 1] [:g#4 1]) (drop 3 (reverse half)))]
+    (concat half rev)))
+
 
 (defn inst-chooser [e]
   (let [val (value (.getSource e))]
     (case val
       "Flute"  (def inst-cur flute)
+      "Piano"  (def inst-cur piano)
+      "Mooger" (def inst-cur mooger)
       "CS80"   (def inst-cur cs80)
       "SSaw"   (def inst-cur ssaw)
       "Ticker" (def inst-cur tick)

                           (label :text ""
                                  :size [100 :by 30])
                           (label "Instrument:")
                           (combobox :model ["Flute" "CS80" "SSaw" "Ticker" "Ping"]
                                     :id :instChooser
                                     :listen [:action inst-chooser])
                           (label "Tonic:")

;;(println aof-subject)

(defn play-one
  [metronome beat instrument [pitch dur] {midiq :midi}]
  (let [end (+ beat dur)]
    (if pitch
      (let [freq (if midiq
                   (midi->freq pitch)
                   pitch)
            id (o/at (metronome beat) (instrument freq))]
        (o/at (metronome end) (o/ctl id :gate 0))))
    end))

(defn play
  ([metronome inst score {midiq :midi}]
     (play metronome (metronome) inst score {:midi midiq}))
  ([metronome beat instrument score {midiq :midi}]
     (let [cur-note (first score)]
       (when cur-note
         (let [next-beat (play-one metronome beat instrument cur-note {:midi midiq})]
           (o/apply-at (metronome next-beat) play metronome next-beat instrument
             (next score) {:midi midiq} []))))))

(def a-scale ["A" "B\u266D" "B" "C" "C\u266F" "D"
              "E\u266D" "E" "F" "F\u266F" "G" "G\u266F"] )
