forked from s-e-a-m/faust-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nono.lib
249 lines (233 loc) · 9.94 KB
/
nono.lib
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//################################################################# nono.lib ###
//
// A library for the exploration of the Luigi Nono's Live Electronics Instruments
//
// * HARMONIZER
// * DELAY BANKS
// * REVERBERATORS
// * HALAPHON
// * PHASER
//
//##############################################################################
/*******************************************************************************
Except where noted otherwise, Copyright (C) 2019-2020 by SEAM
GRAME LICENSE
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 "Nono's Elements Faust Library";
declare version "0.1";
declare author "Giuseppe Silvi";
declare license "CC4";
//========================================================= LIVE ELECTRONICS ===
//==============================================================================
//------------------------------------------------------------------------------
// HARMONIZER
//------------------------------------------------------------------------------
// Converts an LR stereo image into Mid mono signal describes the frontal
// directional component of the sound image.
//
// #### Reference
//
// #### Usage
//
// ```
// _,_ : mid : _
// ```
//
// Where the two inputs are respectively:
// L,R
//
// Where the output is the Mid component
//
//------------------------------------------------------------------------------
harmonizer = ef.transpose(400,300,(vslider("HARMONIZER (cents) [style:knob]", 0, -2600, +100, 1) : *(0.01): si.smoo));
//------------------------------------------------------------------------------
// 8 DELAY BANK ODD-FBACK
//------------------------------------------------------------------------------
// Converts an LR stereo image into Mid mono signal describes the frontal
// directional component of the sound image.
//
// #### Reference
//
// #### Usage
//
// ```
// _,_ : mid : _
// ```
//
// Where the two inputs are respectively:
// L,R
//
// Where the output is the Mid component
//
//------------------------------------------------------------------------------
delbank = _ <: (+<: de.delay(D1,D1), de.delay(D2,D2))~*(fbgain1),
(+<: de.delay(D3,D3), de.delay(D4,D4))~*(fbgain2),
(+<: de.delay(D5,D5), de.delay(D6,D6))~*(fbgain3),
(+<: de.delay(D7,D7), de.delay(D8,D8))~*(fbgain4);
//------------------------------------------------------------------------------
// REVERB 4 SEC
//------------------------------------------------------------------------------
// Converts an LR stereo image into Mid mono signal describes the frontal
// directional component of the sound image.
//
// #### Reference
//
// #### Usage
//
// ```
// _,_ : mid : _
// ```
//
// Where the two inputs are respectively:
// L,R
//
// Where the output is the Mid component
//
//------------------------------------------------------------------------------
rev_quattro(N,NB,BBSO) = _ <: re.fdnrev0(MAXDELAY,delays,BBSO,freqs,durs,loopgainmax,nonl) :> *(gain), *(gain)
with{
MAXDELAY = 8192; // sync w delays and prime_power_delays above
defdurs = (3.00, 4.0, 6.5, 4.5, 2.0); // NB default durations (sec)
deffreqs = (350, 1250, 3500, 8000); // NB-1 default crossover frequencies (Hz)
fdn_group(x) = vgroup("FDN REV 4", x);
freq_group(x) = fdn_group(hgroup("[1] Crossover Frequencies", x));
t60_group(x) = fdn_group(hgroup("[2] Band Decay Times (T60)", x));
path_group(x) = fdn_group(vgroup("[3] Room Dimensions", x));
revin_group(x) = fdn_group(hgroup("[4] Input Controls", x));
nonl_group(x) = revin_group(vgroup("[4] Nonlinearity",x));
quench_group(x) = revin_group(vgroup("[3] Reverb State",x));
nonl = nonl_group(hslider("[style:knob] [tooltip: nonlinear mode coupling]", 0, -0.999, 0.999, 0.001));
loopgainmax = 1.0-0.5*quench_group(button("[1] Clear [tooltip: Hold down to clear the reverberator]"));
pathmin = path_group(hslider("[1] min acoustic ray length [unit:m] [scale:log]", 12.0, 0.1, 63, 0.1));
pathmax = path_group(hslider("[2] max acoustic ray length [unit:m] [scale:log]", 63.0, 0.1, 63, 0.1));
durvals(i) = t60_group(nentry("[%i] %i [unit:s]",ba.take(i+1,defdurs), 0.1, 100, 0.1));
durs = par(i,NB,durvals(NB-1-i));
freqvals(i) = freq_group(nentry("[%i] Band %i upper edge in Hz [unit:Hz]",ba.take(i+1,deffreqs), 100, 10000, 1));
freqs = par(i,NB-1,freqvals(i));
delays = de.prime_power_delays(N,pathmin,pathmax);
gain = hslider("[3] Output Level (dB) [unit:dB][tooltip: Output scale factor]", -40, -70, 20, 0.1) : ba.db2linear;
};
//------------------------------------------------------------------------------
// REVERB 80 SEC
//------------------------------------------------------------------------------
// Converts an LR stereo image into Mid mono signal describes the frontal
// directional component of the sound image.
//
// #### Reference
//
// #### Usage
//
// ```
// _,_ : mid : _
// ```
//
// Where the two inputs are respectively:
// L,R
//
// Where the output is the Mid component
//
//------------------------------------------------------------------------------
rev_ottanta(N,NB,BBSO) = _ <: re.fdnrev0(MAXDELAY,delays,BBSO,freqs,durs,loopgainmax,nonl) :> *(gain), *(gain), *(gain), *(gain)
with{
MAXDELAY = 8192; // sync w delays and prime_power_delays above
defdurs = (43.00, 84.0, 66.5, 44.5, 22.0); // NB default durations (sec)
deffreqs = (350, 1250, 3500, 8000); // NB-1 default crossover frequencies (Hz)
fdn_group(x) = vgroup("FDN REV 80", x);
freq_group(x) = fdn_group(hgroup("[1] Crossover Frequencies", x));
t60_group(x) = fdn_group(hgroup("[2] Band Decay Times (T60)", x));
path_group(x) = fdn_group(vgroup("[3] Room Dimensions", x));
revin_group(x) = fdn_group(hgroup("[4] Input Controls", x));
nonl_group(x) = revin_group(vgroup("[4] Nonlinearity",x));
quench_group(x) = revin_group(vgroup("[3] Reverb State",x));
nonl = nonl_group(hslider("[style:knob] [tooltip: nonlinear mode coupling]", 0, -0.999, 0.999, 0.001));
loopgainmax = 1.0-0.5*quench_group(button("[1] Clear [tooltip: Hold down to clear the reverberator]"));
pathmin = path_group(hslider("[1] min acoustic ray length [unit:m] [scale:log]", 12.0, 0.1, 63, 0.1));
pathmax = path_group(hslider("[2] max acoustic ray length [unit:m] [scale:log]", 63.0, 0.1, 63, 0.1));
durvals(i) = t60_group(nentry("[%i] %i [unit:s]",ba.take(i+1,defdurs), 0.1, 100, 0.1));
durs = par(i,NB,durvals(NB-1-i));
freqvals(i) = freq_group(nentry("[%i] Band %i upper edge in Hz [unit:Hz]",ba.take(i+1,deffreqs), 100, 10000, 1));
freqs = par(i,NB-1,freqvals(i));
delays = de.prime_power_delays(N,pathmin,pathmax);
gain = hslider("[3] Output Level (dB) [unit:dB][tooltip: Output scale factor]", -40, -70, 20, 0.1) : ba.db2linear;
};
//------------------------------------------------------------------------------
// HALAPHON
//------------------------------------------------------------------------------
// Converts an LR stereo image into Mid mono signal describes the frontal
// directional component of the sound image.
//
// #### Reference
//
// #### Usage
//
// ```
// _,_ : mid : _
// ```
//
// Where the two inputs are respectively:
// L,R
//
// Where the output is the Mid component
//
//------------------------------------------------------------------------------
halaphon = sp.spat(4, hramp, hdist) : halmeters
with{
hramp = os.lf_sawpos(1.0/(hslider("[01] h1 time", 3.0, -23.0, 23.0, 0.01)));
hdist = hslider("[02] h1 distance", 1, 0, 1, 0.01);
h1(v) = vgroup("Ch %v", hmeter);
halmeters = vgroup("h1 meters", par(i, 4, h1(i)));
hmeter(x) = attach(x, envelop(x) : hbargraph("[05][unit:dB] Meter", -70, +5));
envelop = abs : max ~ -(1.0/ma.SR) : max(ba.db2linear(-70)) : ba.linear2db;
};
//------------------------------------------------------------------------------
// PHASER
//------------------------------------------------------------------------------
// Converts an LR stereo image into Mid mono signal describes the frontal
// directional component of the sound image.
//
// #### Reference
//
// Where the two inputs are respectively:
// L,R
//
// Where the output is the Mid component
//
// #### Usage
//
// ```
// p_g(x) = hgroup("PHASER",x);
// frq = p_g(vslider("[01]LFO[scale:exp][style:knob]", 0.001, 0, 30, 0.001)) : si.smoo;
// fbk = p_g(vslider("[02]FBACK[style:knob]", 0.0, -1, 1, 0.01) : si.smoo);
// lfo = os.osc(frq);
// process = phaser(4,_,1,lfo,fbk);
// ```
//------------------------------------------------------------------------------
phaser(N,x,d,g,fb) = x <: _,(+:alseq(N,d,g))~*(fb):> _
with{
ap(d,g) = (+ <: de.fdelay((ma.SR/2),d),*(-g)) ~ *(g) : mem,_ : +;
alseq(N,d,g) = seq(i,N,ap(d,g));
};
// amplificazione trasparente
//import("stdfaust.lib");
ampt(g,mt) = *(g) : de.delay(ma.SR,mt2samp(mt));
sos = 344;
mt2samp(mt) = int(mt*ma.SR/sos);
//process = <:,ampt(0.5,20);