            hold        100
            rms-window  100
            trigger     default-trigger}}]
-  (let [config {:sample-rate sample-rate
-                :threshold   threshold
-                :look-ahead  look-ahead
-                :hold        hold
-                :rms-window  rms-window
-                :trigger     trigger}]
-    (map->Gate {:config      config
-                :next        (atom nil)
-                :buffers     (aatom {})
-                :rms-buffers (aatom {})})))
+  (let [config {:sample-rate  sample-rate
+                :threshold    threshold
+                :look-ahead   look-ahead
+                :hold         hold
+                :rms-window   rms-window
+                :trigger      trigger}]
+    (map->Gate {:config       config
+                :next         (atom nil)
+                :buffers      (aatom {})
+                :rms-buffers  (aatom {})
+                :samples-held (aatom 0)})))

(ns audio-utils.gate
  (:require [audio-utils.ring-buffer :as rb]
            [audio-utils.rms-buffer :as rms]
            [audio-utils.util :refer [aatom aderef areset! aswap!
                                      db->amplitude time->samples]]
            [audio-utils.worker :as w]))


  (queue-in-buffer [this channel sample])
  (dequeue-from-buffer [this channel]))

(defrecord Gate [config next buffers rms-buffers samples-held]
  w/IWorkerAudioNode
  (connect [this destination]
    (reset! next destination))
