Forums > Gen

Delay inside GenExpr operators

October 18, 2012 | 1:42 pm

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


October 19, 2012 | 5:58 am

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


October 19, 2012 | 11:32 am

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


June 18, 2014 | 2:55 am

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


July 3, 2014 | 12:30 pm

hi woyteg.

it should work fine.

here is an example, made using max 6.1.7

– Pasted Max Patch, click to expand. –

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~.


July 3, 2014 | 12:39 pm

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


Viewing 6 posts - 1 through 6 (of 6 total)