forked from LucaSpanedda/Digital_Reverberation_in_Faust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0.00_Reverbs_Library.dsp
146 lines (139 loc) · 6.2 KB
/
0.00_Reverbs_Library.dsp
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
// FAUST standard library
import("stdfaust.lib");
//-LUCA-SPANEDDA-DIGITAL-REVERBS-LIBRARY----------------------------------------
//------------------------------------------------------------------------------
//-UTILITIES--------------------------------------------------------------------
//
//------------------------------------------------------------------------------
// CONVERSION MILLISECONDS to SAMPLES
//------------------------------------------------------------------------------
// (t) = give time in milliseconds we want to know in samples
msasamps(t) = (ma.SR/1000)*t : int;
//
//
//------------------------------------------------------------------------------
// CONVERSION SAMPLES to MILLISECONDS
//------------------------------------------------------------------------------
// (samps) = give tot. samples we want to know in milliseconds
sampsams(samps) = ((1000/ma.SR)*samps) : int;
//
//
//------------------------------------------------------------------------------
// T60 DECAY TIME from SAMPLES
//------------------------------------------------------------------------------
// (samps,seconds) = give: samples of the filter, seconds we want for t60 decay
dect60(samps,seconds) = 1/(10^((3*(((1000 / ma.SR)*samps)/1000))/seconds));
//
//
//------------------------------------------------------------------------------
// T60 DECAY TIME from MILLISECONDS
//------------------------------------------------------------------------------
// (ms,seconds) = give: ms delay of the filter, seconds we want for t60 decay
dect60ms(ms,seconds) = 1/(10^((3*(ms/1000))/seconds));
//
//
//------------------------------------------------------------------------------
// DIRAC IMPULSE (1 SAMPLE IMPULSE)
//------------------------------------------------------------------------------
dirac = 1-(1:mem)
//
//
//------------------------------------------------------------------------------
// SOUND TO THE WALL AND BACK TIME
//------------------------------------------------------------------------------
// (meters) = give a distance in meters for samples of the filter
wall(meters) = ((ma.SR/1000.)*((1000*meters)/343.1)*2);
//
//
//-FILTERS----------------------------------------------------------------------
//
//------------------------------------------------------------------------------
// ONEZERO FILTER (FIR of I° Order)
//------------------------------------------------------------------------------
// (g) = give amplitude 0-1(open-close) to the delayed signal
ozf(g) = _<:(mem*g), _ :>;
//
//
//------------------------------------------------------------------------------
// ONEPOLE FILTER (IIR of 1 sample delay)
//------------------------------------------------------------------------------
// (g) = give amplitude 1-0(open-close) for the lowpass cut
opf(g) = _*g : +~(_ : *(1- g));
//
//
//------------------------------------------------------------------------------
// FEEDFORWARD COMB FILTER (FIR of N° sample delay)
//------------------------------------------------------------------------------
// (t,g) = delay time in samples, filter gain 0-1
ffcf(t,g) = _ <: ( _@(t-1) *g), _ :> _;
//
//
//------------------------------------------------------------------------------
// FEEDBACK COMB FILTER (IIR of N° sample delay)
//------------------------------------------------------------------------------
// (t,g) = give: delay time in samples, feedback gain 0-1
fbcf(t,g) = _ : (+ @(t-1)~ *(g)) : mem;
//
//
//------------------------------------------------------------------------------
// LOWPASS FEEDBACK COMB FILTER (IIR of N° sample delay)
//------------------------------------------------------------------------------
// (t,g,cut) = give: delay samps, feedback gain 0-1, lowpass cut 1-0(open-close)
lfbcf(t,g,cut) = (+ : @(t-1) : _*cut : +~(_ : *(1-cut)))~ *(g) : mem;
//
//
//------------------------------------------------------------------------------
// ALLPASS FILTER (FIR + IIR COMB FILTER)
//------------------------------------------------------------------------------
// (t,g) = give: delay in samples, feedback gain 0-1
apf(t,g) = (+: _<: @(t-1), *(g))~ *(-g) : mem, _ : + : _;
//
//
//------------------------------------------------------------------------------
// ALLPASS FILTER - fixed - POSITIVE FEEDBACK
//------------------------------------------------------------------------------
// (t,g) = give: delay in samples, feedback gain 0-1
apffp(t,g) = (+: _<: @(min(max(t-1,0),ma.SR)), *(-g))~ *(g) : mem, _ : + : _;
//
//
//------------------------------------------------------------------------------
// ALLPASS FILTER - fixed - NEGATIVE FEEDBACK
//------------------------------------------------------------------------------
// (t,g) = give: delay in samples, feedback gain 0-1
apffn(t,g) = (+: _<: @(min(max(t-1,0),ma.SR)), *(g))~ *(-g) : mem, _ : + : _;
//
//
//-REVERBERATORS----------------------------------------------------------------
//
//------------------------------------------------------------------------------
// CHAMBERLIN REVERB
// High-quality stereo reverberator:
// Musical Applications of Microprocessor
//------------------------------------------------------------------------------
// chamberlinverb
chamberlinverb = ap3ch <: apout1ch, apout2ch
with{
ap3ch = apffp(msasamps(49.6),0.75) :
apffp(msasamps(34.75),0.72) : apffp(msasamps(24.18),0.691);
apout1ch = apffp(msasamps(17.85),0.649) : apffp(msasamps(10.98),0.662);
apout2ch = apffp(msasamps(18.01),0.646) : apffp(msasamps(10.82),0.666);
};
//
//
//------------------------------------------------------------------------------
// CHAMBERLIN REVERB
// with T60 Decay
//------------------------------------------------------------------------------
// (seconds) = give: decay time in seconds of 60dB
chamberlindecay(seconds) = ap3ch <: apout1ch, apout2ch
with{
ap3ch = apffp(msasamps(49.6),dect60(49.6,seconds)) :
apffp(msasamps(34.75),dect60(34.75,seconds)) :
apffp(msasamps(24.18),dect60(24.18,seconds));
apout1ch = apffp(msasamps(17.85),dect60(17.85,seconds)) :
apffp(msasamps(10.98),dect60(10.98,seconds));
apout2ch = apffp(msasamps(18.01),dect60(18.01,seconds)) :
apffp(msasamps(10.82),dect60(10.82,seconds));
};
//
//