/usr/share/faust/envelope.lib is in faust-common 0.9.95~repack1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | //################################ envelope.lib ##########################################
// This library contains a collection of envelope generators.
//
// It should be used using the `en` environment:
//
// ```
// en = library("envelope.lib");
// process = en.functionCall;
// ```
//
// Another option is to import `stdfaust.lib` which already contains the `en`
// environment:
//
// ```
// import("stdfaust.lib");
// process = en.functionCall;
// ```
//########################################################################################
/************************************************************************
************************************************************************
FAUST library file
Copyright (C) 2003-2016 GRAME, Centre National de Creation Musicale
----------------------------------------------------------------------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
EXCEPTION TO THE LGPL LICENSE : As a special exception, you may create a
larger FAUST program which directly or indirectly imports this library
file and still distribute the compiled code generated by the FAUST
compiler, or a modified version of this compiled code, under your own
copyright and license. This EXCEPTION TO THE LGPL LICENSE explicitly
grants you the right to freely choose the license for the resulting
compiled code. In particular the resulting compiled code has no obligation
to be LGPL or GPL. For example you are free to choose a commercial or
closed source license or any other license if you decide so.
************************************************************************
************************************************************************/
declare name "Faust Envelope Library";
declare version "0.0";
declare author "GRAME";
declare copyright "GRAME";
declare license "LGPL with exception";
ma = library("math.lib");
ba = library("basic.lib");
si = library("signal.lib");
//=============================Functions Reference========================================
//========================================================================================
//------------------------`smoothEnvelope`------------------------
// An envelope with an exponential attack and release.
// `smoothEnvelope` is a standard Faust function.
//
// #### Usage
//
// ```
// smoothEnvelope(ar,t) : _
// ```
//
// * `ar`: attack and release duration (s)
// * `t`: trigger signal (0-1)
//----------------------------------------------------------------
smoothEnvelope(ar,t) = t : si.smooth(ba.tau2pole(ar));
//-----------------------`ar`--------------------------
// AR (Attack, Release) envelope generator (useful to create percussion envelopes).
// `ar` is a standard Faust function.
//
// #### Usage
//
// ```
// ar(a,r,t) : _
// ```
//
// Where:
//
// * `a`: attack (sec)
// * `r`: release (sec)
// * `t`: trigger signal (0 or 1)
//-----------------------------------------------------
ar(a,r,t) = ba.countup(attTime+relTime,on) : ba.bpf.start(0,0) :
ba.bpf.point(attTime,1) : ba.bpf.end(attTime+relTime,0)
with{
on = (t-t')==1;
attTime = ma.SR*a;
relTime = ma.SR*r;
};
//------------------------`asr`----------------------
// ASR (Attack, Sustain, Release) envelope generator.
// `asr` is a standard Faust function.
//
// #### Usage
//
// ```
// asr(a,s,r,t) : _
// ```
//
// Where:
//
// * `a`, `s`, `r`: attack (sec), sustain (percentage of t), release (sec)
// * `t`: trigger signal ( >0 for attack, then release is when t back to 0)
//-----------------------------------------------------
// TODO: author RM
asr(a,s,r,t) = on*(as) : ba.sAndH(on) : rel
with{
on = t>0;
off = t==0;
attTime = ma.SR*a;
relTime = ma.SR*r;
sustainGain = t*s*0.01;
as = ba.countup(attTime,off) : ba.bpf.start(0,0) :
ba.bpf.end(attTime,sustainGain);
rel = _,ba.countup(relTime,on) : ba.bpf.start(0) : ba.bpf.end(relTime,0);
};
//------------------------`adsr`----------------------
// ADSR (Attack, Decay, Sustain, Release) envelope generator.
// `adsr` is a standard Faust function.
//
// #### Usage
//
// ```
// adsr(a,d,s,r,t) : _
// ```
//
// Where:
//
// * `a`, `d`, `s`, `r`: attack (sec), decay (sec), sustain (percentage of t), release (sec)
// * `t`: trigger signal ( >0 for attack, then release is when t back to 0)
//-----------------------------------------------------
// TODO: author RM
adsr(a,d,s,r,t) = on*(ads) : ba.sAndH(on) : rel
with{
on = t>0;
off = t==0;
attTime = ma.SR*a;
decTime = ma.SR*d;
relTime = ma.SR*r;
sustainGain = t*s*0.01;
ads = ba.countup(attTime+decTime,off) : ba.bpf.start(0,0) :
ba.bpf.point(attTime,1) : ba.bpf.end(attTime+decTime,sustainGain);
rel = _,ba.countup(relTime,on) : ba.bpf.start(0) : ba.bpf.end(relTime,0);
};
// Old version of ADSR (originally from music.lib)...
/*
adsr(a,d,s,r,t) = env ~ (_,_) : (!,_) // the 2 'state' signals are fed back
with {
env (p2,y) =
(t>0) & (p2|(y>=1)), // p2 = decay-sustain phase
(y + p1*u - (p2&(y>s))*v*y - p3*w*y) // y = envelop signal
*((p3==0)|(y>=eps)) // cut off tails to prevent denormals
with {
p1 = (p2==0) & (t>0) & (y<1); // p1 = attack phase
p3 = (t<=0) & (y>0); // p3 = release phase
// #samples in attack, decay, release, must be >0
na = ma.SR*a+(a==0.0); nd = ma.SR*d+(d==0.0); nr = ma.SR*r+(r==0.0);
// correct zero sustain level
z = s+(s==0.0)*ba.db2linear(-60);
// attack, decay and (-60dB) release rates
u = 1/na; v = 1-pow(z, 1/nd); w = 1-1/pow(z*ba.db2linear(60), 1/nr);
// values below this threshold are considered zero in the release phase
eps = ba.db2linear(-120);
};
};
*/
////////////////////////////////////////////////////////
// UNDOCUMENTED/DISMISSED ELEMENTS
////////////////////////////////////////////////////////
|