Real and Imaginary into Poke~. Sync Problem?

Dominik Dudek's icon

Hello,
I'm trying to write Real and imaginary numbers from fftin~ into separate buffers using poke~ object.
Index number is provided by a single count~ object.
As i understand, count~ uses samples as count-limit, and buffer~ uses ms. So in count i set it to 4410 samps and in buffer 100 ms (working on 44.1 kHz).
When i try to check how it sounds it seems like it has some phase issue (flanging sound).
First i checked if my grooves are in sync (using second outlet and comparing in scope~). They are in sync.
So it's something inside my pfft~.

Could you help me to figure this out?

my_nr.maxpat
Max Patch


Dominik Dudek's icon

I just realized, that i could use 2 channel buffer instead of 2 1 channel buffers.
It will be probably a solution.
Will check and post

Chris Rolfe's icon

Are you aware of the fft real-to-complex packing format? The documentation (or help patcher?) has details hidden somewhere (perhaps fft~.maxhelp?) but iirc the real and imaginary array is arranged:

[DC][Nyquist]
f1: [real][imag]
f2: [real][imag]
f3: [real][imag]

The first entry is not a complex number but two real numbers. It matters if you're doing complex math in the frequency domain (in a pfft~ subpatcher for example).

Dominik Dudek's icon

Hey,
Yeah, i'm aware of the format which fftin~ is outputting.
I thought that buffer~ would handle this.


Although i just found this:
https://docs.cycling74.com/max7/tutorials/14_analysischapter04
(next to last example)

I will check that example, it looks like something i wanted to do :D

Roman Thilenius's icon

why poke~? i.e. why not record~?

Chris Rolfe's icon

I don't see packing in that tutorial. A bit clearer though:

[f0:DC][fn-1:Nyquist]
f1: [real][imag]
f2: [real][imag]
f3: [real][imag]

where DC and Nyquist are the real components of bin 0 and n-1.

Could you be assuming 1 bin too few or many?

A few years ago, I tested inplace ffts in Max. Here's a test patcher using jit.fft that splits real/imag to phase/mag and then roundtrip back to the original. At least a sanity check (?).

Chris Rolfe's icon

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

testcase's icon

Could you explain a little more what you are trying to do or post the patch the pfft~ is in? What is the overlap factor for the pfft~. I believe you need to use #0 to get unique buffer names or else . btw you can make a buffer~ with a specific size in samples like this [buffer~ name -1 2 @samps 512]