 (defn init-line []
   "Initializes Minim and an InputLine"
   (let [frame-size 1024
+        sample-rate 44100
         minim (Minim. MinimDummyInput)
-        input (.getLineIn minim Minim/MONO, frame-size)]
-    {:frame-size frame-size
+        input (.getLineIn minim Minim/MONO frame-size sample-rate)]
+    {:sample-rate sample-rate
+     :frame-size frame-size
      :minim minim
      :input input}))
 


;;; waveform

(defn draw-waveform [a]
  (q/background 1.0)
  (defn scale [y] (-> y (* 200) (+ 200)))
  (defn get-y [i] (-> (:input a) .-mix (.get i)))
  (doseq [i (-> (:frame-size a) dec range)]
    (q/line i (scale (get-y i))
            (inc i) (scale (get-y (inc i))))))


(defn plot-waveform [a]
  (q/sketch
   :size [1024 400]
   :setup quil-setup
   :update identity
   :draw (fn [_] (draw-waveform a))



(defn update-state [state args]
  (let [fft (FFT. (:frame-size args) (:sample-rate args))]
    (.logAverages fft 45 15)
    (a/go (while (not (:stop @state))
            (.forward fft (.-mix (:input args)))
