/usr/share/faust/synth.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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | //################################### synth.lib ##########################################
// This library contains a collection of envelope generators.
//
// It should be used using the `sy` environment:
//
// ```
// sy = library("synth.lib");
// process = sy.functionCall;
// ```
//
// Another option is to import `stdfaust.lib` which already contains the `sy`
// environment:
//
// ```
// import("stdfaust.lib");
// process = sy.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 Synthesizer Library";
declare version "0.0";
ma = library("math.lib");
ba = library("basic.lib");
en = library("envelope.lib");
fi = library("filter.lib");
os = library("miscoscillator.lib");
no = library("noise.lib");
//-----------------------------------`popFilterPerc`--------------------------------------
// A simple percussion instrument based on a "popped" resonant bandpass filter.
// `popFilterPerc` is a standard Faust function.
//
// #### Usage
//
// ```
// popFilterDrum(freq,q,gate) : _;
// ```
//
// Where:
//
// * `freq`: the resonance frequency of the instrument
// * `q`: the q of the res filter (typically, 5 is a good value)
// * `gate`: the trigger signal (0 or 1)
//----------------------------------------------------------------------------------------
// TODO: author RM
popFilterDrum(freq,q,gate) = en.ar(0.001,0.001,gate)*no.noise : fi.resonbp(freq,q,1);
//---------------------------------------`dubDub`-----------------------------------------
// A simple synth based on a sawtooth wave filtered by a resonant lowpass.
// `dubDub` is a standard Faust function.
//
// #### Usage
//
// ```
// dubDub(freq,ctFreq,q,gate) : _;
// ```
//
// Where:
//
// * `freq`: frequency of the sawtooth
// * `ctFreq`: cutoff frequency of the filter
// * `q`: Q of the filter
// * `gate`: the trigger signal (0 or 1)
//----------------------------------------------------------------------------------------
// TODO: author RM
dubDub(freq,ctFreq,q,gate) = os.sawtooth(freq)*gainEnvelope : fi.resonlp(ctFreq,q,1)
with{
maxGain = 0.5;
gainEnvelope = en.smoothEnvelope(0.01,gate)*maxGain;
};
//-----------------------------------`sawTrombone`----------------------------------------
// A simple trombone based on a lowpassed sawtooth wave.
// `sawTrombone` is a standard Faust function.
//
// #### Usage
//
// ```
// sawTrombone(att,freq,gain,gate) : _
// ```
//
// Where:
//
// * `att`: exponential attack duration in s (typically 0.01)
// * `freq`: the frequency
// * `gain`: the gain (0-1)
// * `gate`: the gate (0 or 1)
//----------------------------------------------------------------------------------------
// TODO: author RM
sawTrombone(freq,gain,gate) = os.sawtooth(freq)*gainEnvelope : fi.lowpass(3,cutoff)
with{
// controls both the gain of the instrument and the lowpass frequency
gainEnvelope = en.smoothEnvelope(0.01,gate)*gain;
cutoff = gainEnvelope*5000+50;
};
//-----------------------------------`combString`-----------------------------------------
// Simplest string physical model ever based on a comb filter.
// `combString` is a standard Faust function.
//
// #### Usage
//
// ```
// combString(freq,res,gate) : _;
// ```
//
// Where:
//
// * `freq`: the frequency of the string
// * `res`: string T60 (resonance time) in second
// * `gate`: trigger signal (0 or 1)
//----------------------------------------------------------------------------------------
// TODO: author RM
combString(freq,res,gate) = excitation : fi.fb_fcomb(maxDel,N,b0,aN)
with{
maxDel = 1024;
N = ma.SR/freq;
b0 = 1;
aN = ba.tau2pole(res*0.001)*-1;
excitation = no.noise*en.ar(0.001,0.001,gate);
};
//-----------------------------------`additiveDrum`---------------------------------------
// A simple drum using additive synthesis.
// `additiveDrum` is a standard Faust function.
//
// #### Usage
//
// ```
// additiveDrum(freq,freqRatio,gain,harmDec,att,rel,gate) : _
// ```
//
// Where:
//
// * `freq`: the resonance frequency of the drum
// * `freqRatio`: a list of ratio to choose the frequency of the mode in
// function of `freq` e.g.(1 1.2 1.5 ...). The first element should always
// be one (fundamental).
// * `gain`: the gain of each mode as a list (1 0.9 0.8 ...). The first element
// is the gain of the fundamental.
// * `harmDec`: harmonic decay ratio (0-1): configure the speed at which
// higher modes decay compare to lower modes.
// * `att`: attack duration in second
// * `rel`: release duration in second
// * `gate`: trigger signal (0 or 1)
//----------------------------------------------------------------------------------------
// TODO: author RM
additiveDrum(freq,freqRatio,gain,modeDec,att,rel,gate) = par(i,N,os.osc(modeFreq(i))*gainEnvelope(i)) :> _
with{
N = ba.count(freqRatio);
modeFreq(i) = freq*ba.take(i+1,freqRatio);
modeGain(i) = ba.take(i+1,gain);
gainEnvelope(i) = modeGain(i)*en.ar(att,rel*(1-(modeDec*(i/N))),gate);
};
//-----------------------------------`fm`---------------------------------------
// An FM synthesizer with an arbitrary number of modulators connected as a sequence.
// `fm` is a standard Faust function.
//
// #### Usage
//
// ```
// freqs = (300,400,...);
// indices = (20,...);
// fm(freqs,indices) : _
// ```
//
// Where:
//
// * `freqs`: a list of frequencies where the first one is the frequency of the carrier
// and the others, the frequency of the modulator(s)
// * `indices`: the indices of modulation (Nfreqs-1)
//----------------------------------------------------------------------------------------
// TODO: author RM
fm(freqs,indices) = seq(i,N,fmBlock(i))
with{
N = ba.count(freqs);
freq(i) = ba.take(N-i,freqs);
gain(i) = ba.take(N-i,indices);
fmBlock(0) = freq(0) : os.osc;
fmBlock(i) = *(gain(i))*freq(i) : os.osc;
};
|