                       loudness              (double-array [0])
                       tonality              (double-array [0])]
 
-
-
-                  (xtract/xtract_spectral_centroid spectrum block-size (xtract-args 0.0) spectral-centroid)
-                  (xtract/xtract_irregularity_j    spectrum half-block-size nil spectral-irregularity)
+                  (raise-errors
+                   (xtract/xtract_spectral_centroid spectrum block-size (xtract-args 0.0) spectral-centroid))
+                  (raise-errors
+                   (xtract/xtract_irregularity_j    spectrum half-block-size nil spectral-irregularity))
 
                   (let [spectral-skewness      (double-array [0])
                         spectral-std-deviation (double-array [0])
                         spectral-mean          (double-array [0])
                         spectral-kurtosis      (double-array [0])]
 
-                    (xtract/xtract_spectral_mean spectrum block-size nil spectral-mean)
-                    (xtract/xtract_variance spectrum block-size (xtract-args (first spectral-mean)) spectral-variance)
-                    (xtract/xtract_spectral_standard_deviation spectrum block-size (xtract-args (first spectral-variance)) spectral-std-deviation)
+                    (raise-errors
+                     (xtract/xtract_spectral_mean spectrum block-size nil spectral-mean))
+                    (raise-errors
+                     (xtract/xtract_variance spectrum block-size (xtract-args (first spectral-mean)) spectral-variance))
+                    (raise-errors
+                     (xtract/xtract_spectral_standard_deviation spectrum block-size (xtract-args (first spectral-variance)) spectral-std-deviation))
 
                     (let [argv (xtract-args (first spectral-mean) (first spectral-std-deviation))]
-                      (xtract/xtract_spectral_skewness spectrum block-size argv spectral-skewness)
-                      (xtract/xtract_spectral_kurtosis spectrum block-size argv spectral-kurtosis))
+                      (raise-errors
+                       (xtract/xtract_spectral_skewness spectrum block-size argv spectral-skewness))
+                      (raise-errors
+                       (xtract/xtract_spectral_kurtosis spectrum block-size argv spectral-kurtosis)))
 
                     ;;(xtract/xtract_noisiness     wav-data block-size (xtract-args NUM_HARMONICS ) noiseness)
 

     (let [full-window (xtract/xtract_init_window block-size xtract-hann)
           half-window (xtract/xtract_init_window half-block-size xtract-hann)]

       (xtract/xtract_init_wavelet_f0_state)

       (let [stats
             (map-indexed
              (fn [idx v]


;;                (println v)
                (let [wav-data (clojure->c-double v)
                      f0       (extract-fundemental-frequency wav-data block-size SAMPLE_RATE)
                      cents    (frequency->cents f0)


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

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