rdk

Check-in [3c171a0296]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:compiled /initrd/mnt/dev_save/dsp/rdk/test/zt2.dsp to zt2.jgtk using f2jgtk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | www
Files: files | file ages | folders
SHA1:3c171a02961c11ea2f1bfa75504c084b379a4fec
User & Date: root 2019-01-08 13:36:30
Context
2019-01-09
06:12
compiled /initrd/mnt/dev_save/dsp/rdk/test/zt2.dsp to zt2.jgtk using f2jgtk. renamed params. complete. check-in: 5567893d1e user: root tags: www
2019-01-08
13:36
compiled /initrd/mnt/dev_save/dsp/rdk/test/zt2.dsp to zt2.jgtk using f2jgtk. check-in: 3c171a0296 user: root tags: www
2019-01-07
07:32
SchlemmerReverb/zita_ref1d.jgtk --> preset: chamber () (/initrd/mnt/dev_save/dsp/rdk/SchlemmerReverb/zita_ref1d-presets) drums eg. check-in: 709d3069e4 user: root tags: www
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Deleted SchlemmerReverb/connect_pd.sh.

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
#!/bin/sh

app1="pure_data_0"
app2="zita_ref1d.jgtk"
chain="$app1 $app2"

while [ 0 ] ; do
echo run? $chain ?
read
  ### 1. disconnect all
  jack_disconnect system:capture_1 mhwe:inL #2> /dev/null
  jack_disconnect system:capture_2 mhwe:inR #2> /dev/null
  jack_disconnect mhwe:outL system:playback_1 #2> /dev/null
  jack_disconnect mhwe:outR system:playback_2 #2> /dev/null
  for component in $chain ; do
  echo $component
  #read
    jack_disconnect system:capture_1 $component:in_0 #2> /dev/null
    jack_disconnect system:capture_2 $component:in_1 #2> /dev/null
    jack_disconnect $component:out_0 system:playback_1 #2> /dev/null
    jack_disconnect $component:out_1 system:playback_2 #2> /dev/null
    jack_disconnect system:capture_1 $component:input0 #2> /dev/null
    jack_disconnect system:capture_2 $component:input1 #2> /dev/null
    jack_disconnect $component:output0 system:playback_1 #2> /dev/null
    jack_disconnect $component:output1 system:playback_2 #2> /dev/null

  done
  #read
### 1. make connections  
	jack_connect mhwe:outL $app1:input0 #2> /dev/null
	jack_connect mhwe:outR $app1:input1 #2> /dev/null
  for count in 0 1 2 3 4 5 6 7 ; do
    jack_connect $app1:output$count $app2:in_$count #2> /dev/null
  done
  jack_connect $app1:output8 system:playback_1 #2> /dev/null
  jack_connect $app1:output9 system:playback_2 #2> /dev/null
  jack_connect $app2:out_0 system:playback_1 #2> /dev/null  
  jack_connect $app2:out_1 system:playback_2 #2> /dev/null  
done
  
  
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































Added SchlemmerReverb/scripts/connect_pd.sh.



























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#!/bin/sh

app1="pure_data_0"
app2="zita_ref1d.jgtk"
chain="$app1 $app2"

while [ ! pidof $app2 ] ; do sleep 0.1 ; done

while [ 0 ] ; do

  ### 1. disconnect all
  jack_disconnect system:capture_1 mhwe:inL #2> /dev/null
  jack_disconnect system:capture_2 mhwe:inR #2> /dev/null
  jack_disconnect mhwe:outL system:playback_1 #2> /dev/null
  jack_disconnect mhwe:outR system:playback_2 #2> /dev/null
  for component in $chain ; do
  echo $component
  #read
    jack_disconnect system:capture_1 $component:in_0 #2> /dev/null
    jack_disconnect system:capture_2 $component:in_1 #2> /dev/null
    jack_disconnect $component:out_0 system:playback_1 #2> /dev/null
    jack_disconnect $component:out_1 system:playback_2 #2> /dev/null
    jack_disconnect system:capture_1 $component:input0 #2> /dev/null
    jack_disconnect system:capture_2 $component:input1 #2> /dev/null
    jack_disconnect $component:output0 system:playback_1 #2> /dev/null
    jack_disconnect $component:output1 system:playback_2 #2> /dev/null

  done
  #read
### 1. make connections  
	jack_connect mhwe:outL $app1:input0 #2> /dev/null
	jack_connect mhwe:outR $app1:input1 #2> /dev/null
  for count in 0 1 2 3 4 5 6 7 ; do
    jack_connect $app1:output$count $app2:in_$count #2> /dev/null
  done
  jack_connect $app1:output8 system:playback_1 #2> /dev/null
  jack_connect $app1:output9 system:playback_2 #2> /dev/null
  jack_connect $app2:out_0 system:playback_1 #2> /dev/null  
  jack_connect $app2:out_1 system:playback_2 #2> /dev/null 
  
  echo run? $chain ?
  read 
done
  
  

Added SchlemmerReverb/scripts/zita_ext_demo.sh.























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#!/bin/sh

cd /mnt/home/dsp/rdk/

roxterm --tab -n JACK -e qjackctl

#if ! pidof jackd >& /dev/null; then
#(qjackctl) &
#fi

while [ ! pidof jackd ] ; do sleep 0.1 ; done
echo x
read

mhwaveedit /mnt/home/dsp/wavetestfile/drums_lowart_bd_sn.WAV &
cd SchlemmerReverb/directivity_polar
roxterm --tab -n PD -e pdextended uref3filters_test2.pd
cd ..
roxterm --tab -n FAUST -e preset zita_ref1d.jgtk $PWD chamber
cd scripts
roxterm --tab -n CONNECT -e ./connect_pd.sh






Added SchlemmerReverb/zita_ref1d-presets/defaults.default_fl_faun.























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
LF_X = 200;
Low_RT60 = 5.205;
Mid_RT60 = 2.7;
HF_Damping = 9082.8;
RoomSize = 1.52;
RT = 0.284;
APDELAY_PERCENT = 0.62;
AP_G = 0.62;
ER_COMPRESSION_FACTOR = 1;
compare_loss_filters = 1;
SIM_ROOM(1) = 42;
SIM_ROOM(2) = 19;
SIM_ROOM(3) = 16;
SIM_SOURCE(1) = 33;
SIM_SOURCE(2) = 11;
SIM_SOURCE(3) = 3;
SIM_DISTANCE = 0.618;
SIM_LR = 0.569;
SIM_DESTINATION(3) = 1;
BY(1) = 0;
Outlevel(1) = 0.3;
BY(2) = 0;
Outdelay = 256;
Outlevel(2) = -0.5;
DIR_WD = 0.005;
ZE_SinusDepth = 0.004;
ZE_SinusFreqHz = 1.18;

Added test/zt.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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
import("filter.lib");
import("math.lib");

///1
//const:
fsmax=48000; //zita_gui.fsmax
//process(x,y) = zita_rev_fdn(1,2,3,4,fsmax,x,y);
///2 zita_rev1(x,y) = ... with {...} -> zita_gui = environment{...}
//process(x,y) = zita_rev_fdn(zita_gui.f1,zita_gui.f2,zita_gui.t60m,zita_gui.t60dc,48000,x,y);
///3 zita_rev_fdn with {...} -> //--- ; freqs = (zita_gui.f1,zita_gui.f2); durs = (zita_gui.t60dc,zita_gui.t60m);
process(x,y) = zita_rev_fdn(zita.freqs,zita.durs,fsmax,x,y);
//doesnt work:
//process = zita_rev_fdn_demo;


//------------------------------- zita_rev_fdn -------------------------------
// Internal 8x8 late-reverberation FDN used in the FOSS Linux reverb zita-rev1
// by Fons Adriaensen <fons@linuxaudio.org>.  This is an FDN reverb with
// allpass comb filters in each feedback delay in addition to the
// damping filters.
//
// USAGE:
//   bus(8) : zita_rev_fdn(f1,f2,t60dc,t60m,fsmax) : bus(8)
//
// WHERE
//   f1    = crossover frequency (Hz) separating dc and midrange frequencies
//   f2    = frequency (Hz) above f1 where T60 = t60m/2 (see below)
//   t60dc = desired decay time (t60) at frequency 0 (sec)
//   t60m  = desired decay time (t60) at midrange frequencies (sec)
//   fsmax = maximum sampling rate to be used (Hz)
//
// REFERENCES:
//   http://www.kokkinizita.net/linuxaudio/zita-rev1-doc/quickguide.html
//   https://ccrma.stanford.edu/~jos/pasp/Zita_Rev1.html
//
// DEPENDENCIES:
//   filter.lib (allpass_comb, lowpass, smooth)
//   math.lib (hadamard, take, etc.)

///---------------------------------------------------------------
zita_rev_fdn(zita.freqs,zita.durs,zita.fsmax) =
  ((bus(2*zita.N) :> zita.allpass_combs(zita.N) : zita.feedbackmatrix(zita.N)) ~
   (zita.delayfilters(zita.N,zita.freqs,zita.durs) : zita.fbdelaylines(zita.N)));
//---with {
zita = environment {
  N = 8;

  // Delay-line lengths in seconds:
  apdelays = (0.020346, 0.024421, 0.031604, 0.027333, 0.022904,
              0.029291, 0.013458, 0.019123); // feedforward delays in seconds
  tdelays = ( 0.153129, 0.210389, 0.127837, 0.256891, 0.174713,
              0.192303, 0.125000, 0.219991); // total delays in seconds
  tdelay(i) = floor(0.5 + SR*take(i+1,tdelays)); // samples
  apdelay(i) = floor(0.5 + SR*take(i+1,apdelays));
  fbdelay(i) = tdelay(i) - apdelay(i);
  // NOTE: Since SR is not bounded at compile time, we can't use it to
  // allocate delay lines; hence, the fsmax parameter:
  tdelaymaxfs(i) = floor(0.5 + fsmax*take(i+1,tdelays));
  apdelaymaxfs(i) = floor(0.5 + fsmax*take(i+1,apdelays));
  fbdelaymaxfs(i) = tdelaymaxfs(i) - apdelaymaxfs(i);
  nextpow2(x) = ceil(log(x)/log(2.0));
  maxapdelay(i) = int(2.0^max(1.0,nextpow2(apdelaymaxfs(i))));
  maxfbdelay(i) = int(2.0^max(1.0,nextpow2(fbdelaymaxfs(i))));

  apcoeff(i) = select2(i&1,0.6,-0.6);  // allpass comb-filter coefficient
  allpass_combs(N) =
    par(i,N,(allpass_comb(maxapdelay(i),apdelay(i),apcoeff(i)))); // filter.lib
  fbdelaylines(N) = par(i,N,(delay(maxfbdelay(i),(fbdelay(i)))));
  ///-----------------------snip
  freqs = (zita_gui.f1,zita_gui.f2); durs = (zita_gui.t60dc,zita_gui.t60m);
  ///-----------------------snap
  delayfilters(N,zita.freqs,zita.durs) = par(i,N,filter(i,zita.freqs,zita.durs));
  feedbackmatrix(N) = hadamard(N); // math.lib

  staynormal = 10.0^(-20); // let signals decay well below LSB, but not to zero

  special_lowpass(g,f) = smooth(p) with {
    // unity-dc-gain lowpass needs gain g at frequency f => quadratic formula:
    p = mbo2 - sqrt(max(0,mbo2*mbo2 - 1.0)); // other solution is unstable
    mbo2 = (1.0 - gs*c)/(1.0 - gs); // NOTE: must ensure |g|<1 (t60m finite)
    gs = g*g;
    c = cos(2.0*PI*f/float(SR));
  };

  filter(i,zita.freqs,zita.durs) = lowshelf_lowpass(i)/sqrt(float(zita.N))+staynormal
  with {
    lowshelf_lowpass(i) = gM*low_shelf1_l(g0/gM,f(1)):special_lowpass(gM,f(2));
    low_shelf1_l(G0,fx,x) = x + (G0-1)*lowpass(1,fx,x); // filter.lib
    g0 = g(0,i);
    gM = g(1,i);
    f(k) = take(k,zita.freqs);
    dur(j) = take(j+1,zita.durs);
    n60(j) = dur(j)*SR; // decay time in samples
    g(j,i) = exp(-3.0*log(10.0)*tdelay(i)/n60(j));
  };
//---};
};

// Stereo input delay used by zita_rev1 in both stereo and ambisonics mode:
zita_in_delay(rdel) = zita_delay_mono(rdel), zita_delay_mono(rdel) with {
  zita_delay_mono(rdel) = delay(8192,SR*rdel*0.001) * 0.3;
};

// Stereo input mapping used by zita_rev1 in both stereo and ambisonics mode:
zita_distrib2(N) = _,_ <: fanflip(N) with {
   fanflip(4) = _,_,*(-1),*(-1);
   fanflip(N) = fanflip(N/2),fanflip(N/2);
};

//--------------------------- zita_rev_fdn_demo ------------------------------
// zita_rev_fdn_demo = zita_rev_fdn (above) + basic GUI
//
// USAGE:
//   bus(8) : zita_rev_fdn_demo(f1,f2,t60dc,t60m,fsmax) : bus(8)
//
// WHERE
//   (args and references as for zita_rev_fdn above)

///---------------------------------------------------------------
zita_rev_fdn_demo = zita_rev_fdn(f1,f2,t60dc,t60m,fsmax)
with {
  fsmax = 48000.0;
  fdn_group(x) = hgroup(
    "Zita_Rev Internal FDN Reverb [tooltip: ~ Zita_Rev's internal 8x8 Feedback Delay Network (FDN) & Schroeder allpass-comb reverberator.  See Faust's effect.lib for documentation and references]",x);
  t60dc = fdn_group(vslider("[1] Low RT60 [unit:s] [style:knob]
    [style:knob]
    [tooltip: T60 = time (in seconds) to decay 60dB in low-frequency band]",
    3, 1, 8, 0.1));
  f1 = fdn_group(vslider("[2] LF X [unit:Hz] [style:knob]
    [tooltip: Crossover frequency (Hz) separating low and middle frequencies]",
    200, 50, 1000, 1));
  t60m = fdn_group(vslider("[3] Mid RT60 [unit:s] [style:knob]
    [tooltip: T60 = time (in seconds) to decay 60dB in middle band]",
    2, 1, 8, 0.1));
  f2 = fdn_group(vslider("[4] HF Damping [unit:Hz] [style:knob]
    [tooltip: Frequency (Hz) at which the high-frequency T60 is half the middle-band's T60]",
    6000, 1500, 0.49*fsmax, 1));
};

//---------------------------- zita_rev1_stereo ---------------------------
// Extend zita_rev_fdn to include zita_rev1 input/output mapping in stereo mode.
//
// USAGE:
//   _,_ : zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax) : _,_
//
// WHERE
//   rdel  = delay (in ms) before reverberation begins (e.g., 0 to ~100 ms)
//   (remaining args and refs as for zita_rev_fdn above)

///---------------------------------------------------------------
zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax) =
   zita_in_delay(rdel)
 : zita_distrib2(N)
 : zita_rev_fdn(f1,f2,t60dc,t60m,fsmax)
 : output2(N)
with {
 N = 8;
 output2(N) = outmix(N) : *(t1),*(t1);
 t1 = 0.37; // zita-rev1 linearly ramps from 0 to t1 over one buffer
 outmix(4) = !,butterfly(2),!; // probably the result of some experimenting!
 outmix(N) = outmix(N/2),par(i,N/2,!);
};

//----------------------------- zita_rev1_ambi ---------------------------
// Extend zita_rev_fdn to include zita_rev1 input/output mapping in
// "ambisonics mode", as provided in the Linux C++ version.
//
// USAGE:
//   _,_ : zita_rev1_ambi(rgxyz,rdel,f1,f2,t60dc,t60m,fsmax) : _,_,_,_
//
// WHERE
//   rgxyz = relative gain of lanes 1,4,2 to lane 0 in output (e.g., -9 to 9)
//   (remaining args and references as for zita_rev1_stereo above)

///---------------------------------------------------------------
zita_rev1_ambi(rgxyz,rdel,f1,f2,t60dc,t60m,fsmax) =
   zita_in_delay(rdel)
 : zita_distrib2(N)
 : zita_rev_fdn(f1,f2,t60dc,t60m,fsmax)
 : output4(N) // ambisonics mode
with {
  N=8;
  output4(N) = select4 : *(t0),*(t1),*(t1),*(t1);
  select4 = _,_,_,!,_,!,!,! : _,_,cross with { cross(x,y) = y,x; };
  t0 = 1.0/sqrt(2.0);
  t1 = t0 * 10.0^(0.05 * rgxyz);
};

//---------------------------------- zita_rev1 ------------------------------
// Example GUI for zita_rev1_stereo (mostly following the Linux zita-rev1 GUI).
//
// Only the dry/wet and output level parameters are "dezippered" here.  If
// parameters are to be varied in real time, use "smooth(0.999)" or the like
// in the same way.
//
// REFERENCE:
//   http://www.kokkinizita.net/linuxaudio/zita-rev1-doc/quickguide.html
//
// DEPENDENCIES:
//   filter.lib (peak_eq_rm)

///---------------------------------------------------------------
zita_rev1(x,y) = zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax,x,y)
	  : out_eq : dry_wet(x,y) : out_level;
zita_gui = environment {

  fsmax = 48000.0;  // highest sampling rate that will be used

  fdn_group(x) = hgroup(
    "[0] Zita_Rev1 [tooltip: ~ ZITA REV1 FEEDBACK DELAY NETWORK (FDN) & SCHROEDER ALLPASS-COMB REVERBERATOR (8x8). See Faust's effect.lib for documentation and references]", x);

  in_group(x) = fdn_group(hgroup("[1] Input", x));

  rdel = in_group(vslider("[1] In Delay [unit:ms] [style:knob]
                  [tooltip: Delay in ms before reverberation begins]",
                  60,20,100,1));

  freq_group(x) = fdn_group(hgroup("[2] Decay Times in Bands (see tooltips)", x));

  f1 = freq_group(vslider("[1] LF X [unit:Hz] [style:knob]
       [tooltip: Crossover frequency (Hz) separating low and middle frequencies]",
       200, 50, 1000, 1));

  t60dc = freq_group(vslider("[2] Low RT60 [unit:s] [style:knob]
          [style:knob] [tooltip: T60 = time (in seconds) to decay 60dB in low-frequency band]",
	  3, 1, 8, 0.1));

  t60m = freq_group(vslider("[3] Mid RT60 [unit:s] [style:knob]
          [tooltip: T60 = time (in seconds) to decay 60dB in middle band]",
	  2, 1, 8, 0.1));

  f2 = freq_group(vslider("[4] HF Damping [unit:Hz] [style:knob]
       [tooltip: Frequency (Hz) at which the high-frequency T60 is half the middle-band's T60]",
       6000, 1500, 0.49*fsmax, 1));

  out_eq = pareq_stereo(eq1f,eq1l,eq1q) : pareq_stereo(eq2f,eq2l,eq2q);
// Zolzer style peaking eq (not used in zita-rev1) (filter.lib):
// pareq_stereo(eqf,eql,Q) = peak_eq(eql,eqf,eqf/Q), peak_eq(eql,eqf,eqf/Q);
// Regalia-Mitra peaking eq with "Q" hard-wired near sqrt(g)/2 (filter.lib):
  pareq_stereo(eqf,eql,Q) = peak_eq_rm(eql,eqf,tpbt), peak_eq_rm(eql,eqf,tpbt)
  with {
    tpbt = wcT/sqrt(max(0,g)); // tan(PI*B/SR), B bw in Hz (Q^2 ~ g/4)
    wcT = 2*PI*eqf/SR;  // peak frequency in rad/sample
    g = db2linear(eql); // peak gain
  };

  eq1_group(x) = fdn_group(hgroup("[3] RM Peaking Equalizer 1", x));

  eq1f = eq1_group(vslider("[1] Eq1 Freq [unit:Hz] [style:knob]
       [tooltip: Center-frequency of second-order Regalia-Mitra peaking equalizer section 1]",
       315, 40, 2500, 1));

  eq1l = eq1_group(vslider("[2] Eq1 Level [unit:dB] [style:knob]
       [tooltip: Peak level in dB of second-order Regalia-Mitra peaking equalizer section 1]",
       0, -15, 15, 0.1));

  eq1q = eq1_group(vslider("[3] Eq1 Q [style:knob]
       [tooltip: Q = centerFrequency/bandwidth of second-order peaking equalizer section 1]",
       3, 0.1, 10, 0.1));

  eq2_group(x) = fdn_group(hgroup("[4] RM Peaking Equalizer 2", x));

  eq2f = eq2_group(vslider("[1] Eq2 Freq [unit:Hz] [style:knob]
       [tooltip: Center-frequency of second-order Regalia-Mitra peaking equalizer section 2]",
       315, 40, 2500, 1));

  eq2l = eq2_group(vslider("[2] Eq2 Level [unit:dB] [style:knob]
       [tooltip: Peak level in dB of second-order Regalia-Mitra peaking equalizer section 2]",
       0, -15, 15, 0.1));

  eq2q = eq2_group(vslider("[3] Eq2 Q [style:knob]
       [tooltip: Q = centerFrequency/bandwidth of second-order peaking equalizer section 2]",
       3, 0.1, 10, 0.1));

  out_group(x)  = fdn_group(hgroup("[5] Output", x));

  dry_wet(x,y) = *(wet) + dry*x, *(wet) + dry*y with {
    wet = 0.5*(drywet+1.0);
    dry = 1.0-wet;
  };

  drywet = out_group(vslider("[1] Dry/Wet Mix [style:knob]
       [tooltip: -1 = dry, 1 = wet]",
       0, -1.0, 1.0, 0.01)) : smooth(0.999);

  out_level = *(gain),*(gain);

  gain = out_group(vslider("[2] Level [unit:dB] [style:knob]
    [tooltip: Output scale factor]", -20, -70, 40, 0.1))
    : db2linear : smooth(0.999);

};

Added test/zt2.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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
import("filter.lib");
import("math.lib");

process = bus(8) : zita_extended : bus(8) : outmix(8) : bus(2) ;

outmix(N)=bus(N)<:bus(2*N):(reva,refb):bus(4):>bus(2)
  with {
    //Lexicon style phaser
    reva=bus(N):>bus(2):par(i,2,*(zxgui.OUTLEVEL(1)));
    refb=bus(N):>bus(2):par(i,2,@(zxgui.OUTDELAY)):par(i,2,*(zxgui.OUTLEVEL(2)));
  };
    
zita_extended = (bus(2*M):>
  fbdelaylines(M))
      ~(
      allpass_combs(M)
      :zita.feedbackmatrix(M)
      :wdn(M,lossfilters(M),zxgui.FLTON)
      :wdn(M,reverbtime(M),(1-(zxgui.FLTON)))
        )
  :reflevel(M)
with {
  M=8;
  //N channel wet-dry control, "0" = dry, "1" = wet
  wdn(N,fx,ctl) = par(i,N,_) <: (fx : par(i,N,*(ctl))),par(i,N,*(1-(ctl))) :> par(i,N,_);
  
  maxapdelay(i) = 1<<16 ;
  maxfbdelay(i) = 1<<16 ;
  apdelay(i)=sim.reflectiondelay_ms(i)
    *SR/1000.0
    *zxgui.APPERCENT
    :min(maxapdelay(i))
    :max(10)
    ; //samples 
  fbdelay(i)=sim.reflectiondelay_ms(i)
    *SR/1000.0
    :min(maxfbdelay(i)-(100))
    :max(100)*zitaLFO(i)
    ;
  lossfilters(N) = zita[
    tdelay(i)=fbdelay(i)+apdelay(i);
    ].delayfilters(N,zita.freqs,zita.durs);
  fbdelaylines(N) = par(i,N,(fdelay(maxfbdelay(i),(fbdelay(i)))));
  allpass_combs(N)=par(i,N,(allpass_fcomb(maxapdelay(i),apdelay(i), zxgui.APG(i)))) 
    with {
      allpass_fcomb(maxdel,N,aN) = (+ <: fdelay(maxdel,N-1),*(aN)) ~ *(-aN) : mem,_ : + ;//filters.lib
    };
  reverbtime(N) = par(i,N,*(g0(i)))
    with {
      //choose decay law
      g0(i) = zxgui.MAINFB ; //none
      g1(i) = pow(pow(0.001,(1.0/(SR*(zxgui.RT60)))),tdelay(i)); //rt60 in seconds 
      tdelay(i) = fbdelay(i)+apdelay(i); //samps
    };
 
  zitaLFO(i)=sinusi(
    zxgui.SINUSFREQ_HZ,i*.125)
    *(zxgui.SINUSDEPTH)+1.0
    with {
      sinusi(freq,phase)=component("../rdk.lib").rdk.sinusi(freq,phase);
    };
    
  reflevel(N) = par(i,N,*(reflectionlevel(i)))
    with {
      reflectionlevel(i)=sim.reflectionlevel(i)*(zxgui.ERCOMPRESSION) + makeup ;
      makeup = 1 - zxgui.ERCOMPRESSION ;
    };
  };
  
sim = environment {

  /*** Source Image Model **********
  coordinates:
  Room <R1,R2,R3> ,Source <S1,S2,S3>, Destination <D1,D2,D3>

          front

  Width  <  R2  >
       ^ +------+  ^(Length R1, Hight R3)
         ¦ (S)  ¦  |
         ¦______¦  | ^
   (left)¦      ¦  | |(right)
         ¦  (D) ¦  | x distance S->D
         ¦      ¦  | 
       0 +------+  x 
         0       >                
          rear

  *********************************/ 

  R1 = zxgui.ROOM(1) *(zxgui.RS); //default: SIM_ROOM(1)=42; 
  R2 = zxgui.ROOM(2) *(zxgui.RS); //default: SIM_ROOM(2)=19;
  R3 = zxgui.ROOM(3) *(zxgui.RS); //default: SIM_ROOM(3)=16;

  S1 = zxgui.SOURCE(1) *(zxgui.RS); //default: SIM_SOURCE(1)=33; //todo: movement
  S2 = zxgui.SOURCE(2) *(zxgui.RS); //default: SIM_SOURCE(2)=11; 
  S3 = zxgui.SOURCE(3);             //default: SIM_SOURCE(3)=3; //sender (stage hight does not change with room size)

  D1 = (S1-1)*zxgui.DISTANCE; //default: SIM_DISTANCE=0.91; 
  D2 = (R2)*(zxgui.LR);        //default: SIM_D1=0.50;
  D3 = zxgui.DESTINATION(3) ; //default: SIM_DESTINATION(3)=1; //receiver (chair hight does not change with room size)

  SPEED_OF_SOUND=343;

  //define a pattern of 8 reflection vectors:
  ref(0) = S1 	, -S2 		, S3 ; //left wall
  ref(1) = S1 	, 2*R2-S2 , S3 ; //right wall
  ref(2) = S1 	, -S2 		, 2*R3-S3 ; //left + ceiling
  ref(3) = S1 	, 2*R2-S2 	, 2*R3-S3 ; //right + ceiling
  ref(4) = 2*R1-S1 , -S2 		, S3 ; //left + front
  ref(5) = 2*R1-S1 , 2*R2-S2 	, S3 ; //right + front
  ref(6) = -S1 , -S2 		, 2*R3-S3 ; //left + ceiling + rear
  ref(7) = -S1 , 2*R2-S2 , 2*R3-S3 ; //right + ceiling + rear

  vector(i) = ref(i), (-D1,-D2,-D3) :> bus(3) ; //subtract vector

  betrag(i) = vector(i) : par(i,3,quadrat) :> sqrt ;
   quadrat(x) = x*x ;

  direct_m = (S1-D1), (S2-D2), (S3-D3) : par(i,3,quadrat) :> sqrt ; //meter
  reflectiondelay_ms(i) = ((betrag(i) - direct_m) / SPEED_OF_SOUND) *1000 ; //milliseconds
  reflectionlevel(i) = direct_m/(betrag(i));



};

zita = environment {

  //------------------------------- zita_rev_fdn -------------------------------
  // Internal 8x8 late-reverberation FDN used in the FOSS Linux reverb zita-rev1
  // by Fons Adriaensen <fons@linuxaudio.org>.  This is an FDN reverb with
  // allpass comb filters in each feedback delay in addition to the
  // damping filters.
  //
  // USAGE:
  //   bus(8) : zita_rev_fdn(f1,f2,t60dc,t60m,fsmax) : bus(8)
  //
  // WHERE
  //   f1    = crossover frequency (Hz) separating dc and midrange frequencies
  //   f2    = frequency (Hz) above f1 where T60 = t60m/2 (see below)
  //   t60dc = desired decay time (t60) at frequency 0 (sec)
  //   t60m  = desired decay time (t60) at midrange frequencies (sec)
  //   fsmax = maximum sampling rate to be used (Hz)
  //
  // REFERENCES:
  //   http://www.kokkinizita.net/linuxaudio/zita-rev1-doc/quickguide.html
  //   https://ccrma.stanford.edu/~jos/pasp/Zita_Rev1.html
  //
  // DEPENDENCIES:
  //   filter.lib (allpass_comb, lowpass, smooth)
  //   math.lib (hadamard, take, etc.)

  zita_rev_fdn(f1,f2,t60dc,t60m,fsmax) =
    ((bus(2*N) :> allpass_combs(N) : feedbackmatrix(N)) ~
     (delayfilters(N,freqs,durs) : fbdelaylines(N)));
  //with {
    N = 8;

    // Delay-line lengths in seconds:
    apdelays = (0.020346, 0.024421, 0.031604, 0.027333, 0.022904,
                0.029291, 0.013458, 0.019123); // feedforward delays in seconds
    tdelays = ( 0.153129, 0.210389, 0.127837, 0.256891, 0.174713,
                0.192303, 0.125000, 0.219991); // total delays in seconds
    tdelay(i) = floor(0.5 + SR*take(i+1,tdelays)); // samples
    apdelay(i) = floor(0.5 + SR*take(i+1,apdelays));
    fbdelay(i) = tdelay(i) - apdelay(i);
    // NOTE: Since SR is not bounded at compile time, we can't use it to
    // allocate delay lines; hence, the fsmax parameter:
    tdelaymaxfs(i) = floor(0.5 + fsmax*take(i+1,tdelays));
    apdelaymaxfs(i) = floor(0.5 + fsmax*take(i+1,apdelays));
    fbdelaymaxfs(i) = tdelaymaxfs(i) - apdelaymaxfs(i);
    nextpow2(x) = ceil(log(x)/log(2.0));
    maxapdelay(i) = int(2.0^max(1.0,nextpow2(apdelaymaxfs(i))));
    maxfbdelay(i) = int(2.0^max(1.0,nextpow2(fbdelaymaxfs(i))));

    apcoeff(i) = select2(i&1,0.6,-0.6);  // allpass comb-filter coefficient
    allpass_combs(N) =
      par(i,N,(allpass_comb(maxapdelay(i),apdelay(i),apcoeff(i)))); // filter.lib
    fbdelaylines(N) = par(i,N,(delay(maxfbdelay(i),(fbdelay(i)))));
    freqs = (f1,f2); durs = (t60dc,t60m);
    delayfilters(N,freqs,durs) = par(i,N,filter(i,freqs,durs));
    feedbackmatrix(N) = hadamard(N); // math.lib

    staynormal = 10.0^(-20); // let signals decay well below LSB, but not to zero

    special_lowpass(g,f) = smooth(p) with {
      // unity-dc-gain lowpass needs gain g at frequency f => quadratic formula:
      p = mbo2 - sqrt(max(0,mbo2*mbo2 - 1.0)); // other solution is unstable
      mbo2 = (1.0 - gs*c)/(1.0 - gs); // NOTE: must ensure |g|<1 (t60m finite)
      gs = g*g;
      c = cos(2.0*PI*f/float(SR));
    };

    filter(i,freqs,durs) = lowshelf_lowpass(i)/sqrt(float(N))+staynormal
    with {
      lowshelf_lowpass(i) = gM*low_shelf1_l(g0/gM,f(1)):special_lowpass(gM,f(2));
      low_shelf1_l(G0,fx,x) = x + (G0-1)*lowpass(1,fx,x); // filter.lib
      g0 = g(0,i);
      gM = g(1,i);
      f(k) = take(k,freqs);
      dur(j) = take(j+1,durs);
      n60(j) = dur(j)*SR; // decay time in samples
      g(j,i) = exp(-3.0*log(10.0)*tdelay(i)/n60(j));
    };
  //};

  // Stereo input delay used by zita_rev1 in both stereo and ambisonics mode:
  zita_in_delay(rdel) = zita_delay_mono(rdel), zita_delay_mono(rdel) with {
    zita_delay_mono(rdel) = delay(8192,SR*rdel*0.001) * 0.3;
  };

  // Stereo input mapping used by zita_rev1 in both stereo and ambisonics mode:
  zita_distrib2(N) = _,_ <: fanflip(N) with {
     fanflip(4) = _,_,*(-1),*(-1);
     fanflip(N) = fanflip(N/2),fanflip(N/2);
  };

  //--------------------------- zita_rev_fdn_demo ------------------------------
  // zita_rev_fdn_demo = zita_rev_fdn (above) + basic GUI
  //
  // USAGE:
  //   bus(8) : zita_rev_fdn_demo(f1,f2,t60dc,t60m,fsmax) : bus(8)
  //
  // WHERE
  //   (args and references as for zita_rev_fdn above)

  zita_rev_fdn_demo = zita_rev_fdn(f1,f2,t60dc,t60m,fsmax);
  /*with {
    fsmax = 48000.0;
    fdn_group(x) = hgroup(
      "Zita_Rev Internal FDN Reverb [tooltip: ~ Zita_Rev's internal 8x8 Feedback Delay Network (FDN) & Schroeder allpass-comb reverberator.  See Faust's effect.lib for documentation and references]",x);
    t60dc = fdn_group(vslider("[1] Low RT60 [unit:s] [style:knob]
      [style:knob]
      [tooltip: T60 = time (in seconds) to decay 60dB in low-frequency band]",
      3, 1, 8, 0.1));
    f1 = fdn_group(vslider("[2] LF X [unit:Hz] [style:knob]
      [tooltip: Crossover frequency (Hz) separating low and middle frequencies]",
      200, 50, 1000, 1));
    t60m = fdn_group(vslider("[3] Mid RT60 [unit:s] [style:knob]
      [tooltip: T60 = time (in seconds) to decay 60dB in middle band]",
      2, 1, 8, 0.1));
    f2 = fdn_group(vslider("[4] HF Damping [unit:Hz] [style:knob]
      [tooltip: Frequency (Hz) at which the high-frequency T60 is half the middle-band's T60]",
      6000, 1500, 0.49*fsmax, 1));
  };
  */
  
  //---------------------------- zita_rev1_stereo ---------------------------
  // Extend zita_rev_fdn to include zita_rev1 input/output mapping in stereo mode.
  //
  // USAGE:
  //   _,_ : zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax) : _,_
  //
  // WHERE
  //   rdel  = delay (in ms) before reverberation begins (e.g., 0 to ~100 ms)
  //   (remaining args and refs as for zita_rev_fdn above)

  zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax) =
     zita_in_delay(rdel)
   : zita_distrib2(N)
   : zita_rev_fdn(f1,f2,t60dc,t60m,fsmax)
   : output2(N)
  with {
   N = 8;
   output2(N) = outmix(N) : *(t1),*(t1);
   t1 = 0.37; // zita-rev1 linearly ramps from 0 to t1 over one buffer
   outmix(4) = !,butterfly(2),!; // probably the result of some experimenting!
   outmix(N) = outmix(N/2),par(i,N/2,!);
  };

  //----------------------------- zita_rev1_ambi ---------------------------
  // Extend zita_rev_fdn to include zita_rev1 input/output mapping in
  // "ambisonics mode", as provided in the Linux C++ version.
  //
  // USAGE:
  //   _,_ : zita_rev1_ambi(rgxyz,rdel,f1,f2,t60dc,t60m,fsmax) : _,_,_,_
  //
  // WHERE
  //   rgxyz = relative gain of lanes 1,4,2 to lane 0 in output (e.g., -9 to 9)
  //   (remaining args and references as for zita_rev1_stereo above)

  zita_rev1_ambi(rgxyz,rdel,f1,f2,t60dc,t60m,fsmax) =
     zita_in_delay(rdel)
   : zita_distrib2(N)
   : zita_rev_fdn(f1,f2,t60dc,t60m,fsmax)
   : output4(N) // ambisonics mode
  with {
    N=8;
    output4(N) = select4 : *(t0),*(t1),*(t1),*(t1);
    select4 = _,_,_,!,_,!,!,! : _,_,cross with { cross(x,y) = y,x; };
    t0 = 1.0/sqrt(2.0);
    t1 = t0 * 10.0^(0.05 * rgxyz);
  };

  //---------------------------------- zita_rev1 ------------------------------
  // Example GUI for zita_rev1_stereo (mostly following the Linux zita-rev1 GUI).
  //
  // Only the dry/wet and output level parameters are "dezippered" here.  If
  // parameters are to be varied in real time, use "smooth(0.999)" or the like
  // in the same way.
  //
  // REFERENCE:
  //   http://www.kokkinizita.net/linuxaudio/zita-rev1-doc/quickguide.html
  //
  // DEPENDENCIES:
  //   filter.lib (peak_eq_rm)

  zita_rev1(x,y) = zita_rev1_stereo(rdel,f1,f2,t60dc,t60m,fsmax,x,y)
      : out_eq : dry_wet(x,y) : out_level;
  //with {

    fsmax = 48000.0;  // highest sampling rate that will be used

    fdn_group(x) = hgroup(
      "[0] Zita_Rev1 [tooltip: ~ ZITA REV1 FEEDBACK DELAY NETWORK (FDN) & SCHROEDER ALLPASS-COMB REVERBERATOR (8x8). See Faust's effect.lib for documentation and references]", x);

    in_group(x) = fdn_group(hgroup("[1] Input", x));

    rdel = in_group(vslider("[1] In Delay [unit:ms] [style:knob]
                    [tooltip: Delay in ms before reverberation begins]",
                    60,20,100,1));

    freq_group(x) = fdn_group(hgroup("[2] Decay Times in Bands (see tooltips)", x));

    f1 = freq_group(vslider("[1] LF X [unit:Hz] [style:knob]
         [tooltip: Crossover frequency (Hz) separating low and middle frequencies]",
         200, 50, 1000, 1));

    t60dc = freq_group(vslider("[2] Low RT60 [unit:s] [style:knob]
            [style:knob] [tooltip: T60 = time (in seconds) to decay 60dB in low-frequency band]",
      3, 1, 8, 0.1));

    t60m = freq_group(vslider("[3] Mid RT60 [unit:s] [style:knob]
            [tooltip: T60 = time (in seconds) to decay 60dB in middle band]",
      2, 1, 8, 0.1));

    f2 = freq_group(vslider("[4] HF Damping [unit:Hz] [style:knob]
         [tooltip: Frequency (Hz) at which the high-frequency T60 is half the middle-band's T60]",
         6000, 1500, 0.49*fsmax, 1));

    out_eq = pareq_stereo(eq1f,eq1l,eq1q) : pareq_stereo(eq2f,eq2l,eq2q);
  // Zolzer style peaking eq (not used in zita-rev1) (filter.lib):
  // pareq_stereo(eqf,eql,Q) = peak_eq(eql,eqf,eqf/Q), peak_eq(eql,eqf,eqf/Q);
  // Regalia-Mitra peaking eq with "Q" hard-wired near sqrt(g)/2 (filter.lib):
    pareq_stereo(eqf,eql,Q) = peak_eq_rm(eql,eqf,tpbt), peak_eq_rm(eql,eqf,tpbt)
    with {
      tpbt = wcT/sqrt(max(0,g)); // tan(PI*B/SR), B bw in Hz (Q^2 ~ g/4)
      wcT = 2*PI*eqf/SR;  // peak frequency in rad/sample
      g = db2linear(eql); // peak gain
    };

    eq1_group(x) = fdn_group(hgroup("[3] RM Peaking Equalizer 1", x));

    eq1f = eq1_group(vslider("[1] Eq1 Freq [unit:Hz] [style:knob]
         [tooltip: Center-frequency of second-order Regalia-Mitra peaking equalizer section 1]",
         315, 40, 2500, 1));

    eq1l = eq1_group(vslider("[2] Eq1 Level [unit:dB] [style:knob]
         [tooltip: Peak level in dB of second-order Regalia-Mitra peaking equalizer section 1]",
         0, -15, 15, 0.1));

    eq1q = eq1_group(vslider("[3] Eq1 Q [style:knob]
         [tooltip: Q = centerFrequency/bandwidth of second-order peaking equalizer section 1]",
         3, 0.1, 10, 0.1));

    eq2_group(x) = fdn_group(hgroup("[4] RM Peaking Equalizer 2", x));

    eq2f = eq2_group(vslider("[1] Eq2 Freq [unit:Hz] [style:knob]
         [tooltip: Center-frequency of second-order Regalia-Mitra peaking equalizer section 2]",
         315, 40, 2500, 1));

    eq2l = eq2_group(vslider("[2] Eq2 Level [unit:dB] [style:knob]
         [tooltip: Peak level in dB of second-order Regalia-Mitra peaking equalizer section 2]",
         0, -15, 15, 0.1));

    eq2q = eq2_group(vslider("[3] Eq2 Q [style:knob]
         [tooltip: Q = centerFrequency/bandwidth of second-order peaking equalizer section 2]",
         3, 0.1, 10, 0.1));

    out_group(x)  = fdn_group(hgroup("[5] Output", x));

    dry_wet(x,y) = *(wet) + dry*x, *(wet) + dry*y with {
      wet = 0.5*(drywet+1.0);
      dry = 1.0-wet;
    };

    drywet = out_group(vslider("[1] Dry/Wet Mix [style:knob]
         [tooltip: -1 = dry, 1 = wet]",
         0, -1.0, 1.0, 0.01)) : smooth(0.999);

    out_level = *(gain),*(gain);

    gain = out_group(vslider("[2] Level [unit:dB] [style:knob]
      [tooltip: Output scale factor]", -20, -70, 40, 0.1))
      : db2linear : smooth(0.999);

  //};
};

zxgui = environment {
  //GUI
  guigroup1(fx)=vgroup("[1]Zita_Extended",tgroup("",vgroup("2 Room Model",fx)));
  guigroup2(fx)=vgroup("[1]Zita_Extended",tgroup("",vgroup("1 Reverb",fx)));
  guigroup3(fx)=vgroup("[1]Zita_Extended",tgroup("",hgroup("3 Outmix",fx)));

  ROOM(i)       =guigroup1(hgroup("1",nentry("SIM_ROOM(%i)[unit:m]",SIM_ROOM(i),0,100,0.001)));
  SOURCE(i)     =guigroup1(hgroup("2",nentry("SIM_SOURCE(%i)[unit:percent]",SIM_SOURCE(i),0,100,.001))); 
  DESTINATION(i)=guigroup1(hgroup("3",nentry("[3]SIM_DESTINATION(%i)[unit:percent]",SIM_DESTINATION(i),0,100,.001))); 
  RS            =guigroup2(hslider("[0]RoomSize",RoomSize,0.010,4,.001));
  LR            =guigroup1(hgroup("3",hslider("[2]SIM_LR[unit:percent]",SIM_LR,0,1,.001))); 
  DISTANCE      =guigroup1(hgroup("3",hslider("[1]SIM_DISTANCE[unit:percent]",SIM_DISTANCE,0,1,.001))); 
  
  APG(i)         =guigroup2(hslider("[15]AP_G",AP_G,0,.9,.01)); 
  FLTON          =guigroup2(checkbox("compare_loss_filters"));
  MAINFB         =guigroup2(hslider("[12]RT",RT,0,.999,.001));
  RT60           =guigroup2(hslider("[12]RT",RT,0,12,.001));
  ERCOMPRESSION  =guigroup2(hslider("[17]ER_COMPRESSION_FACTOR",ER_COMPRESSION_FACTOR,0,1,.01));
  APPERCENT      =guigroup2(hslider("[13]APDELAY_PERCENT",APDELAY_PERCENT,0,1,.01));
  OUTDELAY       =guigroup3(vgroup("[2]Out2",nentry("[0]Outdelay",Outdelay,0,4000,1)));
  OUTLEVEL(1)    =guigroup3(vgroup("[1]Out1",nentry("[0]Outlevel(1)",Outlevel(1),-1,1,0.001)*BYBOX(1)));
  OUTLEVEL(2)    =guigroup3(vgroup("[2]Out2",nentry("[0]Outlevel(2)",Outlevel(2),-1,1,0.001)*BYBOX(2)));
  BYBOX(i) = 1-checkbox("BY(%i)");
  DIRECTIVITY_WD=guigroup3(vgroup("[3]",hgroup("[0]Directivity",vgroup("[3]Flute",nentry("[4]DIR_WD[style:knob]",DIR_WD,0,1,0.01)))));
  SINUSDEPTH     =guigroup3(vgroup("[3]",vgroup("[1]LFO",nentry("[0]ZE_SinusDepth",ZE_SinusDepth,0,1,0.001))));
  SINUSFREQ_HZ   =guigroup3(vgroup("[3]",vgroup("[1]LFO",nentry("[2]ZE_SinusFreqHz",ZE_SinusFreqHz,0,10,0.01))));
  MOVEMENT       =guigroup3(vgroup("[3]",vgroup("[1]LFO",nentry("[0]SIM_MOVEMENT",SIM_MOVEMENT,0,1,0.001))));
  
  //------------------------
  //preset: default_fl_faun
  //------------------------
  //LF_X = 200;
  //Low_RT60 = 5.205;
  //Mid_RT60 = 2.7;
  //HF_Damping = 9082.8;
  RT = 0.284;
  APDELAY_PERCENT = 0.62;
  AP_G = 0.62;
  ER_COMPRESSION_FACTOR = 1;
  compare_loss_filters = 1;
  BY(1) = 0;
  Outlevel(1) = 0.3;
  BY(2) = 0;
  Outdelay = 256;
  Outlevel(2) = -0.5;
  DIR_WD = 0.005;
  ZE_SinusDepth = 0.004;
  ZE_SinusFreqHz = 1.18;
  RoomSize = 1.52;
  SIM_ROOM(1) = 42;
  SIM_ROOM(2) = 19;
  SIM_ROOM(3) = 16;
  SIM_SOURCE(1) = 33;
  SIM_SOURCE(2) = 11;
  SIM_SOURCE(3) = 3;
  SIM_DISTANCE = 0.618;
  SIM_LR = 0.569;
  SIM_DESTINATION(3) = 1;
};