FFT maths
hi
well it's more a concept/math question since im trying to apply this on a use module.
what i am trying to achieve is kind of parametric visual EQ but using a bezier curve to control the frequency response, manipulating directly fft and not using pole filters.
ir's abit complex for me but i think it should be something like:
Array of Samples (-1...1)
-----> extract FFT forward ------> convert Real and Imaginary to Magnitudes and Phases arrays -----> PROCESS magnitudes with my curve ----> convert back to R & I
-----> Inverse FFT -----> get the samples out.
1rst Q: is this scheme right? semms ok when patching it, now i have to code it , it's here prb are coming.
2) is that ok method to fill a Real array with samples values, fill Imaginary with 0 and do FFT forward as the first process to extract FFT from a set of samples? or is it done differently?
3) any ideas of better math code to revert from magnitudes and phases to Real and Imaginaries?
4) Finally, how to convert back to sample audio data, just use Reals?
5) globally how to deal with size of audio 'sampled' buffer Vs size of FFT
any enlighting on those points would be very cool
well it's more a concept/math question since im trying to apply this on a use module.
what i am trying to achieve is kind of parametric visual EQ but using a bezier curve to control the frequency response, manipulating directly fft and not using pole filters.
ir's abit complex for me but i think it should be something like:
Array of Samples (-1...1)
-----> extract FFT forward ------> convert Real and Imaginary to Magnitudes and Phases arrays -----> PROCESS magnitudes with my curve ----> convert back to R & I
-----> Inverse FFT -----> get the samples out.
1rst Q: is this scheme right? semms ok when patching it, now i have to code it , it's here prb are coming.
2) is that ok method to fill a Real array with samples values, fill Imaginary with 0 and do FFT forward as the first process to extract FFT from a set of samples? or is it done differently?
3) any ideas of better math code to revert from magnitudes and phases to Real and Imaginaries?
4) Finally, how to convert back to sample audio data, just use Reals?
5) globally how to deal with size of audio 'sampled' buffer Vs size of FFT
any enlighting on those points would be very cool
I'm learning this myself & am very interested in the detailed answers. My understanding is:
1) Yes, that looks correct in theory. Only question is your 'array of samples' - which should be your audio stream in at the beginning & audio stream out at the end.
2) No, I don't believe so. If you fill imaginary with 0, you will lose phase information. You should feed both real & imaginary into carttopol & poltocart.
3) You need to use the Polar to Cartesian & Cartesian to Polar calls to do this math. You can Google these, they're very straightforward if you want to write your own. But HH2 has these modules.
4) The Inverse FFT does that, it 'reconstructs' your sound. The output of the inverse FFT function is your audio.
5) Excellent question...
Hope this helps... I'm still learning this. Experts, please chime in.
1) Yes, that looks correct in theory. Only question is your 'array of samples' - which should be your audio stream in at the beginning & audio stream out at the end.
2) No, I don't believe so. If you fill imaginary with 0, you will lose phase information. You should feed both real & imaginary into carttopol & poltocart.
3) You need to use the Polar to Cartesian & Cartesian to Polar calls to do this math. You can Google these, they're very straightforward if you want to write your own. But HH2 has these modules.
4) The Inverse FFT does that, it 'reconstructs' your sound. The output of the inverse FFT function is your audio.
5) Excellent question...
Hope this helps... I'm still learning this. Experts, please chime in.
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp
yes i could successfully test with modules, that seems to work nice.
but on the code part i could code the polar to catesian and reverse, and i found a FFT forward/inverse code, however it takes Real and Imaginary arrays as input, and return them once processed. so it's the first and final conversion trick that i miss: how to get Reals and imaginary out of audio samples (-1...1) datas array, and on the other way, how to convert back to sample once process is done. mm
in fact i just need to code this: but fail on the first and last module i think:

but on the code part i could code the polar to catesian and reverse, and i found a FFT forward/inverse code, however it takes Real and Imaginary arrays as input, and return them once processed. so it's the first and final conversion trick that i miss: how to get Reals and imaginary out of audio samples (-1...1) datas array, and on the other way, how to convert back to sample once process is done. mm
in fact i just need to code this: but fail on the first and last module i think:

The new 'Phase Vocoder' modules appear to replace the FFT & carttopol & poltocar & IFFT. ???
PhVocForw & PhVocInv...
Haven't tried them yet...
PhVocForw & PhVocInv...
Haven't tried them yet...
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp
I'm really missing something... Getting R & I out of audio samples is exactly what the FFT does... Why not use the FFT? (Or its new PhVocForw?)23fx23 wrote:so it's the first and final conversion trick that i miss: how to get Reals and imaginary out of audio samples (-1...1) datas array, and on the other way, how to convert back to sample once process is done. mm
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp
yes that would be easy, but im after a all in one code withouth wiring , because in fact i plan do do a single module with my bezier template i posted in addon as a 'starting point',
it's kind of bezier synthetiser with all elements controlled via bezier (oscillators, envellopes, and filters), so ideally id like it to be hard coded
it's kind of bezier synthetiser with all elements controlled via bezier (oscillators, envellopes, and filters), so ideally id like it to be hard coded
i already got the bezier oscillators working cool
, implemented filters where some other bezier curves control/act as envellopes/lfo, working cool too, id just said myself why not go deeper with global graphical eq &/or custom filter responses bezier controlled as well^^
Oh - you want to do this all in the SDK? I haven't used the SDK, I'm not sure how you get the internal audio blocks into the SDK.23fx23 wrote:yes that would be easy, but im after a all in one code withouth wiring
My understanding is that your FFT formula should take the block of samples input & generate R & I output.
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp
yup with the sdk. i already got it globally coded with the audio manipulation in/out ok when im generating wavforms and filter them with pole filters it's working as espected, but i think you are right and i need a different FFT function taking samples on input at first,i keep on investigating...
okkk just to let ya know in case later interested shawnb, after few nights of really hard braining fights^^ got it atlast starting to work nicely
slowly start to catch.
mind ya you won't have those problematics with patchs as the modules are well coded, but still can be interesting maybe..
so basically i generated oscilators like saw/sin or noise as test material, then after failing and failing with random FFT codes, i let dwn and decided to give a shot at performing a DFT instead (discrete fourier transform) So for first 'pass', feeding the samples as 'Reals' and set Imaginary to 0 was indeed the way to go, then the DFT algo returns the reals and imaginary filled according to samples material. then here i used a curved array as EQ to control directly the weight of both R and I, in fact no need for Polar/back to Cartesian convesions exept visual feedback purposes, just multiply by a factor works..then Invese DFT recomposed the filered wave. hurra^^ worked nice, but the sad thing is DFT is veryyy heavvvvy process on large chunks of datas..serious CPU hits on low freqs. so I struggled for a while again with few FFT codes and finally found a way to replicate, and it's much faster and workable this way. same process --->reset all Imag and Reals to 0,--->feed audio to Reals--->performs FFT--->process the weights to filter/control coefficients gains--->do the invese FFT. get filtered signal.where Reals are samples and Imag are back to 0. i made my first curved EQ im happy lol
here i did a trick as i don't work 'real time' in process, i kinda make it 'offline' on the datas before they are played so didn't even't made a windowing function, anyway the modules will do the job automatically, but found interesting trying to catch the concepts behind.
mind ya you won't have those problematics with patchs as the modules are well coded, but still can be interesting maybe..
so basically i generated oscilators like saw/sin or noise as test material, then after failing and failing with random FFT codes, i let dwn and decided to give a shot at performing a DFT instead (discrete fourier transform) So for first 'pass', feeding the samples as 'Reals' and set Imaginary to 0 was indeed the way to go, then the DFT algo returns the reals and imaginary filled according to samples material. then here i used a curved array as EQ to control directly the weight of both R and I, in fact no need for Polar/back to Cartesian convesions exept visual feedback purposes, just multiply by a factor works..then Invese DFT recomposed the filered wave. hurra^^ worked nice, but the sad thing is DFT is veryyy heavvvvy process on large chunks of datas..serious CPU hits on low freqs. so I struggled for a while again with few FFT codes and finally found a way to replicate, and it's much faster and workable this way. same process --->reset all Imag and Reals to 0,--->feed audio to Reals--->performs FFT--->process the weights to filter/control coefficients gains--->do the invese FFT. get filtered signal.where Reals are samples and Imag are back to 0. i made my first curved EQ im happy lol
here i did a trick as i don't work 'real time' in process, i kinda make it 'offline' on the datas before they are played so didn't even't made a windowing function, anyway the modules will do the job automatically, but found interesting trying to catch the concepts behind.
Fun article explaining the differences, including code samples. How to get 100x improvement pretty quickly...
Thought you'd like this, since you like to roll your own:
https://jakevdp.github.io/blog/2013/08/ ... g-the-fft/
Shawn
Thought you'd like this, since you like to roll your own:
https://jakevdp.github.io/blog/2013/08/ ... g-the-fft/
Shawn
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp
cool thanks gonna check those !. yeah the first i had were not performing very well. last one seems modern, well written& ok but worth checking/testing other methods
found this calculator interesting also:
http://sooeet.com/math/fourier-transform.php
here is a wip of my tests for an eq/filters module

first quick test low fftrez:
https://drive.google.com/file/d/0B0VUyz ... sp=sharing
found this calculator interesting also:
http://sooeet.com/math/fourier-transform.php
here is a wip of my tests for an eq/filters module

first quick test low fftrez:
https://drive.google.com/file/d/0B0VUyz ... sp=sharing
Who is online
Users browsing this forum: No registered users and 83 guests
