Kyma Forum
  Tips & Techniques
  general FFT questions

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   general FFT questions
johannes
Member
posted 06 May 2014 16:31         Edit/Delete Message   Reply w/Quote
hello,

i have 3 basic kyma fft questions:

1. i wonder if it would be possible to process fft data at framerate instead of doing it at samplerate. lets say i want to randomize the phases (after convert from cartesian to polar) by adding random amounts (between 0 and pi) to all phasevalues before convert back to cartesian coords. would it be possible to write fftsize/2 sample of my phase data into a wavetable and add an array of randomnumbers to it?

2. is it possible to use hopsizes greater than fftsize/2 and fftsizes greater than 1024?

3. i am still a bit confused about the output of fft. regarding the "fft 512 analysis" prototype the
left and right channel are used for the undelayed and delayed signal... so is it meant for processing the overlapping frames independently, no?
the output of fft are the x and y values of the cartesian coordinates, right?

thanks for your help to make me understand,
ciao,
johannes

IP: Logged

gustl
Member
posted 07 May 2014 04:55         Edit/Delete Message   Reply w/Quote
Hi johannes,

I'm not the real pro regarding this but maybe I can help:

1. Isn't the FFT data already framebased? e.g. A 512 point FFT is represented in 512 samples so 1 frame is 512 samples long. I'm not sure if I understand everything correctly but if you want to add random numbers to all phases you don't need to care about the frame, just use a noise module and a mixer. If you want to add the same random generated value for all phases in one frame you can use a SampleAndHold module with FFTsize samp Hold time after the noise.

2. Yes. But the FFTsize hast to be a power of 2.

3. I think the delayed and undelayed signal are just made up to process a mono signal. If you change the delayed signal to a Constant 0 and use only the left output of the inv FFT you get the same signal back. So I think the FFT module is made for 2-channel (Stereo) Input and therefore you are actually doing a 256 point FFT for 2 channels when choosing an FFTsize of 512.
The Outputs of the FFT are complex numbers (real part = left, imaginary part = right) which you can interpret as cartesian coordinates in the complex plane (z-plane).


Best wishes,
gustl

IP: Logged

johannes
Member
posted 07 May 2014 06:38         Edit/Delete Message   Reply w/Quote
hey gustl, thanks for taking the time.

1:
for me its a bit tricky to understand the sr based fftdata processing, because in other programming environments like in max-ftm library the fftdata is stored in matrices and the processing happens at hopsize rate. (the equivalent fft object outputs a frame each hopsize samples). but in kyma things work differently. from what i know, with each sample we get the data for one bin (a x-y pair that we convert to mags and phi of a specific bin). so i would like to know how fft data get buffered under hood in kyma... does this happens after analyzing the last bin in a frame, right before fft starts to analyze the next frame?

the other reason i asked for the processingrate was because i would like to use capytalk scripts to mangle the fft data. e.g modulo, divide, etc

yes, i already used white noise for that. great hint with the sample and hold!


2:
so for a 4-time overlap of the frames i will simply have to add 2 more delays before and after fft and ifft? or would you do that?

3:
will make some experiments and report back later. but this is still a bit unclear to me: how can the left channel (of fft output) be the real part (x axis value) and the anlysis of the left stereo channel at the same time... i might miss something.


again, thanks for your help.
ciao, johannes

[This message has been edited by johannes (edited 07 May 2014).]

IP: Logged

gustl
Member
posted 07 May 2014 07:37         Edit/Delete Message   Reply w/Quote
no problem

1: I don't know what hopsize means but in Kyma it works like this: The FFT module has got 2 inputs (left, right). When you start the Sound there's a short delay (3 * FFTsize samples at FFTsize 512) for buffering/calculating. Then it will output the complex numbers (left = real, right = imaginary) at samplerate. Each sample represents one bin so when you do a FFT with size 512 each 256 samples represent 1 frame (alternating between left and right input - see 3 below).
CapyTalk doesn't work at samplerate it just works at 1 kHz so you can't use it to process the stream directly. However you can control modules that work at samplerate with CapyTalk.

2: No, I think for overlaps you'd have to use 2 FFT modules and make up the timing and the windowing yourself.

3: The FFT module is alternating between the left and the right input. So for 256 samples (again for 512 point FFT) it will output the complex numbers of the left input and for another 256 samples it will output the complex numbers of the right input. An FFTsize of 512 actually is a 2 channel 256 point FFT.

Select the FFT module and go to Info -> Describe Sound. It's basically all in there

IP: Logged

gustl
Member
posted 07 May 2014 12:04         Edit/Delete Message   Reply w/Quote
add 2: By thinking about this again I think you can use the 2 inputs to do the overlapping windows

best wishes,
gustl

IP: Logged

pete
Member
posted 07 May 2014 15:43         Edit/Delete Message   Reply w/Quote
Hi Johannes

I think you can have FFT frame sizes greater than 1024 but only on the paca(rana) (not the capybara).

Gustl is right, but there are a few things to note about the FFT Module (assuming it hasn't changed lately). The left and right input expect two different signals but they are analyzed at the same frame edge so to achieve the half frame overlap you need to delay one leg. Also you will probably need windowing of the two overlapping frames and this has to be done before feeding the left and right inputs. The output of the module gives a stream of pairs of values (left reals and right imagins) in alternating frames, left input result right input result etc. So if your FFT length was 1024 samples you would get 512 pairs of points of the left inputs results followed by 512 pairs of points of the right inputs results.

But heres the crunch. The first 512 point start with DC then 1,2 3 harmonic, but the second 512 point come out in reverse order, harmonic 511,510 all the way down to DC. The inverse FFT module expects this forward backward arrangement of the partials and will output the two simultaneous (time domain) frames on the left and right output, but with the frame edges in sync. So you will need to delay the one leg you didn't delay on the way in, before combining them to get the clean mono output signal.

I think we worked out that the overall route from in to out (with the delays and processing time) took a total of 7.5 frames. If you have a capybara I may have some old DSP code I through together that didn't use FFT, but used my own FT algorithm, that was not so efficient but had a lower latency and dealt with the windowing , overlapping and outputted the partials from DC upwards all the time. It had an overall latency of 1.5 frames, but it cannot be used on the Paca(rana).

As gustl said if you want the data in tables you would have to record the streams of data into the tables (at sample rate). This is in effect what is happening with the other table based FFTs except that the streaming is done before hand.

For quarter frame overlapping you would need two sets of FFTs and would have to have different input and output delays to shift the frames to the correct place. I don't know how you would deal with two stereo streams of data but I suspect there are ways.

I hope this makes sense

And just in passing, it's not the Z-Plane, it's BarbieCam.

Pete

IP: Logged

gustl
Member
posted 08 May 2014 03:22         Edit/Delete Message   Reply w/Quote
quote:
I think you can have FFT frame sizes greater than 1024 but only on the paca(rana) (not the capybara).

Definitely!

I didn't know the thing about the reversed bins, thanks for the information! This should be added to the Prototype description!

BarbieCam, of course

IP: Logged

johannes
Member
posted 08 May 2014 05:15         Edit/Delete Message   Reply w/Quote

4x-ola-fft.kym

 
hey gustl and pete,

thanks for the very detailed explanations. it really helped me to understand whats going on.

pete, is there a specific reason for the reverse partial order (in the fft output) for every second frame?
and what do you mean with "to record the streams of data into the TABLES"?

i just worked on the 4 times overlap using the 2 inputs. with a fftsize of 1024 samples i set the delaytimes to 0 and 512 on the left and 256 and 768 samples on the right channel, than joining, windowing (frequency: fftsize), fft...
after the ifft i set the delays exactly the other way arround: 0 and 512 on the right and 256 and 768 samples on the left channel…probably that last part is wrong because it creates a combfilter like modulation on the resynthesis signal.
i also tried a 2 fft-ift sets version that works for now...but here also some slight modulation happens that gets stronger as you increase the fft size. i append a patch with both versions.

too bad that capytalk wont work for direct fft processing. i already had some ideas including the use of modulo and divide... and there is no samplerate version of them (for the paca). would be perfect if we could slow down the capyrate to framerate...

ciao, johannes

[This message has been edited by johannes (edited 08 May 2014).]

IP: Logged

SSC
Administrator
posted 08 May 2014 11:23         Edit/Delete Message   Reply w/Quote
quote:
I didn't know the thing about the reversed bins,

Probably because the bins are NOT reversed.


quote:
add 2: By thinking about this again I think you can use the 2 inputs to do the overlapping windows

See the Prototypes "Inverse 512 FFT" and "Inverse 512 FFT Windowed".

Also, in Kyma Sound Library>Effects processing>SpectralProcessing-Live.kym see:

"pseudo bandpass with 1024 FFT (5)"

[This message has been edited by SSC (edited 08 May 2014).]

IP: Logged

johannes
Member
posted 08 May 2014 15:38         Edit/Delete Message   Reply w/Quote

4x-ola-fft_v2.kym

 
ok, i finally managed the 4 times ola using 2 fft sets. patch append…

for sounds with processing in the freq domain i wonder if it is good to use a second windowing module right behind the ifft resynthesis stage.


IP: Logged

pete
Member
posted 09 May 2014 07:18         Edit/Delete Message   Reply w/Quote
Hi Johannes

Normally with a half overlap FFT you can only window on the input or the output, as windowing in both places results in a sound with big holes. ie as if you put it through a ring modulator with an off set sine wave at 2 times frame rate. It would need odd window shapes like Square root of hann to fill in the gaps.

But

With a quarter overlapping FFT you can put ordinary windows on both the input and output as the extra two signals fill in the holes. I have a feeling you will get better results with windows at both ends but I've never got round to trying it.

Also SSC

Do the harmonics now come out in the same order for every half frame, as they used to alternate?

Am I delivering old news?


Pete

[This message has been edited by pete (edited 09 May 2014).]

IP: Logged

SSC
Administrator
posted 09 May 2014 09:55         Edit/Delete Message   Reply w/Quote
quote:
Also SSC
Do the harmonics now come out in the same order for every half frame

The harmonics come out in the same order for every half frame.


quote:
Am I delivering old news?

Possibly? Might have been that way pre-2003?

IP: Logged

gustl
Member
posted 09 May 2014 17:51         Edit/Delete Message   Reply w/Quote
Hi johannes,
I'm just curious: Why are you using the FFT module instead of all the ready-to-go spectral analysis possibilities?

IP: Logged

johannes
Member
posted 10 May 2014 08:05         Edit/Delete Message   Reply w/Quote

phaseRandMagsSmoothed.kym

 
hey gustl,

the reason i used the fft module is because i need to access the phases in order to accomplish phase randomization as a addition to magnitude smoothing.
i use phase randomization to create subtile modulations of the pitches. in combination with magnitude smoothing it leads to a kind of spatial diffusion. this helps to make the sound more blurry, which i like specially on dense layer and ambience sounds.

of course something similar is possible using the wire between but it will sound differently because we processing partials instead of bins. i tried a similar technic to phase randomization (via the wire in between) by adding an random amount to the right leg, also with a interesting but different result.

anyway, there might be other and more efficient ways of doing this in kyma. i definitely need to encapsulate the stereo version of the patch - its a big mess now. if you try to follow than look at the mono version of the patch.
on the other hand there are still things missing, for example i need to wrap the phases after adding random using modulo. i would also love to add some phase smoothing. i tried it and it doesn't seem to be that easy...

all suggestions, idea´s etc. are welcome.

pete, thanks for the windowing suggestion. that made it work without any crackles…

ciao, johannes


[This message has been edited by johannes (edited 10 May 2014).]

[This message has been edited by johannes (edited 10 May 2014).]

IP: Logged

Roland Kuit
Member
posted 15 February 2015 03:27         Edit/Delete Message   Reply w/Quote

4timesoverlapfft-ifftfun.kym

 
Hi Johannes,

I was just having fun with your sound.

Kind regards,
Roland

IP: Logged

gustl
Member
posted 01 June 2015 04:28         Edit/Delete Message   Reply w/Quote

ReplicatedFFT.kym

 
I've had a look at this again and decided to clean up the mess

Encapsulating doesn't make sense because then you can't access/manipulate the FFT data. You could encapsulate one module for the FFT and one for the inverse FFT but then you always have to make sure the settings match. So I just went for a Script here and merged the FFT / inverse FFT parts of the Sound.

Enjoy!

IP: Logged

johannes
Member
posted 14 June 2015 11:14         Edit/Delete Message   Reply w/Quote
Great. Will look into your sound the NeXT days . Did you Manage your fft-ifft timestretcher?

IP: Logged

gustl
Member
posted 14 June 2015 12:33         Edit/Delete Message   Reply w/Quote
Not yet.. Did you have a look at the Sound at the Q&A? Maybe you've got an idea?

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c