overtone

rodrigojuarez 2018-05-12T12:09:34.000060Z

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

rodrigojuarez 2018-05-12T12:09:47.000046Z

Basically after that I want to display the data with quil

2018-05-12T19:47:34.000006Z

@rodrigo.juarez.inf

(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.

2018-05-12T19:49:02.000085Z

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.

rodrigojuarez 2018-05-12T21:15:43.000041Z

@hlolli perfect, I’m also checking out this one: https://clojurefun.wordpress.com/2013/12/22/spectrograms-with-overtone/

rodrigojuarez 2018-05-12T21:16:52.000116Z

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

2018-05-12T21:20:57.000021Z

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).

2018-05-12T21:25:05.000035Z

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.