problem with multiple instances of a function

Feb 5, 2014 at 3:20pm

problem with multiple instances of a function

hi,

this genexpr code produces only sound on out1. out2 is silent, why?
only one instance of the svf-function works.
without the upsamp parameter it works.
(on osx max 1.6.1. 32bit)
——————————————

svf (input, freq, reso, upsamp=1) {
History d1(0), d2(0);
sr = SAMPLERATE*upsamp;
q1 = 1 / ( scale( clip( reso*reso*reso, 0, 1), 0, 1, 0.5, 100 ) );
f1 = 2*sin(pi*( min(freq, sr/4) )/sr);
L = d2 + f1*d1;
H = input – L – q1*d1;
B = f1 * H + d1;
N = H+L;
d1, d2 = B, L;
return L, H, B, N;
}

out1 = svf(noise(), 600, 0.3);
out2 = svf(noise(), 600, 0.3);

#280197
Feb 5, 2014 at 3:53pm

mhh,
without the default value for upsamp it works also fine …
… but i think it should be possible to have default values ????
micha

#280198
Feb 9, 2014 at 3:13am

hi michael.

it is confusing this. been trying to make it work. anyway, all i know is that no, you cannot have default values in gen. it is an always-on environment. notice in patching land, the right inlet of a plus (for example) will disappear if you give it a default value, i.e. it becomes a constant.

what your “upsamp=1″ does in your function header is turn the upsamp into a “param”. there is a section in the GenExpr documentation about this. the thing about params is that they operate at control rate (like in csound, for example), but do so automatically. so params do have ‘default values’. but, you then have to be careful about how params interact with full signal rate controls. this is probably the problem here. it can be a bit oblique sometimes.

hope my ramblings help a little.

#280463
Feb 9, 2014 at 9:19am

thanks STKR,

this helps, now i understand why it not works

micha

#280490

You must be logged in to reply to this topic.