Cryptic gen~ error message

Alexander Bean's icon

I was working on a FIR-based reverb algorithm in gen~ when the following error message came up:

gen_domain: dsp.gen: [string "gen2.Module"]:151: invalid replacement value (a nil)

The patch is supposed to generate a random string of 1 and -1, which are then used as coefficients in a FIR. This amounts to convolution with a particular kind of noise, but requires far fewer computations. The FIR requires 2205 multiplications (by either 1 or -1) and subsequent additions. I've attached the patch so you can see how I've structured this. Is there a more efficient way to do this than what I've come up with?

velvet noise reverb fir with gen.maxpat
Max Patch

error message

jvkr's icon

The gen code itself is missing from the patch. I think with 'Select All' and 'Copy Compressed' it should work fine.

Alexander Bean's icon

Thank you for pointing that out. This patch should work now.

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

jvkr's icon

Still not, I realize the gen~ object is referring to an external file. Without it, the object defaults to adding together two inputs. Easiest probably is zipping the gendsp file and attaching it here.

Alexander Bean's icon

Okay. This should work. I didn't notice that, as when I opened it, it naturally found the relevant file and everything worked fine.

velvet_algorithm copy.gendsp.zip
application/zip 534.87 KB

I'll also make a zip file with both the patch and the gendsp file:

gen_forum_patches.zip
application/zip 536.37 KB

Hopefully, one of these will work.

jvkr's icon

Yes, can open it now. Probably the error is the result of going over a limit of what gen~ can do. That limit appears to be at around 1700 delays. This generates then almost 14000 lines of gendsp code. After that it breaks. Maybe one of the developers has something more informative to say about this.

Anyway, your approach appears to be highly inefficient. Did you take a look at the gen~.buffir example? It must be possible to realize what you're thinking of using codebox and a for-loop.