 (ns the-nature-of-sound.core
   (:require [clojure.java.io :as io]
-            [dynne.sampled-sound :as sample])
+            [dynne.sampled-sound :as ssample])
   (:import [xtract]
            [xtractJNI]
            [xtract_mel_filter]

         half-block-size (/ block-size 2)
         SAMPLE_RATE_RATIO (/ SAMPLE_RATE block-size)

         s           (ssample/read-sound sample-path block-size)
         data-chunks (ssample/chunks s SAMPLE_RATE)
         ;;TODO: Merging channels?
         ;;with sliding window, overlap
         data (partition block-size half-block-size (mapcat (fn [bit] bit) (flatten (flatten ch))))         ;;seperate
         ;;data (partition block-size (mapcat (fn [bit] bit) (flatten (flatten ch))))

         mel-filters  (xtract/create_filterbank  MFCC_FREQ_BANDS block-size)

         ;;bark-band-limits (xtract/new_int_array 0)

        file-sample-rate     (.getSampleRate base-file-format)]
    file-sample-rate))

(defn extract-spectral-inharmonicity
  [peaks-data block-size f0]
  (if (> f0 0.0)
    (with-result
      (fn [r] (xtract/xtract_spectral_inharmonicity peaks-data block-size (xtract-args f0) r)))
    0.0))

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

;;    (when (> (first r) 0.0) (println :---------------------> (first r)))
    (first r)
    )
)

(defn extract-spectrum
  "Extract frequency domain spectrum from time domain signal"
