Peak detection with an FFT

I’m trying to work inside a pfft~ subpatch to detect amplitude peaks and
their associated frequencies from a recorded sine sweep [this is a test
patch for a larger project in which i am attempting to detect room modes
by analyzing recordings of sine sweeps through a room and looking for
amplitude spikes]. However, I can’t seem to be able to simply read
through the buffer~ of fft output and pick out the loudest X bins and
their associated amplitudes. This seems like it should be a fairly
simple task (and with a language such as Perl, Javascript, etc. it would
be), but using MSP objects to do this seems quite tricky. For one thing,
everything is forced to work at signal rate, even though the analysis
would ideally be at CPU rate, and using scheduler-rate objects seems to
be a dead end due to the synchronization issues they run into. I’ve
attached two patches below (please let me know if there is a better way
to attach these). The first is the parent patch where you trigger the
sweep. the second is the pfft~ subpatch where the magic should happen.
If you read the comments inside of it, you’ll see where the problem is
and get an idea as to how I’m approaching it. Many thanks in advance for
any and all assistance!

Best,

Peter Traub

— Pasted Max Patch, click to expand. —

Copy all of the following text. Then, in Max, select New From Clipboard.

You can analyze a buffer~ in Java. See [mxj buf.Op] (help file is called
buf.Op.help )
Another option is to record your spectral data into Jitter matrices instead
of buffers. Then, you may find data easier to manipulate and visualize.
Jean-Francois.

> Hi All,
>
> I’m trying to work inside a pfft~ subpatch to detect amplitude peaks and
> their associated frequencies from a recorded sine sweep [this is a test
> patch for a larger project in which i am attempting to detect room modes
> by analyzing recordings of sine sweeps through a room and looking for
> amplitude spikes]. However, I can’t seem to be able to simply read
> through the buffer~ of fft output and pick out the loudest X bins and
> their associated amplitudes. This seems like it should be a fairly
> simple task (and with a language such as Perl, Javascript, etc. it would
> be), but using MSP objects to do this seems quite tricky. For one thing,
> everything is forced to work at signal rate, even though the analysis
> would ideally be at CPU rate, and using scheduler-rate objects seems to
> be a dead end due to the synchronization issues they run into. I’ve
> attached two patches below (please let me know if there is a better way
> to attach these). The first is the parent patch where you trigger the
> sweep. the second is the pfft~ subpatch where the magic should happen.
> If you read the comments inside of it, you’ll see where the problem is
> and get an idea as to how I’m approaching it. Many thanks in advance for
> any and all assistance!
>
> Best,
>
> Peter Traub

If you are looking for peaks extraction, you could also use iana~.
It extracts peaks with various parameters (width, level difference between
centre bin and adjacent ones, keep or not peaks below threshold of hearing)
and allows you to order them by frequency, sound pressure level, or
psychoacoustically perceived level or contribution to pitch perception.

Best,
Todor

> You can analyze a buffer~ in Java. See [mxj buf.Op] (help file is called
> buf.Op.help )
> Another option is to record your spectral data into Jitter matrices instead
> of buffers. Then, you may find data easier to manipulate and visualize.
> Jean-Francois.
>
>
>> Hi All,
>>
>> I’m trying to work inside a pfft~ subpatch to detect amplitude peaks and
>> their associated frequencies from a recorded sine sweep [this is a test
>> patch for a larger project in which i am attempting to detect room modes
>> by analyzing recordings of sine sweeps through a room and looking for
>> amplitude spikes]. However, I can’t seem to be able to simply read
>> through the buffer~ of fft output and pick out the loudest X bins and
>> their associated amplitudes. This seems like it should be a fairly
>> simple task (and with a language such as Perl, Javascript, etc. it would
>> be), but using MSP objects to do this seems quite tricky. For one thing,
>> everything is forced to work at signal rate, even though the analysis
>> would ideally be at CPU rate, and using scheduler-rate objects seems to
>> be a dead end due to the synchronization issues they run into. I’ve
>> attached two patches below (please let me know if there is a better way
>> to attach these). The first is the parent patch where you trigger the
>> sweep. the second is the pfft~ subpatch where the magic should happen.
>> If you read the comments inside of it, you’ll see where the problem is
>> and get an idea as to how I’m approaching it. Many thanks in advance for
>> any and all assistance!
>>
>> Best,
>>
>> Peter Traub
>
>

Thanks! I’ll certainly check this one out as it may solve most of my
problems. I’ve actually had a bit of success since emailing the list by
adding a function to the java buf.Op library. I’m not a java writer at
all, but have done plenty of Perl, so I was able to hack my way to a
function that returned the three highest peaks. Of course, they’re all
right next to each other, so I need something that looks at surrounding
bins and essentially does a lot more sophisticated analysis. That said,
does anyone have a link to the iana~ library? I’m having a very hard
time finding it via Google, and as I don’t speak French, I’m not getting
too far on the Ircam site. Thanks again!

Best,

Peter

Todor Todoroff wrote:
> If you are looking for peaks extraction, you could also use iana~.
> It extracts peaks with various parameters (width, level difference between
> centre bin and adjacent ones, keep or not peaks below threshold of hearing)
> and allows you to order them by frequency, sound pressure level, or
> psychoacoustically perceived level or contribution to pitch perception.
>
> Best,
> Todor
>
>
>> You can analyze a buffer~ in Java. See [mxj buf.Op] (help file is called
>> buf.Op.help )
>> Another option is to record your spectral data into Jitter matrices instead
>> of buffers. Then, you may find data easier to manipulate and visualize.
>> Jean-Francois.
>>
>>
>>
>>> Hi All,
>>>
>>> I’m trying to work inside a pfft~ subpatch to detect amplitude peaks and
>>> their associated frequencies from a recorded sine sweep [this is a test
>>> patch for a larger project in which i am attempting to detect room modes
>>> by analyzing recordings of sine sweeps through a room and looking for
>>> amplitude spikes]. However, I can’t seem to be able to simply read
>>> through the buffer~ of fft output and pick out the loudest X bins and
>>> their associated amplitudes. This seems like it should be a fairly
>>> simple task (and with a language such as Perl, Javascript, etc. it would
>>> be), but using MSP objects to do this seems quite tricky. For one thing,
>>> everything is forced to work at signal rate, even though the analysis
>>> would ideally be at CPU rate, and using scheduler-rate objects seems to
>>> be a dead end due to the synchronization issues they run into. I’ve
>>> attached two patches below (please let me know if there is a better way
>>> to attach these). The first is the parent patch where you trigger the
>>> sweep. the second is the pfft~ subpatch where the magic should happen.
>>> If you read the comments inside of it, you’ll see where the problem is
>>> and get an idea as to how I’m approaching it. Many thanks in advance for
>>> any and all assistance!
>>>
>>> Best,
>>>
>>> Peter Traub
>>>
>>
>
>
>

I could send it to you. On what system are you?
Best,
Todor
> Thanks! I’ll certainly check this one out as it may solve most of my
> problems. I’ve actually had a bit of success since emailing the list by
> adding a function to the java buf.Op library. I’m not a java writer at
> all, but have done plenty of Perl, so I was able to hack my way to a
> function that returned the three highest peaks. Of course, they’re all
> right next to each other, so I need something that looks at surrounding
> bins and essentially does a lot more sophisticated analysis. That said,
> does anyone have a link to the iana~ library? I’m having a very hard
> time finding it via Google, and as I don’t speak French, I’m not getting
> too far on the Ircam site. Thanks again!
>
> Best,
>
> Peter
>
> Todor Todoroff wrote:
>> If you are looking for peaks extraction, you could also use iana~.
>> It extracts peaks with various parameters (width, level difference between
>> centre bin and adjacent ones, keep or not peaks below threshold of hearing)
>> and allows you to order them by frequency, sound pressure level, or
>> psychoacoustically perceived level or contribution to pitch perception.
>>
>> Best,
>> Todor
>>
>>
>>> You can analyze a buffer~ in Java. See [mxj buf.Op] (help file is called
>>> buf.Op.help )
>>> Another option is to record your spectral data into Jitter matrices instead
>>> of buffers. Then, you may find data easier to manipulate and visualize.
>>> Jean-Francois.
>>>
>>>
>>>
>>>> Hi All,
>>>>
>>>> I’m trying to work inside a pfft~ subpatch to detect amplitude peaks and
>>>> their associated frequencies from a recorded sine sweep [this is a test
>>>> patch for a larger project in which i am attempting to detect room modes
>>>> by analyzing recordings of sine sweeps through a room and looking for
>>>> amplitude spikes]. However, I can’t seem to be able to simply read
>>>> through the buffer~ of fft output and pick out the loudest X bins and
>>>> their associated amplitudes. This seems like it should be a fairly
>>>> simple task (and with a language such as Perl, Javascript, etc. it would
>>>> be), but using MSP objects to do this seems quite tricky. For one thing,
>>>> everything is forced to work at signal rate, even though the analysis
>>>> would ideally be at CPU rate, and using scheduler-rate objects seems to
>>>> be a dead end due to the synchronization issues they run into. I’ve
>>>> attached two patches below (please let me know if there is a better way
>>>> to attach these). The first is the parent patch where you trigger the
>>>> sweep. the second is the pfft~ subpatch where the magic should happen.
>>>> If you read the comments inside of it, you’ll see where the problem is
>>>> and get an idea as to how I’m approaching it. Many thanks in advance for
>>>> any and all assistance!
>>>>
>>>> Best,
>>>>
>>>> Peter Traub
>>>>
>>>
>>
>>
>>
>

Todor Todoroff wrote:
> I could send it to you. On what system are you?
> Best,
> Todor
>
>> Thanks! I’ll certainly check this one out as it may solve most of my
>> problems. I’ve actually had a bit of success since emailing the list by
>> adding a function to the java buf.Op library. I’m not a java writer at
>> all, but have done plenty of Perl, so I was able to hack my way to a
>> function that returned the three highest peaks. Of course, they’re all
>> right next to each other, so I need something that looks at surrounding
>> bins and essentially does a lot more sophisticated analysis. That said,
>> does anyone have a link to the iana~ library? I’m having a very hard
>> time finding it via Google, and as I don’t speak French, I’m not getting
>> too far on the Ircam site. Thanks again!
>>
>> Best,
>>
>> Peter
>>
>> Todor Todoroff wrote:
>>
>>> If you are looking for peaks extraction, you could also use iana~.
>>> It extracts peaks with various parameters (width, level difference between
>>> centre bin and adjacent ones, keep or not peaks below threshold of hearing)
>>> and allows you to order them by frequency, sound pressure level, or
>>> psychoacoustically perceived level or contribution to pitch perception.
>>>
>>> Best,
>>> Todor
>>>
>>>
>>>
>>>> You can analyze a buffer~ in Java. See [mxj buf.Op] (help file is called
>>>> buf.Op.help )
>>>> Another option is to record your spectral data into Jitter matrices instead
>>>> of buffers. Then, you may find data easier to manipulate and visualize.
>>>> Jean-Francois.
>>>>
>>>>
>>>>
>>>>
>>>>> Hi All,
>>>>>
>>>>> I’m trying to work inside a pfft~ subpatch to detect amplitude peaks and
>>>>> their associated frequencies from a recorded sine sweep [this is a test
>>>>> patch for a larger project in which i am attempting to detect room modes
>>>>> by analyzing recordings of sine sweeps through a room and looking for
>>>>> amplitude spikes]. However, I can’t seem to be able to simply read
>>>>> through the buffer~ of fft output and pick out the loudest X bins and
>>>>> their associated amplitudes. This seems like it should be a fairly
>>>>> simple task (and with a language such as Perl, Javascript, etc. it would
>>>>> be), but using MSP objects to do this seems quite tricky. For one thing,
>>>>> everything is forced to work at signal rate, even though the analysis
>>>>> would ideally be at CPU rate, and using scheduler-rate objects seems to
>>>>> be a dead end due to the synchronization issues they run into. I’ve
>>>>> attached two patches below (please let me know if there is a better way
>>>>> to attach these). The first is the parent patch where you trigger the
>>>>> sweep. the second is the pfft~ subpatch where the magic should happen.
>>>>> If you read the comments inside of it, you’ll see where the problem is
>>>>> and get an idea as to how I’m approaching it. Many thanks in advance for
>>>>> any and all assistance!
>>>>>
>>>>> Best,
>>>>>
>>>>> Peter Traub
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>
>
>