Forums > MaxMSP

Phase rotation in FFT ?

September 18, 2006 | 8:01 pm

Hi,
I thought phase rotation in FFT is just change the phase of the input signal within pfft subpatch.
The original subpatch which I learned from Cort Lippe’s paper is look like this which works fine, but complicated in math.
Something like this:
(a+bi)* (cosX + i sinX) = (a cosX -b sinX) + (a sinX + b cos X)i

but since it is just adding some angle to the original phase, I made another patch use cartopol~ object in which I just add the numbers to the original phase angle. However, the output does not seem to be as effective as the first one. Am I misunderstood the theory ?

The codes of the correct one and the simplified one ("wrong" one) are as follows. Can anyone let me know why the 2nd patch does not work well ?

Thank you very much.

max v2;
#N vpatcher 15 55 615 455;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 162 325 45 9109513 fftout~ 1;
#P newex 247 284 27 9109513 +~;
#P newex 161 284 27 9109513 -~;
#P comment 276 174 43 9109513 cosin;
#P message 302 124 29 9109513 -0.25;
#P newex 302 102 45 9109513 loadbang;
#P newex 276 149 36 9109513 cycle~;
#P newex 367 146 36 9109513 cycle~;
#P newex 270 249 27 9109513 *~;
#P newex 232 247 27 9109513 *~;
#P newex 192 247 27 9109513 *~;
#P newex 155 248 27 9109513 *~;
#N in 2;
#P newobj 319 43 23 9109513 in 2;
#P newex 183 41 40 9109513 fftin~ 1;
#P comment 370 170 24 9109513 sine;
#P comment 51 288 100 9109513 (a cos x – b sin x);
#P comment 295 285 100 9109513 (a sin x + b cos x) i;
#P connect 3 0 5 0;
#P connect 5 0 14 0;
#P connect 14 0 16 0;
#P connect 10 0 5 1;
#P connect 6 0 14 1;
#P connect 3 1 6 0;
#P connect 15 0 16 1;
#P connect 9 0 6 1;
#P connect 3 1 7 0;
#P connect 7 0 15 0;
#P connect 10 0 7 1;
#P connect 8 0 15 1;
#P connect 3 0 8 0;
#P connect 4 0 10 0;
#P connect 9 0 8 1;
#P connect 11 0 12 0;
#P connect 12 0 10 1;
#P connect 4 0 9 0;
#P pop;

max v2;
#N vpatcher 435 95 1035 495;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 103 276 45 9109513 fftout~ 1;
#P newex 102 220 46 9109513 poltocar~;
#P newex 138 169 27 9109513 +~;
#P newex 101 129 46 9109513 cartopol~;
#N in 2;
#P newobj 172 87 23 9109513 in 2;
#P newex 103 88 40 9109513 fftin~ 1;
#P connect 0 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 5 0;
#P connect 0 1 2 1;
#P connect 2 1 3 0;
#P connect 3 0 4 1;
#P connect 4 1 5 1;
#P connect 1 0 3 1;
#P pop;


September 19, 2006 | 8:22 am

OK

Not really sure what you’re trying to do here, but anyway…..

The two patches do different things. The first adds a variable phase (according to the frequency of the cycle~ objects) – the second adds a fixed phase, which won’t make it sound any different to the original (except as you alter it). In the first the phase rotation will vary between 0 and two pi. My corrected version of the second patch is below. I haven’t checked it, but i think it does the same thing.

The first patch is more efficient in terms of CPU though, so i can’t see any good reason to do the second unless its just to try and figure out what’s going on in this case, or unless you will need the polar representation later. The maths may seem more complex this way, but multiplication + addition is much cheaper on CPU than the trigonometry needed in cartopol~ or poltocar~ Anyway, if you really want to do it the polar way i believe below is an equivalent patch. Sorry if it doesn’t work. I did it quite quickly…..

Alex

max v2;
#N vpatcher 10 59 610 459;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 248 236 32 196617 *~ 2;
#P newex 247 199 179 196617 *~ 3.141593;
#P newex 235 172 46 196617 phasor~;
#P newex 163 336 59 196617 fftout~ 1;
#P newex 162 280 60 196617 poltocar~;
#P newex 198 229 27 196617 +~;
#P newex 161 189 60 196617 cartopol~;
#N in 2;
#P newobj 232 147 23 196617 in 2;
#P newex 163 148 40 196617 fftin~ 1;
#P connect 0 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 5 0;
#P connect 2 1 3 0;
#P connect 0 1 2 1;
#P connect 3 0 4 1;
#P connect 4 1 5 1;
#P connect 8 0 3 1;
#P connect 1 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P pop;


September 19, 2006 | 3:37 pm

They generate the same effects now.
But I still have no idea about the math in it. I think I can imagine the cos~ in the first patch keeps "modulate" the parameters from fftin~, but I don’t quite understand why your modified version equals to the first. For me, phasor~ is just a saw tooth oscillator. I am completely lost.

Any math or physics readings I should review ?

Thank you very much.


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