getting the peak frequency from a buffer

Dec 15, 2009 at 5:30pm

getting the peak frequency from a buffer

There must be some easy way to do this that I’m overlooking: I want to scan the audio in a buffer and get the peak frequency. I know how to use myriad of spectral analysis software and the spectroscope object, but I don’t see an obvious way to display the frequency with the greatest amplitude in Max. Seems like a trivial task. I must be going about this the wrong way.

I’m an experienced Max user for several, but new to the forum, and am more familiar with the Max side than the MSP side. Any help would be greatly appreciated. I’ve been scouring through the forum for a while now.

#47218
Dec 15, 2009 at 7:12pm

couldn’t you just get it with ‘peek~’ and a ‘peak’ also? and maybe a ‘trough’ for fun. or maybe i misunderstand…

#169788
Dec 15, 2009 at 9:40pm

I believe peak~ just outputs an amplitude value. I need a frequency value with the highest amplitude.

The sonograph example patch (in fft-fun) seems like a close start, but there doesn’t seem to be an easy way to parse the data from spectroscope~ which is essentially what I want to do. I don’t need the GUI part of spectroscope, just the frequency with the highest amplitude.

Thanks.

#169789
Dec 15, 2009 at 9:52pm

have you considered doing your own fft analysis? have a loop at pfft~. you will need a way to store and order the data. I would recommend ircam’s ftm for that (coll probably won’t cut it). I would use [fmat] to store and order your amplitude and frequency data for each bin and probably a second [fmat] to keep track of the loudest frequency in each frame. this should do the trick (or at least get you started).
Come the weekend I might have time to whip together a crude example if need be…

#169790
Dec 15, 2009 at 9:58pm

Thanks MIB–that gives me a lot to think about. I tried pairing the amplitude values with frequency values that I got from analyzer~ into a coll, but I soon realized that coll was not the way to go.

An example patch would be VERY much appreciated as I have not used the IRCAM externals you mentioned.

#169791
Dec 15, 2009 at 11:41pm

You might want to check zsa.descriptors. There’s a basic peak analyzer, definitely not the best on earth, but you might get some decent results.

#169792
Dec 16, 2009 at 12:18am

thanks! I definitely will!

#169793
Dec 16, 2009 at 8:27am

I believe my patch now does what I originally wanted it to do. I don’t want to impose, but would someone mind taking a look and verifying that the data I’m getting is what I think I’m getting?

http://www.mediafire.com/?zum1awfjczw

The zip file above is contains my main patch and two files from Emmanuel Jordan’s zsa.descriptors.

To reiterate, this patch performs an FFT on incoming data and outputs the frequency of the peak amplitudes for the first four peaks of the signal.

Continued thanks to everyone!!

#169794
May 10, 2010 at 12:38pm

Hey! I want to do exactly what you did. However, your patch isn’t online anymore. Can you re-upload?

#169795

You must be logged in to reply to this topic.