Peak detection with an FFT

pmt's icon

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

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

Jean-Francois Charles's icon

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

TodorTodoroff's icon

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

pmt's icon

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

TodorTodoroff's icon

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

pmt's icon

I'm using Max/MSP 5 on OS 10.5 on a Powerbook (PPC). Thanks!

Peter

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

KaaKaa's icon

excuse me, where can i find iana~ for max5 (ub mac os10.5)?

Emmanuel Jourdan's icon

iana~ is part of the Ircam's forum.

KaaKaa's icon

is it right that i have to pay for downloading this library?

Emmanuel Jourdan's icon

That's the theory about it. You might also have a look to zsa.freqpeak, it doesn't use Terhard algorithm though.