Fork me on GitHub

Hi, I needed some help with overtone, I want to read an mp3 file and get the amplitude, but I’m a little bit lost with the library


Basically after that I want to display the data with quil



(def amp-atom (atom []))

(defn msg-handler [msg]
  (swap! amp-atom conj (nth (:args msg) 2)))

(on-event "/amp" msg-handler 1)

(demo (let [sample "/home/hlolli/samples/xx/note-060.wav"
            signal (play-buf:ar 1 (load-sample sample) :action FREE)
            peaks  (amplitude:ar signal 0 0)]
        (send-reply:ar 1 "/amp" [peaks] 1)))
Just a quick braindump, here you'll get all the amps into an atom. Don't evaluate on-event more than once or you'll get duplicates of everything.


you could also change the msg-handler to feed the data directly into quill (realtime), but the idea here is that you need send-reply to connect the two worlds of supercollider synth and overtone.


Yeah, what I want is basically the real time visualisation as you said


ah buffer-read, didn't know about that one, even easier, no need to record. But if you want realtime then I guess you need to dump the data into the update of your sketch. And send it at the fps rate, as for example 44100 Hz would mean 44040 numbers go to waste every second (on 60 fps).


so an idea would be to use (impule 60) and send that signal to the trigger parameter of send-reply, just need to choose the right signal to analyze, for amp and fft, fft is bit math, you would be sending window stored in a vector. Maybe this is no problem for you.