## extracting peaks from pfft~

Jul 29, 2008 at 5:20pm

# extracting peaks from pfft~

Still trying to figure this one out…

I’m trying to use two pfft~ in sequence, one that zeroes all bin amplitudes lower than the previous one, the other doing the same for amplitudes higher than the previous – theoretically leaving only peaks. Something comes out, but I’m not sure it’s what I intended!

Any ideas please? The pfft~ is below. Thanks~

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 194 178 27 9109513 *~;
#P newex 142 179 27 9109513 *~;
#P newex 159 122 33 9109513 delta~;
#P newex 159 146 29 9109513 >~ 0.;
#P newex 142 238 82 9109513 fftout~ 1;
#P newex 142 209 82 9109513 poltocar~;
#P newex 142 81 63 9109513 cartopol~;
#P newex 142 50 75 9109513 fftin~ 1;
#P connect 0 0 1 0;
#P connect 1 0 6 0;
#P connect 6 0 2 0;
#P connect 2 0 3 0;
#P fasten 1 0 5 0 147 111 164 111;
#P connect 5 0 4 0;
#P connect 4 0 6 1;
#P connect 1 1 7 0;
#P fasten 0 1 1 1 179 75 200 75;
#P fasten 7 0 2 1 199 203 219 203;
#P connect 2 1 3 1;
#P window clipboard copycount 8;

#39057
Jul 29, 2008 at 10:09pm

Hi Demers,

Stefan and I were trying something quite similar a while ago and eventually decided to write it in java for mxj. If you are interested in this approach, you can go to

http://homepages.cae.wisc.edu/~sethares/spectoolsCMJ.html

and download our “Spectral Toolbox” (you’ll also need the java classes). The most relevant command is called SpT.Analysis — so you instantiate this in a block called

mxj~ SpT.Analysis

inside the pfft~, and it will do the peak finding (along with a bunch of stuff that you may not want). It shouldn’t be too hard to edit the java code and remove the irrelevant stuff…

– Bill Sethares

#136990
Jul 29, 2008 at 11:49pm

Thank you Bill (and Stefan indirectly), I’ll definitely check that out. In the meantime, I found a solution… use delta~ in two consecutive pfft~’s to calculate >~ and < ~ bin values, poke~ that data into two buffers (basically containing zeroes and ones), then use those in a third pfft~ (via index~ out of the 3rd outlet of fftin~) to be multiplied with the amplitude of the original soundfile - if both buffers contain a 1 at any given point, it's a peak and it gets passed. Add a little spectral filtering, and voila!

Probably won’t be much use to you, but here it is if you’re curious.

Inouk Demers

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 392 89 152 9109513 play soundfile after initial analysis;
#P number 572 217 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 616 215 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 520 217 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 285 289 147 9109513 pfft~ extractpeaks_sub_2 4096 4;
#P comment 622 193 15 9109513 hi;
#P newex 443 266 52 9109513 normalize~;
#P newex 444 240 189 9109513 pfft~ peakindex_sub 4096 16;
#P newex 249 232 29 9109513 -~ 1;
#P message 428 126 26 9109513 stop;
#P button 393 112 33 9;
#P newex 444 191 36 9109513 count~;
#P newex 444 216 69 9109513 index~ sound;
#P newex 156 283 88 9109513 receive~ ampvals2;
#P newex 156 307 71 9109513 poke~ amps2;
#P newex 104 121 70 9109513 buffer~ amps2;
#P message 35 95 28 9109513 clear;
#B color 9;
#P newex 156 236 83 9109513 receive~ ampvals;
#P newex 156 260 59 9109513 poke~ amps;
#P newex 35 121 65 9109513 buffer~ amps;
#P newex 206 362 70 9109513 receive~ todac;
#P message 69 94 37 9109513 size \$1;
#P newex 69 69 30 9109513 r size;
#P newex 230 98 32 9109513 s size;
#N vpatcher 94 187 611 710;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 40 93 39 9109513 gate~ 2;
#P number 30 66 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 39 428 59 9109513 send~ todac;
#P newex 41 121 63 9109513 index~ sound;
#P message 87 39 26 9109513 stop;
#P button 68 39 15 0;
#P newex 68 64 44 9109513 count~ 0;
#P message 121 405 23 9109513 0.5;
#P newex 121 379 53 9109513 loadbang;
#P flonum 67 379 35 9 0. 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 40 399 37 9109513 *~ 0.2;
#P user umenu 287 195 102 9109541 1 64 211 0;
#P message 287 217 50 9109513 scroll \$1;
#P message 176 223 46 9109513 sono \$1;
#P user umenu 176 196 100 9109543 1 32 212 1;
#P toggle 399 105 15 0;
#P message 399 125 55 9109513 logfreq \$1;
#P user umenu 227 104 102 9109541 1 64 120 0;
#P message 227 127 73 9109513 orientation \$1;
#P flonum 339 105 35 9 0. 2. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 339 125 49 9109513 range \$1;
#P window linecount 2;
#P comment 417 81 100 9109513 other goodies in inspector…;
#P user spectroscope~ 56 260 416 103 20 0 0 0 0 1 0 0 0 0 0 0;
#X frgb 157 170 240;
#X brgb 206 206 206;
#X rgb2 107 107 107;
#X rgb3 146 171 43;
#X rgb4 255 0 0;
#X rgb5 173 173 173;
#X rgb6 170 191 155;
#X rgb7 83 83 83;
#X rgb8 255 255 255;
#X rgb9 0 36 232;
#X rgb10 255 191 0;
#X rgb11 0 191 127;
#X rgb12 0 126 248;
#X rgb13 0 0 0;
#X range 0. 0.14;
#X domain 0. 22050.;
#X done;
#P window linecount 1;
#P comment 340 87 59 9109513 default 1.2;
#P connect 13 0 21 0;
#P connect 22 0 23 0;
#P connect 20 0 13 0;
#P connect 23 0 20 0;
#P connect 20 0 1 0;
#P fasten 5 0 1 0 232 153 61 153;
#P fasten 3 0 1 0 344 153 61 153;
#P fasten 7 0 1 0 404 153 61 153;
#P fasten 10 0 1 0 181 245 61 245;
#P fasten 11 0 1 0 292 245 61 245;
#P fasten 16 0 14 0 126 430 110 430 110 371 72 371;
#P connect 14 0 13 1;
#P connect 18 0 17 0;
#P connect 19 0 17 0;
#P connect 17 0 23 1;
#P connect 15 0 16 0;
#P connect 9 0 10 0;
#P connect 6 0 5 0;
#P connect 12 0 11 0;
#P connect 4 0 3 0;
#P connect 8 0 7 0;
#P pop;
#P newobj 35 159 70 9109513 p spectrograph;
#P newex 285 87 73 9109513 prepend read;
#P newex 259 132 62 9109513 mstosamps~;
#P flonum 311 158 49 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 220 40 28 9109513 open;
#P newex 220 63 79 9109513 sfinfo~;
#P newex 284 259 147 9109513 pfft~ extractpeaks_sub_3 4096 4;
#P flonum 347 315 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 284 340 28 9109513 *~ 1.;
#P message 329 362 56 9109513 startwindow;
#P user ezdac~ 285 389 329 422 0;
#P newex 285 109 73 9109513 buffer~ sound;
#P message 269 169 26 9109513 stop;
#P button 223 154 33 9;
#P newex 285 207 36 9109513 count~;
#P newex 285 232 69 9109513 index~ sound;
#P comment 520 194 67 9109513 amp threshold;
#P window linecount 2;
#P comment 548 134 100 9109513 add a moveable amplitude ‘region’?;
#P comment 548 97 100 9109513 option to shift point at which index is read;
#P window linecount 1;
#P comment 594 193 15 9109513 lo;
#P comment 188 136 67 9109513 play soundfile;
#P connect 28 0 25 0;
#P connect 23 0 25 0;
#P connect 22 0 23 0;
#P connect 23 0 29 0;
#P connect 28 0 29 0;
#P connect 27 0 26 0;
#P connect 31 0 30 0;
#P fasten 36 0 26 1 254 256 185 256;
#P fasten 36 0 30 1 254 303 191 303;
#P connect 16 0 15 0;
#P fasten 15 3 21 0 264 90 235 90;
#P connect 6 0 36 0;
#P connect 15 3 18 0;
#P connect 5 0 14 0;
#P connect 38 0 12 0;
#P connect 40 0 12 0;
#P connect 15 5 19 0;
#P connect 19 0 9 0;
#P fasten 8 0 6 0 274 199 290 199;
#P fasten 7 0 6 0 228 199 290 199;
#P connect 6 0 5 0;
#P connect 14 0 40 0;
#P connect 12 0 10 0;
#P fasten 11 0 10 0 334 384 290 384;
#P fasten 24 0 10 0 211 385 290 385;
#P connect 13 0 12 1;
#P connect 18 1 17 0;
#P connect 17 0 6 1;
#P fasten 24 0 10 1 211 385 324 385;
#P connect 12 0 10 1;
#P connect 37 0 38 0;
#P fasten 35 0 33 0 433 177 449 177;
#P fasten 34 0 33 0 398 177 449 177;
#P connect 33 0 32 0;
#P connect 32 0 37 0;
#P fasten 17 0 33 1 316 187 475 187;
#P connect 41 0 37 1;
#P connect 43 0 37 2;
#P connect 42 0 37 3;
#P window clipboard copycount 45;

#136991
Jul 30, 2008 at 8:01am

On 30 Jul 2008, at 01:49, Inouk Demers wrote:
>
> Thank you Bill (and Stefan indirectly), I’ll definitely check that
> out. In the meantime, I found a solution… use delta~ in two
> consecutive pfft~’s to calculate >~ and < ~ bin values, poke~ that
> data into two buffers (basically containing zeroes and ones), then
> use those in a third pfft~ (via index~ out of the 3rd outlet of
> fftin~) to be multiplied with the amplitude of the original
> soundfile – if both buffers contain a 1 at any given point, it’s a
> peak and it gets passed. Add a little spectral filtering, and voila!

i haven’t had a closer look at your example (the pfft subpatches are
missing), but from your description it sounds a little complicated.
so, i’m not sure the following is what you had in mind. but you
could start experimenting from something like that:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 167 324 27 196617 *~;
#P newex 126 324 27 196617 *~;
#P newex 126 353 51 196617 fftout~ 1;
#P newex 223 167 59 196617 poke~ phas;
#P newex 321 285 27 196617 *~;
#P newex 381 241 27 196617 >~;
#P newex 321 241 27 196617 < ~;
#P newex 424 203 61 196617 index~ mag;
#P newex 295 204 61 196617 index~ mag;
#P newex 360 204 61 196617 index~ mag;
#P newex 209 144 70 196617 poke~ mag;
#P newex 424 182 31 196617 +~ 1;
#P newex 295 181 30 196617 -~ 1;
#P newex 209 108 53 196617 cartopol~;
#P newex 209 53 96 196617 fftin~ 1;
#P connect 5 0 8 1;
#P connect 5 0 9 0;
#P connect 10 0 13 1;
#P connect 10 0 14 1;
#P fasten 0 1 14 0 257 93 172 93;
#P connect 0 1 1 1;
#P fasten 0 0 13 0 214 84 131 84;
#P connect 0 0 1 0;
#P fasten 0 2 4 1 300 128 244 128;
#P fasten 0 2 11 1 300 163 252 163;
#P connect 0 2 2 0;
#P connect 0 2 5 0;
#P connect 0 2 3 0;
#P connect 3 0 7 0;
#P connect 7 0 9 1;
#P connect 9 0 10 1;
#P connect 8 0 10 0;
#P connect 6 0 8 0;
#P connect 2 0 6 0;
#P connect 1 1 11 0;
#P connect 1 0 4 0;
#P connect 14 0 12 1;
#P connect 13 0 12 0;
#P window clipboard copycount 15;

#136992
Jul 30, 2008 at 5:04pm

#136993
Jul 31, 2008 at 5:38am

Hi Bill,

Very nice sound examples. They sound quite like results I have generated from my FFTease pvtuner~ external described in this paper:

http://www.sarc.qub.ac.uk/~elyon/LyonPapers/Spectral_Tuning.pdf

Are you using a similar technique?

Best,

Eric

#136994
Jul 31, 2008 at 2:50pm

Hi Eric,

Yes (and no!). There’s clearly a lot of similarities in our work… a few differences: you seem to use a fixed template to map your frequencies to. We have a pretty ingenious (if I do say so myself) ways of specifying destination locations that are more sophisticated than “map to a fixed location”. Think of a slider that allows your to move continuously from 12-tet through some meantone tunings, to 19-tet and on down to 7-tet. Both the tuning and the timbre are changed simultaneously.

In terms of technique, we both use a phase vocoder for the frequency analysis – you use an oscillator bank for resynthesis while we use an IFFT (also with a PV-like strategy to make the frequencies more accurate.) To see this in more detail, you can find a draft of our paper here:

http://eceserv0.ece.wisc.edu/~sethares/paperspdf/SpectralTools.pdf

I’d be happy for any feedback you might have on this… we have just submitted it and so have plenty of time to make revisions. Also — we clearly need to add reference your spectral tuning work… what is the best reference for this?

–Bill

#136995
Jul 31, 2008 at 3:11pm

I agree, those examples are pretty cool! Eric, I was meaning to ask you whether there were any help files for FFTease. I have 2.5, maybe they’re in a prior version?

Thanks,
Inouk

#136996
Jul 31, 2008 at 3:52pm

Hi Bill,

Your paper looks great! I’m in the middle of a conference but will look at it more closely soon. On first glance, it appears that your approach is much more subtle than the crude quantization algorithm I use in pvtuner~. The most accessible reference for my spectral tuning paper (for which I’m the sole author) is:

“Spectral Tuning,” Proceedings of the ICMC, Miami, FL, 1-6 November 2004. San Francisco: ICMA, 2004. 375-377.

Eric

p.s. Inouk – there should be help files included in the FFTease 2.5 distribution. Definitely on the Mac version, but probably on the Windows one as well.

#136997
Jul 31, 2008 at 6:11pm

Hello again Eric,

I extracted the latest version of FFTease for Windows again, and except for the brief description of each external on the webpage, I didn’t find any other help files (I confirmed this by alt-clicking the objects in Max, and a ‘help file not found’ message comes up).

I can try and guess what the inlets and outlets represent from the messages at the bottom of the window, but I admit I haven’t had much success so far!

It’s a great collection though – can’t wait to use it.

Best,
Inouk

#136998
Aug 1, 2008 at 9:48am

Quote: demers wrote on Thu, 31 July 2008 20:11
—————————————————-
> Hello again Eric,
>
> I extracted the latest version of FFTease for Windows again, and except for the brief description of each external on the webpage, I didn’t find any other help files

they are not there.
i zipped and attached the files from the mac osx package.

regards,
kjg

#136999
Aug 1, 2008 at 4:50pm

Dear kjg,

Oh, thank you so much! Very kind of you to pass that along. I’m like a kid in a toy store now…

Best wishes,
Inouk

#137000
Aug 1, 2008 at 6:16pm

Inouk Demers schrieb:
> I extracted the latest version of FFTease for Windows again, and
> except for the brief description of each external on the webpage, I
> didn’t find any other help files

You could download the Mac version and take the help files from there…

Stefan

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

#137001
Aug 2, 2008 at 9:49pm

Incidentally, the sound examples for the spectral tuning paper that I posted may be heard at:

http://www.sarc.qub.ac.uk/~elyon/LyonPapers/

Eric

#137002

You must be logged in to reply to this topic.