convolution in gen again!

woyteg's icon

Hello!
Last night i have been trying to implement convolution inside gen~. very long..
Ok the first issue: i've read here on the forums that peek/poke are not working inside loops. Is this still true? It seems to kind of work.
As there has been a post on this already in which many people said "why? You don't need that" I want to say, i want it. I want to do it myself in order to understand it on a deeper level and maybe also to experiment with changes in the structure, once it's finished.

If i give my little convolver a unit sample it kind of works, but i get some zippering noise sometimes. If i give it an ir with multiple delayed unit samples, it's zippering all the time. It also seems to be related to the vector size, but i don't know.

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

i know, the patch is a chaos, but inside gen it's quite tidy, and that's where i would need help.
In general, am i doing something completely wrong here? Did i maybe misunderstand something about convolution in general?
If it seems comletely absurd what i'm trying to do in there i can also elabourate on my understanding of the whole thing and the structure i was trying to build there, so you could tell me what i am misunderstanding.
Thank you very much!

Graham Wakefield's icon

Hi there --

I played around with rebuilding buffir~ in gen~ a month or two ago. I was filling around with peek / poke pairs like that, then it dawned on me that the input indexing is the same as what a delay line needs, so it turns out to be a lot simpler just by using a delay read inside a for loop. The patcher I've been working on is below. It sounds a bit rough sometimes though, I'm not 100% sure why.

The usual caveats apply: a time-domain convolution (which is what buffir~ does) only makes sense for convolution sizes similar to or less than the current block size, beyond that a partitioned convolution will perform significantly better. Anything sexy like convolution reverb is not going to work well without partitioning. But the time-domain only method (buffir~) works ok for convolving with finite impulse responses around or less than 100 samples.

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

But exposing time-domain convolution in gen~ does open up some interesting possibilites for experimentation...

4879.gen.buffir.maxpat
Max Patch
woyteg's icon

Hello Graham!
Thank you very much!! I learned a lot there!
Cheers!

SY's icon

Hi, (even though it has been a while for this thread) I also tried to make the convolution using GEN~. This does exactly same as buffir~ yet a bit slow. As of now, about 5000 tabs (about 100 ms when sampling rate is 48000Hz) is max before it reaches to the max CPU.

It is a good exercise to learn how the convolution is working.

Gen_Buffer_Writing_example2.maxpat
Max Patch
Convolution in GEN~

AudioMatt's icon

I tried to do an FFT in gen and it just doesn't let you for some reason. I couldn't find a version that didn't work with recursion.

John Clements's icon

@Graham Wakefield: After looking through your patch (thank you so much for sharing), I take it that the statement in the gen documentation is incorrect - "Note that the delay operator is not currently supported in GenExpr." ..

since I see it on line 4 of your codebox .. . I generally read all the update docs, feature adds, etc, but did I miss this goodness>? and if so, to whom do we communicate this joyous documentation update note?

Thanks for your badass work!

JC