Forums > MaxMSP

getting the peak frequency from a buffer

Dec 15 2009 | 5:30 pm

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.

Dec 15 2009 | 7:12 pm

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

Dec 15 2009 | 9:40 pm

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.


Dec 15 2009 | 9:52 pm

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…

Dec 15 2009 | 9:58 pm

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.

Dec 15 2009 | 11:41 pm

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.

Dec 16 2009 | 12:18 am

thanks! I definitely will!

Dec 16 2009 | 8:27 am

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?

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!!

May 10 2010 | 12:38 pm

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

Jun 21 2015 | 9:01 pm


I am trying to do this as well, could you re-post your file or does anyone else know how to do this? I am trying to get the frequency values (numeric) for the first few peaks in the spectrogram.


Viewing 10 posts - 1 through 10 (of 10 total)

Forums > MaxMSP