Forums > MaxMSP

fft question


MIB
February 19, 2008 | 5:19 am

I think I am having some conceptual problems here. Any help would be greatly appreciated.
I am trying to send out the centre frequencies of bins with high amplitude values, then use those for further synthesis (additive, FM or whatnot). Is this approach suitable at all?? Or do I completely misunderstand the whole real/imaginary number thing??
Thanks a bunch.

#P window setfont "Sans Serif" 9.;
#P user number~ 243 226 312 241 9 3 3 2 0. 0. 0 0. 250 0. 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#N in 2;
#P newobj 366 60 25 196617 in 2;
#P newex 207 226 35 196617 gate~;
#P newex 54 139 33 196617 >~ 0.;
#P newex 207 295 59 196617 send~ out1;
#P newex 54 102 53 196617 poltocar~;
#P flonum 301 128 52 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 232 181 27 196617 *~;
#P newex 249 146 46 196617 / 1024.;
#P newex 268 106 53 196617 fftinfo~;
#P newex 249 77 29 196617 t f b;
#P newex 235 51 54 196617 dspstate~;
#P newex 54 54 141 196617 fftin~ 1;
#P window linecount 2;
#P comment 263 177 100 196617 center frequency of current bin;
#P connect 6 0 11 1;
#P connect 6 0 13 0;
#P connect 1 0 8 0;
#P connect 8 0 10 0;
#P connect 12 0 10 1;
#P connect 10 0 11 0;
#P connect 11 0 9 0;
#P fasten 1 2 6 0 189 126 237 126;
#P connect 2 1 3 0;
#P connect 3 0 5 0;
#P connect 5 0 6 1;
#P connect 3 1 4 0;
#P fasten 4 0 5 1 273 134 290 134;
#P connect 4 0 7 0;
#P window clipboard copycount 14;


February 19, 2008 | 9:32 am

You aren’t actually sending an audio signal out, so its appropriateness
depends on your implementation. What is your plan for the frequency
numbers?

On 19/02/2008, Martin Ritter wrote:
>
>
> I think I am having some conceptual problems here. Any help would be
> greatly appreciated.
> I am trying to send out the centre frequencies of bins with high amplitude
> values, then use those for further synthesis (additive, FM or whatnot). Is
> this approach suitable at all?? Or do I completely misunderstand the whole
> real/imaginary number thing??
> Thanks a bunch.
>
> #P window setfont "Sans Serif" 9.;
> #P user number~ 243 226 312 241 9 3 3 2 0. 0. 0 0. 250 0. 0 0 0 221 221
> 221 222 222 222 0 0 0;
> #P window linecount 1;
> #N in 2;
> #P newobj 366 60 25 196617 in 2;
> #P newex 207 226 35 196617 gate~;
> #P newex 54 139 33 196617 >~ 0.;
> #P newex 207 295 59 196617 send~ out1;
> #P newex 54 102 53 196617 poltocar~;
> #P flonum 301 128 52 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 232 181 27 196617 *~;
> #P newex 249 146 46 196617 / 1024.;
> #P newex 268 106 53 196617 fftinfo~;
> #P newex 249 77 29 196617 t f b;
> #P newex 235 51 54 196617 dspstate~;
> #P newex 54 54 141 196617 fftin~ 1;
> #P window linecount 2;
> #P comment 263 177 100 196617 center frequency of current bin;
> #P connect 6 0 11 1;
> #P connect 6 0 13 0;
> #P connect 1 0 8 0;
> #P connect 8 0 10 0;
> #P connect 12 0 10 1;
> #P connect 10 0 11 0;
> #P connect 11 0 9 0;
> #P fasten 1 2 6 0 189 126 237 126;
> #P connect 2 1 3 0;
> #P connect 3 0 5 0;
> #P connect 5 0 6 1;
> #P connect 3 1 4 0;
> #P fasten 4 0 5 1 273 134 290 134;
> #P connect 4 0 7 0;
> #P window clipboard copycount 14;
>
>
>


February 19, 2008 | 9:35 am

Also, I wasn’t looking at your patch properly, but you need the cartopol
object in order to get amplitude data

On 19/02/2008, Joe Bicker wrote:
>
> You aren’t actually sending an audio signal out, so its appropriateness
> depends on your implementation. What is your plan for the frequency
> numbers?
>
> On 19/02/2008, Martin Ritter wrote:
> >
> >
> > I think I am having some conceptual problems here. Any help would be
> > greatly appreciated.
> > I am trying to send out the centre frequencies of bins with high
> > amplitude values, then use those for further synthesis (additive, FM or
> > whatnot). Is this approach suitable at all?? Or do I completely
> > misunderstand the whole real/imaginary number thing??
> > Thanks a bunch.
> >
> > #P window setfont "Sans Serif" 9.;
> > #P user number~ 243 226 312 241 9 3 3 2 0. 0. 0 0. 250 0. 0 0 0 221 221
> > 221 222 222 222 0 0 0;
> > #P window linecount 1;
> > #N in 2;
> > #P newobj 366 60 25 196617 in 2;
> > #P newex 207 226 35 196617 gate~;
> > #P newex 54 139 33 196617 >~ 0.;
> > #P newex 207 295 59 196617 send~ out1;
> > #P newex 54 102 53 196617 poltocar~;
> > #P flonum 301 128 52 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> > #P newex 232 181 27 196617 *~;
> > #P newex 249 146 46 196617 / 1024.;
> > #P newex 268 106 53 196617 fftinfo~;
> > #P newex 249 77 29 196617 t f b;
> > #P newex 235 51 54 196617 dspstate~;
> > #P newex 54 54 141 196617 fftin~ 1;
> > #P window linecount 2;
> > #P comment 263 177 100 196617 center frequency of current bin;
> > #P connect 6 0 11 1;
> > #P connect 6 0 13 0;
> > #P connect 1 0 8 0;
> > #P connect 8 0 10 0;
> > #P connect 12 0 10 1;
> > #P connect 10 0 11 0;
> > #P connect 11 0 9 0;
> > #P fasten 1 2 6 0 189 126 237 126;
> > #P connect 2 1 3 0;
> > #P connect 3 0 5 0;
> > #P connect 5 0 6 1;
> > #P connect 3 1 4 0;
> > #P fasten 4 0 5 1 273 134 290 134;
> > #P connect 4 0 7 0;
> > #P window clipboard copycount 14;
> >
> >
> >
>
>



MIB
February 19, 2008 | 9:57 am

My bad about the cartopol~ …
Still, when I adjust the float for the >~, numbers bigger than 0.1 rarely give me any output. I would have assumed that numbers bigger than 0.5 would have that effect.
As for the use of the frequency data… well, nothing very concrete at this point. I was hoping to maybe use the data to do some additive synthesis (maybe also use the amplitude data in some way) to create a backdrop of sort. It’s all a bit vague right now, I am pretty sure though that I need those numbers…

Save as binsAndStuff:

#P window setfont "Sans Serif" 9.;
#P user number~ 283 223 352 238 9 3 3 2 0. 0. 0 0. 250 0. 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#N in 2;
#P newobj 373 31 25 196617 in 2;
#P newex 223 197 35 196617 gate~;
#P newex 61 110 33 196617 >~ 0.;
#P newex 223 402 59 196617 send~ out2;
#P newex 61 73 53 196617 cartopol~;
#P flonum 308 99 52 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 239 152 27 196617 *~;
#P newex 256 117 46 196617 / 1024.;
#P newex 275 77 53 196617 fftinfo~;
#P newex 256 48 29 196617 t f b;
#P newex 242 22 54 196617 dspstate~;
#P newex 61 25 141 196617 fftin~ 1;
#P connect 0 0 7 0;
#P connect 11 0 9 1;
#P connect 7 0 9 0;
#P connect 0 1 7 1;
#P connect 9 0 10 0;
#P connect 10 0 8 0;
#P connect 0 2 5 0;
#P connect 1 1 2 0;
#P connect 2 0 4 0;
#P connect 4 0 5 1;
#P connect 2 1 3 0;
#P connect 5 0 12 0;
#P connect 5 0 10 1;
#P fasten 3 0 4 1 280 105 297 105;
#P connect 3 0 6 0;
#P window clipboard copycount 13;

Main Patch:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 135 95 30 196617 open;
#P number 277 112 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 277 134 59 196617 interval $1;
#P newex 277 157 73 196617 receive~ out2;
#P user number~ 277 184 358 199 9 3 3 2 0. 0. 0 0. 20 0. 0 0 0 221 221 221 222 222 222 0 0 0;
#P user meter~ 121 178 201 191 50 0 168 0 103 103 103 255 153 0 255 0 0 217 217 0 153 186 0 12 3 3 3 3;
#P toggle 88 75 15 0;
#P message 88 95 43 196617 loop $1;
#P flonum 174 122 44 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user ezdac~ 54 193 98 226 0;
#P toggle 54 82 15 0;
#N sfplay~ 1 120960 0 ;
#P newobj 54 116 44 196617 sfplay~;
#P newex 54 150 130 196617 pfft~ binsAndStuff 1024 4;
#P fasten 12 0 1 0 140 112 59 112;
#P connect 2 0 1 0;
#P connect 6 0 5 0;
#P connect 5 0 1 1;
#P connect 1 0 7 0;
#P connect 1 0 0 0;
#P connect 4 0 0 1;
#P connect 10 0 8 0;
#P connect 9 0 8 0;
#P connect 11 0 10 0;
#P window clipboard copycount 13;


February 19, 2008 | 4:45 pm



MIB
February 24, 2008 | 3:03 am

Thanks for the help so far. I agree about the send~/receive~, that was just meant to be a quick and dirty way to get at the data…
I have been playing around a bit more and was hoping to get advice once again. I am now using minmax~ to regulate what goes through the gate~. I am wondering if there is a better way, this seems odd.
The other thing I was wondering about is the capture~ part. I am planning to replace that with a buffer and use poke~. The question is: How do I get the data inside the buffer into the Max domain?? Would that be peek~? Sorry if that is obvious, but I have never used any of those. Also, how would I index the buffer data since I would only want numbers other than 0 to be written into it?? I think the index from the fftin~ is useless for this.

So much to learn, so little time. Thanks for indulging in my ramblings.

Main Patch:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P hidden newex 317 60 80 196617 loadmess -0.12;
#P hidden newex 256 60 60 196617 loadmess 1;
#P button 209 105 15 0;
#P flonum 303 89 35 9 0 0. 2 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 256 89 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 209 122 105 196617 pack deltaclip 1. -1.;
#P window linecount 3;
#P comment 319 111 150 196617 – slide ; logarithmic movement to new value;
#P user meter~ 114 171 194 184 50 0 168 0 103 103 103 255 153 0 255 0 0 217 217 0 153 186 0 12 3 3 3 3;
#P user ezdac~ 47 186 91 219 0;
#P window linecount 1;
#P message 65 75 64 196617 open , loop 1;
#P toggle 47 75 15 0;
#N sfplay~ 1 120960 0 ;
#P newobj 47 109 44 196617 sfplay~;
#P newex 47 143 130 196617 pfft~ binsAndStuff 1024 4;
#P hidden connect 12 0 9 0;
#P connect 9 0 10 0;
#P connect 9 0 7 2;
#P connect 8 0 10 0;
#P connect 8 0 7 1;
#P hidden connect 11 0 8 0;
#P connect 10 0 7 0;
#P connect 1 0 0 0;
#P connect 1 0 5 0;
#P connect 0 0 4 0;
#P connect 0 0 4 1;
#P fasten 7 0 0 0 214 141 52 141;
#P fasten 3 0 1 0 70 101 52 101;
#P connect 2 0 1 0;
#P window clipboard copycount 13;

save as binsAndStuff.pfft

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 63 143 43 196617 size $1;
#N in 1;
#P newobj 42 52 25 196617 in 1;
#P newex 172 491 69 196617 poltocar~;
#P newex 63 377 70 196617 vectral~ 512;
#P flonum 393 681 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 351 674 27 196617 t f f;
#P newex 351 728 27 196617 – 0.;
#P newex 368 704 35 196617 * 0.1;
#P newex 172 518 69 196617 fftout~ 1;
#P newex 231 307 53 196617 gate~ 1 0;
#P newex 172 307 56 196617 gate~ 1 0;
#P message 510 308 31 196617 clear;
#P newex 450 337 90 196617 capture~ f 10000;
#P message 189 623 34 196617 reset;
#P button 302 600 15 0;
#P newex 302 575 35 196617 spike~;
#B color 5;
#P newex 302 551 37 196617 ==~ 0;
#P newex 150 570 31 196617 abs~;
#P newex 210 240 29 196617 sig~;
#P newex 150 644 213 196617 minmax~;
#B color 5;
#P newex 450 308 35 196617 gate~;
#P newex 172 272 48 196617 >=~ 0.;
#P newex 172 102 75 196617 cartopol~;
#P newex 475 183 27 196617 *~;
#P newex 492 148 46 196617 / 1024.;
#P newex 511 108 53 196617 fftinfo~;
#P newex 492 79 29 196617 t f b;
#P newex 478 53 54 196617 dspstate~;
#P newex 172 52 141 196617 fftin~ 1;
#P window linecount 2;
#P comment 506 179 100 196617 center frequency of current bin;
#P fasten 4 0 5 1 516 140 533 140;
#P connect 3 1 4 0;
#P connect 5 0 6 1;
#P connect 3 0 5 0;
#P connect 2 1 3 0;
#P connect 6 0 9 1;
#P fasten 1 2 26 0 307 161 68 161;
#P fasten 1 2 26 1 307 166 98 166;
#P connect 1 2 13 0;
#P fasten 1 2 6 0 307 153 480 153;
#P connect 9 0 17 0;
#P fasten 18 0 17 0 515 333 455 333;
#P connect 8 0 19 0;
#P fasten 8 0 20 0 177 299 236 299;
#P fasten 8 0 9 0 177 295 455 295;
#P connect 25 0 22 1;
#P connect 22 0 23 1;
#P fasten 24 1 22 0 373 697 373 697;
#P fasten 24 0 23 0 356 711 356 711;
#P connect 10 3 24 0;
#P connect 14 0 15 0;
#P connect 13 0 14 0;
#P fasten 7 1 20 1 242 289 279 289;
#P fasten 1 1 7 1 242 87 242 87;
#P connect 27 1 21 1;
#P connect 20 0 27 1;
#P fasten 7 0 12 0 177 129 155 129;
#P connect 7 0 8 0;
#P fasten 7 0 19 1 177 262 223 262;
#P connect 11 0 8 1;
#P fasten 23 0 11 0 356 764 138 764 138 230 215 230;
#P fasten 15 0 10 0 307 640 155 640;
#P fasten 15 0 16 0 307 620 194 620;
#P connect 27 0 21 0;
#P fasten 26 0 27 0 68 479 177 479;
#P connect 1 0 7 0;
#P fasten 16 0 10 0 194 640 155 640;
#P connect 12 0 10 0;
#P fasten 19 0 26 2 177 350 128 350;
#P fasten 28 0 26 0 47 168 68 168;
#P connect 29 0 26 0;
#P fasten 4 1 29 0 530 135 68 135;
#P window clipboard copycount 30;


February 24, 2008 | 9:05 am

hey – i’m doing something similar – it still has some kinks reading through the buffer index but it’s getting close if you want to take a look at it. i just posted this:

http://www.cycling74.com/forums/index.php?t=msg&th=31368&start=0&rid=2973&S=4cc0c2654b18f181cda10b947f8cc450

i saw your post before, when i was searching the forum posts for clues – but i didn’t look at the date! : )

cheers,

rama



MIB
February 24, 2008 | 10:15 pm

Thanks for the patch. Now I know how to use peek~ and poke~ :)
I am still not sure on how to write just certain bins into the buffer – let’s say bin 20, 34, 66 and 125 – but at index 1,2,3,4 respectively. Any ideas would be greatly appreciated.


February 24, 2008 | 11:10 pm

there might be a way to switch it around – but i think the default is labeling the bins by the "sample" index number. you can query the index/bins recorded into the buffer by using the peek~ object to get the readings – and dump it into a coll file and re-sort. this is what i’ve been doing (i just put a new version of the patch i’ve been working on with this over on the other thread that does this: http://www.cycling74.com/forums/index.php?t=msg&th=31368&start=0&rid=2973&S=4cc0c2654b18f181cda10b947f8cc450). i’m finding some time efficiency problems with using coll to sort this data – so i’m trying to find another way to do it too.

but if you only have a few bins you are interested in, querying just those into a coll or table would be a lot faster than going through the whole fft maybe that might be a good way to go -

hope that helps!

/r


February 24, 2008 | 11:30 pm

after thought:

also if you record a buffer longer than the frame-size used in pfft (actually half the frame-size) – the index numbers continue ascending. so using this logic, i believe mulitples of: bin number * (frame-size * frame-number), will give you the corresponding buffer index numbers for the same bin in successive frames.

/r


February 25, 2008 | 3:02 pm


Viewing 11 posts - 1 through 11 (of 11 total)