 (def MFCC_FREQ_BANDS    13)
 (def DEFAULT_BLOCK_SIZE 512)
 
+(defn- c-double [len]
+  (let [xtract-vs (xtract/new_double-array len)]
+    (doall
+     (map-indexed
+      (fn [idx f] (xtract/double_array_setitem xtract-vs idx (double 0.0)))
+      (range 0 len)))
+    xtract-vs))
+
+(defonce wav-buffer (c-double DEFAULT_BLOCK_SIZE))
+(defonce full-window (xtract/xtract_init_window DEFAULT_BLOCK_SIZE xtract-hann))
+(defonce spectrum-buffer (c-double DEFAULT_BLOCK_SIZE))
+(defonce peaks-buffer  (c-double DEFAULT_BLOCK_SIZE))
+(defonce arg-buffer    (c-double 5))
+(defonce windowed-buffer (c-double DEFAULT_BLOCK_SIZE))
+(defonce mel-filters (xtract/create_filterbank MFCC_FREQ_BANDS DEFAULT_BLOCK_SIZE))
 (defn raise-errors [result]
   (when result
     (cond

        (raise-errors r)
        (first cents)))))


(defn block-stats
  ([sample-path] (block-stats sample-path DEFAULT_BLOCK_SIZE))
  ([sample-path block-size]

(defn max-for [field frame-stats]
  (apply max (map (fn [f] (get (first (vals f)) field))  frame-stats)))

(defn min-for [field frame-stats]
  (let [vals (map (fn [f] (get (first (vals f)) field)) frame-stats)]
    (when (seq vals)
      (apply min vals))))

(defn global-stats [frame-stats]
  (let [n (count frame-stats)
        fields (-> frame-stats first vals first (dissoc :todo) keys)
