Add simple licence-plate example.
[Faustine.git] / interpretor / preprocessor / faust-0.9.47mr3 / examples / karplus.dsp
1 declare name "karplus";
2 declare version "1.0";
3 declare author "Grame";
4 declare license "BSD";
5 declare copyright "(c)GRAME 2006";
6
7 //-----------------------------------------------
8 // karplus-strong
9 //-----------------------------------------------
10
11 import("music.lib");
12
13 // Excitator
14 //--------
15
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);
20
21 size = hslider("excitation [unit:f]", 128, 2, 512, 1);
22
23
24
25
26 // resonator
27 //-----------------
28
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;
32
33 resonator(d, a) = (+ : delay(4096, d-1.5)) ~ (average : *(1.0-a)) ;
34
35 process = noise * hslider("level", 0.5, 0, 1, 0.1)
36 : vgroup("excitator", *(button("play"): trigger(size)))
37 : vgroup("resonator", resonator(dur, att));