forked from s-e-a-m/faust-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnottoli.lib
191 lines (166 loc) · 7.82 KB
/
nottoli.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
//############################################################## nottoli.lib ###
//
// A library for analise and measure signals. Its official prefix is `gn`.
//
// * VOICED UNVOICED
// * CHARLIEVERB
// *
// *
// *
//
//##############################################################################
/*******************************************************************************
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 "Faust Giorgio Nottoli Algorithms Library";
declare version "0.1";
declare author "Giuseppe Silvi";
declare license "CC4";
//-------------------------------------------------------------- VOICED UNVOICED
threshold = hslider("[2] Threshold", 1.452, 0, 10.000, 0.001);
insp1 = hbargraph("insp1",-2,2);
insp2 = hbargraph("insp2",-2,2);
process = _ <: de.delay(512,500),(_<: *(_,_') < (0) : slidingSumN(500,512) : insp1 : *(0.10) : insp2 : > (threshold) : * (1.570796) <: cos, sin),de.delay(512,500) : *,*;
//----------------------------------------------------------------- GNCOMMON ---
//----------------------------------------------------------------- PORTING ----
//------------------------------------------------------------------------------
//AllPass delay line
/*
g
|
|-----<----------*---------<------|
| |
| | 1-g*g
| +---------------------------+ | |
x ->|-+->| DELAY LINE |->|--*--+--> y
| +---------------------------+ |
| | |
| Delay^Time |
| |
|------->----------*--------->------------|
|
-g
N.B. Delay time is expressed in seconds Only an integer number of samples is
derived from delay time (sec.) The delay line output is normalized
*/
gnalp(D,g) = _ <: ( + : de.delay((ma.SR/2),int(D-1)))~*(g),_ : *(1-(g*g)), *(-g) : +;
//process = _, gnalp(512,0.9);
//-------------------------------------------------------------- CHARLIEVERB ---
//-------------------------------------------------------------- CSOUND --------
//-------------------------------------------------------------- PORTING -------
import("stdfaust.lib");
// GLOBAL INTERFACE
parameters(x) = hgroup("CharlieVerb",x);
// INPUT-FILTER
if_g(x) = parameters(vgroup("[01]INPUT FILTERS",x));
ihip = if_g(vslider("[01]HIPASS[style:knob][scale:exp]", 20,20,1000,0.1) : si.smoo);
ilop = if_g(vslider("[02]LOPASS[style:knob][scale:exp]", 20000,1000,20000,0.1) : si.smoo);
input_filters(ihip,ilop) = fi.highpass(2,ihip) : fi.lowpass(2,ilop);
// PRE-DELAY
pdly = if_g(vslider("[03]PREDELAY[style:knob]", 1,1,100,0.001)/1000 : ba.sec2samp : si.smoo);
mpdl = ba.sec2samp(0.11) : int;
predelay(pdly) = de.fdelay(mpdl,pdly);
// // LIBRARY
// // COMPUTER MUSIC TUTORIAL ALLPASS
// cmtap(maxdel,D,g) = (+ <: de.delay(maxdel,int(D-1)),*(-g)) ~ *(g) : +;
// // CSOUND TONE LOW PASS FILTER
// tone(freq) = _*c1 : (+~_ *(c2))
// with{
// hp = freq; //freq
// c1 = 1-c2;
// b = 2 - (cos(2*ma.PI*(hp/ma.SR)));
// c2 = b - sqrt((b*b)-1.0);
// };
// CSOUND SPECS
ifactor = ma.SR/origSR;
origSR = 44100;
ilog001 = log(0.001);
// fragmentation (to smare pulses) 3x allpass filters
// delay times
itfrag1 = (67/25600)*ifactor;
itfrag2 = (213/25600)*ifactor;
itfrag3 = (647/25600)*ifactor;
// TIME TO SAMPS CONVERSION
itfrag1s = itfrag1 : ba.sec2samp;
itfrag2s = itfrag2 : ba.sec2samp;
itfrag3s = itfrag3 : ba.sec2samp;
ap_g(x) = parameters(vgroup("[02]ALLPASS",x));
dT = ap_g(vslider("[04]AP Decay Time[style:knob]", 6,6,36,0.1) : si.smoo);
apfrag1 = cmtap((2*itfrag1s),(dT*itfrag1));
apfrag2 = cmtap((2*itfrag2s),(dT*itfrag2));
apfrag3 = cmtap((2*itfrag3s),(dT*itfrag3));
fragmentation = apfrag1 : apfrag2 : apfrag3;
//process = _*0.707 : frag * 0.1;
//process = dT*itfrag3; // ktdecayfrag3 = ktattack * itfrag3 => gain > 1 per max 40 clip 36
itdensity = 0.01770 * ifactor : ba.sec2samp ;
kdensity = ap_g(vslider("[04]Density[style:knob]", 0.1,0.1,1,0.01) : si.smoo);
density = cmtap(itdensity,kdensity);
//process = density;
// reverberation 6x comb+alpass filters
// comb delays
itcomb1 = .05004355*ifactor;
itcomb2 = .05607709*ifactor;
itcomb3 = .06106576*ifactor;
itcomb4 = .06800453*ifactor;
itcomb5 = .07131519*ifactor;
itcomb6 = .07839002*ifactor;
//process = itcomb1;
itcomb1s = itcomb1 : ba.sec2samp : int;
itcomb2s = itcomb2 : ba.sec2samp : int;
itcomb3s = itcomb3 : ba.sec2samp : int;
itcomb4s = itcomb4 : ba.sec2samp : int;
itcomb5s = itcomb5 : ba.sec2samp : int;
itcomb6s = itcomb6 : ba.sec2samp : int;
//comb decay feedback coefs
kfeed1 = exp(itcomb1*ilog001/combdt);
kfeed2 = exp(itcomb2*ilog001/combdt);
kfeed3 = exp(itcomb3*ilog001/combdt);
kfeed4 = exp(itcomb4*ilog001/combdt);
kfeed5 = exp(itcomb5*ilog001/combdt);
kfeed6 = exp(itcomb6*ilog001/combdt);
//allpass delays
itdiffuser1 = .00610*ifactor : ba.sec2samp;
itdiffuser2 = .00911*ifactor : ba.sec2samp;
itdiffuser3 = .01118*ifactor : ba.sec2samp;
itdiffuser4 = .01339*ifactor : ba.sec2samp;
itdiffuser5 = .01529*ifactor : ba.sec2samp;
itdiffuser6 = .01731*ifactor : ba.sec2samp;
idifftime = 0.5;
er_g(x) = parameters(vgroup("[03]COMB",x));
comblp = er_g(vslider("[05]TONE[style:knob]", 20000,250,20000,1) : si.smoo);
combdt = er_g(vslider("[06]Decay Time[style:knob]", 0.5,0,1,0.001) : si.smoo);
adel1 = (+ : *(kfeed1) : de.delay(ma.SR,itcomb1s))~(cmtap(itdiffuser1,idifftime) : tone(comblp));
adel2 = (+ : *(kfeed2) : de.delay(ma.SR,itcomb2s))~(cmtap(itdiffuser2,idifftime) : tone(comblp));
adel3 = (+ : *(kfeed3) : de.delay(ma.SR,itcomb3s))~(cmtap(itdiffuser3,idifftime) : tone(comblp));
adel4 = (+ : *(kfeed4) : de.delay(ma.SR,itcomb4s))~(cmtap(itdiffuser4,idifftime) : tone(comblp));
adel5 = (+ : *(kfeed5) : de.delay(ma.SR,itcomb5s))~(cmtap(itdiffuser5,idifftime) : tone(comblp));
adel6 = (+ : *(kfeed6) : de.delay(ma.SR,itcomb6s))~(cmtap(itdiffuser6,idifftime) : tone(comblp));
asumL = (adel1-adel2+adel3-adel4+adel5-adel6)*(0.25); //-12dB
asumR = (adel1+adel2-adel3+adel4-adel5+adel6)*(0.25) ; //-12dB
//process = _ <: asumL, asumR;
// MIXER
om_g(x) = parameters(hgroup("[99]OUTPUT MIXER", x));
inlev = *(om_g(vslider("[01]INPUT LEVEL", 0,0,1,0.01) : si.smoo));
er = *(om_g(vslider("[02]L", 0,0,1,0.01) : si.smoo));
diff = *(om_g(vslider("[03]R", 0,0,1,0.01) : si.smoo));
mixer = (inlev <: _,_) ,er,diff :> _,_;
charlieverb = _*(0.707) <:_, (input_filters(ihip,ilop) : predelay(pdly) : fragmentation : density <: asumL, asumR);// : mixer;