 ;; 0-15 channels and but 129 notes but not all play on a channel
 ;; channel 10 has lots of game like sounds 10-80
 ;; channel 12 has drum/bell stay less than 80 though
-(def max-channels 4)
-(def idx-channel-map {
-                      0 0
-                      1 10
-                      2 12
-                      3 15})
+;; (def max-channels 8)
+;; (def idx-channel-map {
+;;                       0 0
+;;                       1 10
+;;                       2 12
+;;                       3 15
+;;                       4 2
+;;                       5 14
+;;                       6 8
+;;                       7 4})
+
+(def max-channels (count instruments))
+(def idx-channel-map (fn [n] n))
+
 
 (defn default-note-fn
   [grid]

  []
  (.close ^javax.sound.midi.Synthesizer synth))

(def channels (delay (start)
                     (.getChannels ^javax.sound.midi.Synthesizer synth)))

(defn play-note
  "Play a note on channel with note and velocity"

    (map
     (fn [[a b c d :as rows] idx]
       (let [channel-number (idx-channel-map (mod idx max-channels))
             osum (int (Math/pow (apply + rows) (inc idx)))
             sum (Integer/parseInt (apply str rows) 2)
             #_( mults (map #(int (Math/pow * %2 %2)) (partition max-channels)))
             note (mod sum 129)
             velocity (min 100 (max 10 (mod sum 100)))]
