Forums > Gen

problem with multiple instances of a function

February 5, 2014 | 3:20 pm

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);


February 5, 2014 | 3:53 pm

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


February 9, 2014 | 3:13 am

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.


February 9, 2014 | 9:19 am

thanks STKR,

this helps, now i understand why it not works

micha


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