Supporting rfft~ and rifft~ #99
Replies: 4 comments 14 replies
-
Thank you a lot for the input @jameysharp ! Very cool to hear that this has some possibility to be implemented, however even though I took over maintenance of the project I know very little about the internal workings of Heavy, or about programming DSP code in general. So any help with this is certainly appreciated. |
Beta Was this translation helpful? Give feedback.
-
I took a bit of a dive into the internals and It will take some piecing together from various other objects to better understand how to implement |
Beta Was this translation helpful? Give feedback.
-
Potential implementation from Emilie Gillet that at least works on embedded/STM32 target (MIT): https://github.com/electro-smith/DaisyExamples/blob/master/field/Nimbus/shy_fft.h |
Beta Was this translation helpful? Give feedback.
-
Some more docs on rfft~ usage in pd: http://www.pd-tutorial.com/english/ch03s08.html |
Beta Was this translation helpful? Give feedback.
-
I heard from https://hackers.town/@JoshuaACNewman that there are open questions about how to implement FFT support in hvcc. I don't know anything about PD or Heavy, but I do know a thing or two about FFTs, dataflow languages, and compilers, and wanted to offer some help. I don't want to hang out in a Discord though so I thought I'd see if folks would be interested in having a conversation here.
I'm having trouble making sense of Heavy's
ir2c
generator, but if I'm reading it correctly, it looks like the main difficulty is that every signal block takes one sample at a time, or at most, one SIMD vector of samples at a time. That would be troublesome since an FFT necessarily has to wait for N samples to arrive before it can produce any output, where N is the length of the FFT.I see from the example of
SignalConvolution
that a signal block can keep a ring-buffer of past inputs in local state. I think that pattern should work for FFTs as well: every time an input sample arrives, save it in the ring buffer, and when the ring buffer wraps, compute the FFT or inverse FFT of the whole buffer.The other difficulty is it looks like signal blocks are synchronous: they must produce an output sample for every input sample. A length-N FFT introduces N samples worth of latency, so there's no meaningful value to output for the first N samples. That's okay as long as PD's semantics allow emitting N samples of zeroes at the beginning. Does it?
If there aren't any other challenges I've missed, then I think this is… relatively straightforward, and I'd be happy to chat further about how to make it work.
Beta Was this translation helpful? Give feedback.
All reactions