Spectroscope or fft to array?

Pau Roselló's icon

Title says everything. I would like to get the spectral information as an array in order to send it out of MAX/MSP with OSC. How can I do the conversion?

Thanks.

Source Audio's icon

fft~ -> poke~ into buffer~ , peek~ to get the list out

Pau Roselló's icon

Could you share a simple example? I'm not sure about the connections

Source Audio's icon
Pau Roselló's icon

Thanks! I would not have figured it out without your help. How should I interpret the values of the fft? I see they range from -15 to 20. What does this value mean? Are these dBs?

Source Audio's icon

I'd suggest to read about that all somewhere.
for example
https://docs.cycling74.com/max8/tutorials/14_analysischapter03
www.thefouriertransform.com

etc

the example I posted only shows how to capture stream of any signal into
sized buffer, and get nonsignal float list out - conversion you asked about.
Could have been live recording into buffer, and banging that peek from time to time
to output current sampled values list.




David Meyer's icon

hey pau,

you need to convert the real/imaginary number pairs from the cartesian representation to a polar representation. this gives you the amplitude (real part) and phase (imaginary part). I'd suggest using the pfft~ object, which makes the fft stuff a lot easier.

Pau Roselló's icon

Thanks! I'm still figuring out how to make it work . Right now I have a mix of what you all said. I'm using fft->poltocar->poke but the result is not what I want. I'm probably not doing the right connections.

The image shows the visualization I'm getting:

Visualization done with Processing with the OSC data received

This is the patcher:

Max Patch
Copy patch and select New From Clipboard in Max.

Could I get some more help?

Thanks

David Meyer's icon

hey pau,

so you use the wrong conversion. you need to use cartopol instead of poltocar. fft gives you the cartesian representation, but you need the polar representation as this one gives you amplitude and phase.
check out the pasted patch, put it into a pfft~ and set the size and overlap factor of the fft. for pfft~, create a new patch, name it and save it. then create a pfft~ in your main patch and set "nameofthepatch" "fftsize" "overlap factor". pfft is the environment for spectral subpatchers.

set the size of the buffer accordingly to the size of the fft (half of the size of the fft).

Max Patch
Copy patch and select New From Clipboard in Max.

Pau Roselló's icon

Thanks, that was very useful. Now it starts looking as a spectrogram. What I don't understand is why it's (almost) symmetrical over the x axis. I would expect the lowest frequency to be in the lowest position of the array, but it's in the center, and then high frequencies are at the beginning and ending of the array. May I be doing something wrong? Should I just remove one of the halves even they're not 100% the same?

David Meyer's icon

Could you share your patch?

Pau Roselló's icon

Sure. Here it is:

Max Patch
Copy patch and select New From Clipboard in Max.

David Meyer's icon

That's because you use the full fft, but you only need the first part as the second part is the mirrored first part. I strongly advice you to use pfft~, especially if you have little understanding of FFTs. Check out the helpfile and see how to use it.