     ;(.connect source (.-destination context))
     ))
 
-(defn save-recording! [app-state audio-recorder audio-context]
-  (.stop audio-recorder)
-  (.getBuffers audio-recorder
-               (fn [buffers]
-                 (om/transact! app-state :recorded-buffers #(conj % (aget buffers 0)))
-                 (.clear audio-recorder))))
+(defn save-recording! [app-state audio-recorder audio-context analyser-node]
+  (let [buffer-length (.-frequencyBinCount analyser-node)
+        data-array (js/window.Uint8Array. buffer-length)]
+    (.getByteTimeDomainData analyser-node data-array)
+    (.stop audio-recorder)
+    (.getBuffers audio-recorder
+                 (fn [buffers]
+                   (om/transact! app-state :recorded-buffers #(conj % (aget buffers 0)))
+                   (.clear audio-recorder)))))
 
-(defn recorder-view [{:keys [audio-recorder is-recording audio-context] :as data} owner]
+(defn recorder-view [{:keys [audio-recorder is-recording audio-context analyser-node] :as data} owner]
   (reify
     om/IDisplayName (display-name [_] "recorder-view")
     om/IRender

                                :onClick (fn [e]
                                           (if is-recording
                                             (do
                                               (save-recording! data audio-recorder audio-context)
                                               (om/transact! data :is-recording not))
                                             (do
                                               (.record audio-recorder)
                                               (om/transact! data :is-recording not))))}
                           (if is-recording "Stop" "Record"))))))

(defn buffer-view [recorded-buffer owner]
  (reify
    om/IDisplayName (display-name [_] "buffer-view")


(ns ^:figwheel-always web-audio-cljs.core
  (:require [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [web-audio-cljs.audio :as audio]
            [web-audio-cljs.utils :refer [l]]
            [cljs.core.async :refer [put! chan timeout <! >!] :as async])
  (:require-macros [cljs.core.async.macros :refer [go go-loop alt!]]))

(enable-console-print!)

