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

Jan 4, 2008 at 11:20am

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

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

#35206
Jan 4, 2008 at 11:56am

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

#119803
Jan 4, 2008 at 12:15pm

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

#119804
Jan 4, 2008 at 1:24pm

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 v2;
#N vpatcher 32 44 350 391;
#P window setfont “Sans Serif” 9.;
#P flonum 91 202 35 9 0. 2. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 41 235 35 196617 *~ 1.;
#P message 64 255 48 196617 down 64;
#P message 244 55 27 196617 stop;
#P message 173 55 65 196617 startwindow;
#P newex 173 93 29 196617 dac~;
#P flonum 41 179 62 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 41 154 35 196617 * 10.;
#P newex 41 112 46 196617 / 1024.;
#P flonum 41 134 63 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 41 66 64 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 41 87 34 196617 / 64.;
#P newex 27 40 54 196617 dspstate~;
#P newex 41 202 40 196617 cycle~;
#P newex 41 284 85 196617 poly~ pfft_patch;
#P window linecount 3;
#P comment 112 145 100 196617 Exact frequency for the 10 freq.bin of the fft;
#P window linecount 4;
#P comment 135 239 100 196617 Downsample of 64 for an high precision with signal of max 200 hz;
#P connect 4 1 6 0;
#P connect 6 0 5 0;
#P connect 5 0 8 0;
#P connect 8 0 7 0;
#P connect 7 0 9 0;
#P connect 9 0 10 0;
#P connect 10 0 3 0;
#P connect 3 0 15 0;
#P connect 15 0 2 0;
#P fasten 14 0 2 0 69 276 46 276;
#P fasten 16 0 15 1 96 228 71 228;
#P connect 12 0 11 0;
#P fasten 13 0 11 0 249 85 178 85;
#P pop;

“pfft_patch” file:

max v2;
#N vpatcher 442 54 740 182;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N in~ 1;
#P newobj 33 36 33 196617 in~ 1;
#P newex 33 66 127 196617 pfft~ fft_analysis 1024 2;
#P window linecount 3;
#P comment 171 56 100 196617 2 overlapping windows , but can be also 1 or more;
#P connect 2 0 1 0;
#P pop;

“fft_analysis” file:

max v2;
#N vpatcher 606 382 921 780;
#P origin 73 0;
#P window setfont “Sans Serif” 9.;
#P newex 28 94 84 196617 capture~ f 4096;
#P newex 156 323 71 196617 capture 1024;
#P newex 120 235 36 196617 edge~;
#P newex 120 192 43 196617 ==~;
#P flonum 120 346 45 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 120 287 55 196617 snapshot~;
#P message 190 132 34 196617 reset;
#P newex 190 105 36 196617 edge~;
#P newex 190 81 37 196617 ==~ 0;
#P flonum 181 190 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 139 158 53 196617 minmax~;
#P newex 120 45 81 196617 fftin~ 1 hanning;
#P window linecount 3;
#P comment 30 117 81 196617 for see the first 4096 real values;
#P window linecount 2;
#P comment 178 209 49 196617 The max amplitude;
#P window linecount 1;
#P comment 183 296 85 196617 THIS DON’T WORK;
#P fasten 3 0 14 0 125 78 33 78;
#P connect 3 0 11 0;
#P connect 11 0 12 0;
#P fasten 3 2 9 0 195 73 245 73 245 268 125 268;
#P connect 12 0 9 0;
#P connect 9 0 10 0;
#P fasten 3 0 4 0 125 114 144 114;
#P fasten 8 0 4 0 195 151 144 151;
#P fasten 7 0 4 0 195 128 144 128;
#P connect 4 1 11 1;
#P fasten 9 0 13 0 125 315 161 315;
#P connect 4 3 5 0;
#P connect 3 2 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P pop;

#119805
Jan 4, 2008 at 9:37pm

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

#119806
Jan 5, 2008 at 9:43pm

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

#119807
Jan 5, 2008 at 10:56pm

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

#119808
Jan 5, 2008 at 11:16pm

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:

http://www.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

#119809
Jan 6, 2008 at 8:06am

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

#119810
Jan 6, 2008 at 10:50am

#119811
Jan 6, 2008 at 4:13pm

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:
>
> http://www.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

#119812

You must be logged in to reply to this topic.