Delay inside GenExpr operators

Bacchus's icon

Hi All,

I've been trying to get the delay and history operators to work inside a custom GenExpr operator/function definition within a codebox, but I'm not having much luck. The same code works fine as long as I don't try to package it as a function. Has anybody else managed to get something similar to work? I'm wondering whether this a limitation of the language at the moment, or whether I'm using the wrong syntax.

The definition looks like this:

AP(in_AP,delay){

Delay delay_1(8, interp="linear");
tap1_2 = delay_1.read(delay, interp="linear");
float_3 = float(0.618034);
mul_4 = (tap1_2 * float_3);
add_5 = (in_AP + mul_4);
mul_6 = (add_5 * float_3);
add_7 = (mul_6 + tap1_2);
out_AP = add_7;
delay_1.write(add_5);
return out_AP;
}

-J

Graham Wakefield's icon

Hi there,

Yes, we have become aware that there is a problem with object declarations within GenExpr functions for gen~ in 6.0.7. The issue is ticketed and a fix will be in the next update. We're very sorry for the inconvenience.

Graham

Bacchus's icon

Thanks for the reply Graham! Good to know it'll be possible in the future.

woyteg's icon

Is this still a problem? It seems so or I'm doing something wrong..

stkr's icon

hi woyteg.

it should work fine.

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

here is an example, made using max 6.1.7

just be careful using delays in functions. unlike other functions, gen has to create memory for every single instance of the used delays in the used functions at runtime - you can quickly end up with huge memory resources - you cannot dynamically manage the memory allocation in gen~.

woyteg's icon

Hi! Thanks for the reply!
That means I have done something wrong then. I'll re-check. Thank you!