1// this code is copied from faust effect.lib and
2// some parameter texts and defaults changed
3
4declare id "zita_rev1";
5declare name "Zita Rev1";
6declare category "Reverb";
7
8import("stdfaust.lib");
9
10process(x,y) = re.zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax,x,y)
11	  : out_eq : dry_wet(x,y) : out_level
12with {
13
14  fsmax = 48000.0;  // highest sampling rate that will be used
15
16  fdn_group(x) = hgroup(
17    "zita_rev1[name:Zita_Rev1] [tooltip: ~ ZITA REV1 FEEDBACK DELAY NETWORK (FDN) & SCHROEDER ALLPASS-COMB REVERBERATOR (8x8). See Faust's effect.lib for documentation and references]", x);
18
19  in_group(x) = fdn_group(hgroup("input[name:Input]", x));
20
21  rdel = in_group(vslider("in_delay[name:Pre Delay] [unit:ms] [style:knob]
22                  [tooltip: Delay in ms before reverberation begins]",
23                  60,20,100,1));
24
25  freq_group(x) = fdn_group(hgroup("decay_times[name:Decay Times in Bands]", x));
26
27  f1 = freq_group(vslider("lf_x[name:Freq X] [unit:Hz] [style:knob] [log]
28       [tooltip: Crossover frequency (Hz) separating low and middle frequencies]",
29       200, 50, 1000, 1.08));
30
31  t60dc = freq_group(vslider("low_rt60[name:Low] [unit:s] [style:knob] [log]
32          [style:knob] [tooltip: T60 = time (in seconds) to decay 60dB in low-frequency band]",
33	  3, 1, 8, 1.08));
34
35  t60m = freq_group(vslider("mid_rt60[name:Mid] [unit:s] [style:knob] [log]
36          [tooltip: T60 = time (in seconds) to decay 60dB in middle band]",
37	  2, 1, 8, 1.08));
38
39  f2 = freq_group(vslider("hf_damping[name:HF Damp] [unit:Hz] [style:knob] [log]
40       [tooltip: Frequency (Hz) at which the high-frequency T60 is half the middle-band's T60]",
41       6000, 1500, 0.49*fsmax, 1.08));
42
43  out_eq = pareq_stereo(eq1f,eq1l,eq1q) : pareq_stereo(eq2f,eq2l,eq2q);
44// Zolzer style peaking eq (not used in zita-fi.rev1) (filter.lib):
45// pareq_stereo(eqf,eql,Q) = fi.peak_eq(eql,eqf,eqf/Q), fi.peak_eq(eql,eqf,eqf/Q);
46// Regalia-Mitra peaking eq with "Q" hard-wired near sqrt(g)/2 (filter.lib):
47  pareq_stereo(eqf,eql,Q) = fi.peak_eq_rm(eql,eqf,tpbt), fi.peak_eq_rm(eql,eqf,tpbt)
48  with {
49    tpbt = wcT/sqrt(g); // tan(ma.PI*B/ma.SR) where B bandwidth in Hz (Q^2 ~ g/4)
50    wcT = 2*ma.PI*eqf/ma.SR;  // peak frequency in rad/sample
51    g = ba.db2linear(eql); // peak gain
52  };
53
54  eq1_group(x) = fdn_group(hgroup("equalizer1[name:RM Peaking Equalizer 1]", x));
55
56  eq1f = eq1_group(vslider("eq1_freq[name:Freq] [unit:Hz] [style:knob] [log]
57       [tooltip: Center-frequency of second-order Regalia-Mitra peaking equalizer section 1]",
58       315, 40, 2500, 1.08));
59
60  eq1l = eq1_group(vslider("eq1_level[name:Level] [unit:dB] [style:knob]
61       [tooltip: Peak level in dB of second-order Regalia-Mitra peaking equalizer section 1]",
62       0, -15, 15, 0.1));
63
64  eq1q = eq1_group(vslider("eq1_q[name:Q] [style:knob]
65       [tooltip: Q = centerFrequency/bandwidth of second-order peaking equalizer section 1]",
66       3, 0.1, 10, 0.1));
67
68  eq2_group(x) = fdn_group(hgroup("equalizer2[name:RM Peaking Equalizer 2]", x));
69
70  eq2f = eq2_group(vslider("eq2_freq[name:Freq] [unit:Hz] [style:knob] [log]
71       [tooltip: Center-frequency of second-order Regalia-Mitra peaking equalizer section 2]",
72       1500, 160, 10000, 1.08));
73
74  eq2l = eq2_group(vslider("eq2_level[name:Level] [unit:dB] [style:knob]
75       [tooltip: Peak level in dB of second-order Regalia-Mitra peaking equalizer section 2]",
76       0, -15, 15, 0.1));
77
78  eq2q = eq2_group(vslider("eq2_q[name:Q] [style:knob]
79       [tooltip: Q = centerFrequency/bandwidth of second-order peaking equalizer section 2]",
80       3, 0.1, 10, 0.1));
81
82  out_group(x)  = fdn_group(hgroup("output[name:Output]", x));
83
84  dry_wet(x,y) = *(wet) + dry*x, *(wet) + dry*y with {
85    wet = 0.5*(drywet+1.0);
86    dry = 1.0-wet;
87  };
88
89  drywet = out_group(vslider("dry_wet_mix[name:Dry/Wet] [style:knob]
90       [tooltip: -1 = dry, 1 = wet]",
91       0, -1.0, 1.0, 0.01)) : si.smooth(0.999);
92
93  out_level = *(gain),*(gain);
94
95  gain = out_group(vslider("level[name:Level] [unit:dB] [style:knob]
96    [tooltip: Output scale factor]", 0, -70, 40, 0.1))
97    : si.smooth(0.999) : ba.db2linear;
98
99};
100