            :playing false
            :automaton initial-automaton
            :seed initial-seed
-           :music (->>
-                   (automate-music initial-automaton initial-seed)
-                   (tempo (bpm initial-tempo))
-                   (where :pitch initial-scale))}))
+           :music (automate-music initial-automaton initial-seed)}))
 
 (defn play-next! [notes]
-  (let [{:keys [context playing]} @app-state
-        {:keys [time duration] :as note} (first notes)
+  (let [{:keys [context playing tempo scale]} @app-state
+        {:keys [pitch duration] :as note} (first notes)
+        duration ((bpm tempo) duration)
         remainder (rest notes)
         at (synth/current-time context)
         synth-instance (-> note
-                           (update :pitch temperament/equal)
+                           (update :pitch (comp temperament/equal (get scales scale)))
                            (dissoc :time)
                            ping)
         connected-instance (synth/connect synth-instance synth/destination)]

     [:h1 "Pianola"]
     [slider :tempo tempo 20 160]
     [:p (str tempo " BPM")]
     [notation automaton]
     [notation seed]
     [playback-toggle]]))

(defn reload []
  (println "reloading")
  (r/render [app app-state]
            (.getElementById js/document "pianola")))


   (synth/percussive 0.01 0.4)
   (synth/gain 0.1)))

(def scales
  {:a-major (comp scale/A scale/major)
   :a-minor (comp scale/A scale/minor)
   :b-major (comp scale/B scale/major)
   :b-minor (comp scale/B scale/minor)
   :c-major (comp scale/C scale/major)
   :c-minor (comp scale/C scale/minor)
   :d-major (comp scale/D scale/major)
   :d-minor (comp scale/D scale/minor)
   :e-major (comp scale/E scale/major)
   :e-minor (comp scale/E scale/minor)
   :f-major (comp scale/F scale/major)
   :f-minor (comp scale/F scale/minor)
   :g-major (comp scale/G scale/major)
   :g-minor (comp scale/G scale/minor)})

(defonce initial-automaton
  [[0.25 0.125 0.5 0.25 0.125 0.5 0.5]
   [1 2 0 4 5 6 3]])
