1 declare name "karplus";
3 declare author "Grame";
5 declare copyright "(c)GRAME 2006";
7 //-----------------------------------------------
9 //-----------------------------------------------
16 upfront(x) = (x-x') > 0.0;
17 decay(n,x) = x - (x>0.0)/n;
18 release(n) = + ~ decay(n);
19 trigger(n) = upfront : release(n) : >(0.0);
21 size = hslider("excitation [unit:f]", 128, 2, 512, 1);
29 dur = hslider("duration [unit:f]", 128, 2, 512, 1);
30 att = hslider("attenuation", 0.1, 0, 1, 0.01);
31 average(x) = (x+x')/2;
33 resonator(d, a) = (+ : delay(4096, d-1.5)) ~ (average : *(1.0-a)) ;
35 process = noise * hslider("level", 0.5, 0, 1, 0.1)
36 : vgroup("excitator", *(button("play"): trigger(size)))
37 : vgroup("resonator", resonator(dur, att));