                       midi     (if (> f0 0.0)
                                  (Integer/parseInt (format "%.0f" (/ cents 100)))
                                  0)
-
-                      windowed (c-double block-size)
-                      spectrum (c-double block-size)
                       peaks    (c-double block-size)
 
-                      wa (c-double 1)]
-
-                  ;;(xtract/double_array_setitem wa 0 0.0)
-
-                  (xtract/xtract_windowed wav-data block-size (xtract/doublea_to_voidp full-window) windowed)
-                  (xtract/xtract_init_fft block-size xtract-spectrum)
-                  (xtract/xtract_spectrum windowed block-size (xtract-args SAMPLE_RATE_RATIO xtract-spectrum-magnitude 0.0 0.0)
-                                          spectrum)
-                  (xtract/xtract_free_fft)
+                      spectrum (extract-fft-spectrum wav-data block-size SAMPLE_RATE full-window)]
 
                   (xtract/xtract_peak_spectrum spectrum
                                                half-block-size

    file-sample-rate))

(defn extract-fundemental-frequency [wave-data block-size sample-rate]
  (let [r (double-array 1)]
    (xtract/xtract_wavelet_f0 wave-data block-size (xtract-args sample-rate) r)
    (first r)))

(defn raise-errors [result]
    (cond


                      ;;TODO: More memory, probably slower... Re-using variables faster but sad
                      (xtract/delete_double_array wav-data)
                      (xtract/delete_double_array spectrum)
                      (xtract/delete_double_array peaks)

