(help) Find the max amplitude in an fftin~ analysis

alyver00's icon

Hi to all, i spend a lot of time try to find how to extract the frequency with the maximum amplitude from a fft~ analysis.
I try with comparator like >~, snapshot~ change~ and edge~ but nothing want work. I just want to make an pfft~ (inside a poly~ for have a good downsample of the patch) and inside the pfft~ i need to extract the frequency values (better if in float format) with an amplitude threshold that i want.

Maybe i don't understand want came out of the fftin~ object: maybe for this work i can make a mxj java object that take a pair of (fftin~ real, fftin~ sync) signals, read the values and save and output the values if they are over a threshold.
Please can some one also tellme what exactly came out of the fftin~ object? it can be interpretated as a normal signal, of a block of values.

Thanks for all your helps

Emmanuel Jourdan's icon

On 4 janv. 08, at 12:20, Marco wrote:

> Maybe i don't understand want came out of the fftin~ object: maybe
> for this work i can make a mxj java object that take a pair of
> (fftin~ real, fftin~ sync) signals, read the values and save and
> output the values if they are over a threshold.
> Please can some one also tellme what exactly came out of the fftin~
> object? it can be interpretated as a normal signal, of a block of
> values.

Sounds like you can achieve that with minmax~ object that you can
reset each time the index bin is 0.

HTH,
ej

jvkr's icon

You migth give ftm from ircam a try. Lists of data (non-signal) arriving from an fft can relatively easy be modified or sorted.

_
johan

alyver00's icon

Quote: Emmanuel Jourdan wrote on Fri, 04 January 2008 04:56
----------------------------------------------------
> On 4 janv. 08, at 12:20, Marco wrote:
>
> Sounds like you can achieve that with minmax~ object that you can
> reset each time the index bin is 0.
>
> HTH,
> ej
>
>
----------------------------------------------------

Thanks so much this work, but only for find the max amplitude value, i need also to "snapshot" the sync signal when the i reach the max amplitude. i don't understand why the sync is always 0. i do a comparision (==~) between the real signal from the fftin~ and the max signal of minmax~, than an edge~ that bang into a snapshot~ that "have to take" the sync signal, but nothing happened.

Here there are my three files:test,pfft_patch,fft_analysis
I use poly for downsample 64 times my samplerate, for have high precision with the signal i want to handle ( band from 0hz to 200hz).

"test" file:

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

"pfft_patch" file:

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

"fft_analysis" file:

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

mzed's icon

Quote: alyver00 wrote on Fri, 04 January 2008 03:20
----------------------------------------------------
> Hi to all, i spend a lot of time try to find how to extract the frequency with the maximum amplitude from a fft~ analysis.

Look at casey~ in the Percolate objects.

mz

Stefan Tiedje's icon

Emmanuel Jourdan schrieb:
> Sounds like you can achieve that with minmax~ object that you can reset
> each time the index bin is 0.

But that would require an additional signal input for minmax~ as the
reset at the moment is only in scheduler world, the current version of
minmax~ would not cut it. But I think its a good idea to enhance minmax~
with an extra input which would reset on 0...

go for it, that request is sort of your idea... ;-)

Stefan

--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com

Emmanuel Jourdan's icon

On 5 janv. 08, at 22:43, Stefan Tiedje wrote:

> Emmanuel Jourdan schrieb:
>> Sounds like you can achieve that with minmax~ object that you can
>> reset each time the index bin is 0.
>
> But that would require an additional signal input for minmax~ as the
> reset at the moment is only in scheduler world, the current version
> of minmax~ would not cut it. But I think its a good idea to enhance
> minmax~ with an extra input which would reset on 0...

It shouldn't be a problem in pfft~ because you can reset it at the end
of the bin, right?

ej

AlexHarker's icon

Quote: alyver00 wrote on Fri, 04 January 2008 04:20
----------------------------------------------------
> Hi to all, i spend a lot of time try to find how to extract the frequency with the maximum amplitude from a fft~ analysis.
> I try with comparator like >~, snapshot~ change~ and edge~ but nothing want work. I just want to make an pfft~ (inside a poly~ for have a good downsample of the patch) and inside the pfft~ i need to extract the frequency values (better if in float format) with an amplitude threshold that i want.

I made an object to do exactly this a couple of years ago after a discussion in the thread below - I think it outputs the peak frequency and amplitude for the entire frame:

I think I also have an mxj~ peakfinder somewhere which splits the frequency range into regions of influence around a peak value and outputs the frequency/amp of the peak for each bin in the region - maybe that would be useful also - depends on exactly what you're trying to do..

Read the thread - see whether you think it'd be useful - I can probably provide a UB, plus some other objects that do spectral gating with hold/attack/decay etc. that were made at the same time - I suspect this might be what you're after... Anyway, it might take a bit of digging out as I think it's all on an old machine and would need recompiling for UB (not difficult - just annoying).

Mac externals only, but source code can be provided to compile on a Pc and porting to java wouldn't be too hard, although unfortunately I don't have time to do it myself...

Regards,

Alex

Stefan Tiedje's icon

Emmanuel Jourdan schrieb:
> It shouldn't be a problem in pfft~ because you can reset it at the end
> of the bin, right?

But is this trustworthy? The scheduler can backlog, when will it be
executed then? I would not count on it in this case, but you know more
about the scheduler-MSP bridge than I do...

Stefan

--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com

Emmanuel Jourdan's icon
alyver00's icon

Quote: AlexHarker wrote on Sat, 05 January 2008 16:16
----------------------------------------------------
> Quote: alyver00 wrote on Fri, 04 January 2008 04:20
> ----------------------------------------------------
> > Hi to all, i spend a lot of time try to find how to extract the frequency with the maximum amplitude from a fft~ analysis.
> > I try with comparator like >~, snapshot~ change~ and edge~ but nothing want work. I just want to make an pfft~ (inside a poly~ for have a good downsample of the patch) and inside the pfft~ i need to extract the frequency values (better if in float format) with an amplitude threshold that i want.
>
> I made an object to do exactly this a couple of years ago after a discussion in the thread below - I think it outputs the peak frequency and amplitude for the entire frame:
>
> https://cycling74.com/forums/index.php?t=msg&goto=50661&rid=0&S=5da80c4a264d6a227f429cff8803a7ab
>
> I think I also have an mxj~ peakfinder somewhere which splits the frequency range into regions of influence around a peak value and outputs the frequency/amp of the peak for each bin in the region - maybe that would be useful also - depends on exactly what you're trying to do..
>
> Read the thread - see whether you think it'd be useful - I can probably provide a UB, plus some other objects that do spectral gating with hold/attack/decay etc. that were made at the same time - I suspect this might be what you're after... Anyway, it might take a bit of digging out as I think it's all on an old machine and would need recompiling for UB (not difficult - just annoying).
>
> Mac externals only, but source code can be provided to compile on a Pc and porting to java wouldn't be too hard, although unfortunately I don't have time to do it myself...
>
> Regards,
>
> Alex
>
>
----------------------------------------------------

Thanks Alex (and all the others), i finish 2 days ago the same external that you do, but in java, with the same algorithm.
Thanks anyway. I'm doing an EEG analysis patch, for the project SoundcardEEG of the openeeg.sourceforge.net projects. I made the soundcard that read the eeg signal from 4 electrode (2 channel) amplify the signal, modulate in AM format the signal amplified.
Now in Max i do the demodulation, the fft trasformation with high resolution (0,6 or 0,3 hz size each bins). I need this external for have the average frequency (the dominant frequency) of the eeg signal.
I also need a vertical fft display, with a good graphical response of the fft course.any suggests? Think about i have to display at maximum a scale of 200 vertical points interpolated by a line each others.(for now it's not my first problem, but later i have to think about it)
Thanks

Marco