                 :next         (atom nil)
                 :buffers      (aatom {})
                 :rms-buffers  (aatom {})
-                :samples-held (aatom 0)})))
+                :samples-held (aatom 0)
+                :state        (aatom :closed)})))

      (if (>= (calculate-rms this channel) threshold)
        (do
          (>> samples-held 0)
          (dequeue-from-buffer this channel))
        (if (<= (<< samples-held) hold)
          (do
            (aswap! samples-held inc)
            input-sample)
          0.0))))

  (add-to-rms [this channel sample]
    (aswap! rms-buffers update channel

  (add-to-rms [this channel sample])
  (calculate-rms [this channel])
  (queue-in-buffer [this channel sample])
  (dequeue-from-buffer [this channel])
  (maybe-toggle-gate [this state]))

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