Yop,
@katjav said:
If you zeropad an IR, process in frequency domain and bring it back to time domain, you can easily discard samples, like the non-causal part of an IR. But in a real time patch, you really have to transform the zeropadded signal in an upsampled fft block. For example if the non-zero signal part is 1024 samples, transform it with a 2048 point fft. But this is no trivial thing to do in Pd. A signal upsampled by the [block~] object appears diluted with zero's, that's not what you want. A solution could be to reposition the non-zero samples using [tabread~] / [tabwrite~] with an index table designed for the purpose. And after ifft, dilute again before downsampling. Katja
I tried to make a 2x zeropadded version of my IR computation patch. Again, I'm not sure at all it actually works, so I hope Katjav or anyone else will comment it. I couldn't figure out how to remove zeroes and relocate audio stream samples within an upsampled realtime subpatch, so I tried a workaround. The input audio tables are chopped into frames and the frames copied into another table, alternating with zero frames to create a zeropadded audio table (in the main patch, no upsampling), and then play that table inside an upsampled subpatch. Then I go on with the usual computations. No need of "re-delution" here as I don't have to get back into the time domain to do these calculations.
It could be actually working, but I couldn't find a way to make consistency checks. The spectrums and IR are very close to the one calculated with the previous version of the patch, and it still sounds good. I wish I had found exactly all the values of the not-zeropadded magnitudes in the zeropadded results, saparated by new interpolated values, but It seems not to be the case. I'll be playing with text editors, gnuplot and Ocatve to enhance my graph capabilities (it's not trivial to export data from pd to make a plot, from my point of view). There's probably a wrong "normalizing factor" in fft mag and phase computation in the upsampled subpatch, as I maintained the old 32768 value. That's what I can say so far.
The frame length is 32768 and the zeropadding leads to 65536 samples fft size, that is pretty long (not from the computational workload point of view, as this is done not in real time). It could be more interesting to maintain a maximum fft size of 65536 but with frame length 2, 4 or 8 times smaller, combined with the corresponding zeropadding process. I'd like to investigate this as a next step, maybe with an adaptative patch (it's boring to make several parallel versions of the same patch).
But I won't do that before someone here has given me opinions on my zeropadding workaround, sorry I'm a forum's slave
Attached file is the IR computation patch, to be used with the previous material.
Thank you,
Nau
http://www.pdpatchrepo.info/hurleur/ir_construction_16_zeropadded.pd