Add /usr/local/lib/faustine and /usr/lib/faustine to preprocessor import path.
[Faustine.git] / interpretor / preprocessor / faust-0.9.47mr3 / examples / envelop.dsp
1 declare name "envelop";
2 declare version "1.0";
3 declare author "Grame";
4 declare license "BSD";
5 declare copyright "(c)GRAME 2006";
6
7 import("music.lib");
8
9 //-------------------------------------------------
10 // ADSR Envelop Generator
11 // The 'state' of the envelop generator is
12 // defined by a phase signal p2 allowing to
13 // distinguish the attack and the decay-sustain
14 // phases, and the envelop signal y itself.
15 //-------------------------------------------------
16
17 envelop(a,d,s,r,t) = adsr ~ (_,_) : (!,_) // The 2 'state' signal are feedback
18 with {
19 adsr (p2,y) = (t>0) & (p2|(y>=1)), // p2 = decay-sustain phase
20 y + p1*a - (p2&(y>s))*d*y - p3*r*y // y = envelop signal
21 with {
22 p1 = (p2==0) & (t>0) & (y<1); // p1 = attack phase
23 p3 = (t<=0) & (y>0); // p3 = release phase
24 };
25 };
26
27
28 attack = 1.0/(SR*nentry("[1:]attack [unit:ms][style:knob]", 20, 1, 1000, 1)/1000);
29 decay = nentry("[2:]decay[style:knob]", 2, 1, 100, 0.1)/100000;
30 sustain = nentry("[3:]sustain [unit:pc][style:knob]", 10, 1, 100, 0.1)/100;
31 release = nentry("[4:]release[style:knob]", 10, 1, 100, 0.1)/100000;
32
33
34 process = button("play"): hgroup("", envelop(attack, decay, sustain, release) : *(noise));
35