-
Notifications
You must be signed in to change notification settings - Fork 63
/
dx7.lib
1036 lines (984 loc) · 67.5 KB
/
dx7.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
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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//#################################### dx7.lib #########################################
// Yamaha DX7 emulation library. Its official prefix is `dx`.
//
// #### References
// * <https://github.com/grame-cncm/faustlibraries/blob/master/dx7.lib>
//########################################################################################
// Yamaha DX7 emulation library. The various functions available in this library
// are used by the libraries generated from `.syx` DX7 preset files. This
// toolkit was greatly inspired by the CSOUND DX7 emulation package:
// <http://www.parnasse.com/dx72csnd.shtml>.
//
// This library and its related tools are under development. Use it at your
// own risk!
//##############################################################################
/************************************************************************
************************************************************************
FAUST library file, GRAME section
Except where noted otherwise, Copyright (C) 2003-2017 by GRAME,
Centre National de Creation Musicale.
----------------------------------------------------------------------
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.
************************************************************************
************************************************************************/
/*
TODO:
* LFO not implemented yet
* The whole system needs some tuning
*/
ba = library("basics.lib");
en = library("envelopes.lib");
ma = library("maths.lib");
os = library("oscillators.lib");
declare version "1.1.0";
//----------------------`(dx.)dx7_ampf`--------------------------
// DX7 amplitude conversion function. 3 versions of this function
// are available:
//
// * `dx7_amp_bpf`: BPF version (same as in the CSOUND toolkit)
// * `dx7_amp_func`: estimated mathematical equivalent of `dx7_amp_bpf`
// * `dx7_ampf`: default (sugar for `dx7_amp_func`)
//
// #### Usage:
//
// ```
// dx7AmpPreset : dx7_ampf_bpf : _
// ```
//
// Where:
//
// * `dx7AmpPreset`: DX7 amplitude value (0-99)
//----------------------------------------------------------
// CSOUND function implemented as a BPF
// Corresponds to F2 in the CSOUND implementation.
dx7_amp_bpf = ba.bpf.start(0,0) : seq(i,14,ba.bpf.point(xPoints(i)+1,yPoints(i))) : ba.bpf.end(127,1)
with{
xPoints(n) = ba.take(n+1,(9,19,29,39,49,59,64,69,74,79,84,89,94,98));
yPoints(n) = ba.take(n+1,(0.000227445,0.000985595,0.002350265,0.005989386,0.014253222,0.033813495,0.052312358,0.080970432,0.124260804,0.190447309,0.295223654,0.457088704,0.70227445,1));
};
// Function estimated from the CSOUND function (default)
dx7_amp_func = min(98)/98 : pow(_,8);
dx7_ampf = dx7_amp_func;
//----------------------`(dx.)dx7_egraterisef`--------------------------
// DX7 envelope generator rise conversion function. 3 versions of this function
// are available:
//
// * `dx7_egraterise_bpf`: BPF version (same as in the CSOUND toolkit)
// * `dx7_egraterise_func`: estimated mathematical equivalent of `dx7_egraterise_bpf`
// * `dx7_egraterisef`: default (sugar for `dx7_egraterise_func`)
//
// #### Usage:
//
// ```
// dx7envelopeRise : dx7_egraterisef : _
// ```
//
// Where:
//
// * `dx7envelopeRise`: DX7 envelope rise value (0-99)
//----------------------------------------------------------
// CSOUND function implemented as a BPF
// Corresponds to F4 in the CSOUND implementation.
dx7_egraterise_bpf = ba.bpf.start(0,38) : seq(i,24,ba.bpf.point(xPoints(i)+1,yPoints(i))) : ba.bpf.end(127,0.003)
with{
xPoints(n) = ba.take(n+1,(4,9,14,19,24,29,34,42,45,48,51,54,60,66,68,71,74,77,
80,83,86,89,92,95));
yPoints(n) = ba.take(n+1,(22.8,12,7.5,4.8,2.7,1.8,1.3,.737,.615,
.505,.409,.321,.080,.055,.032,.024,.018,.014,.011,.008,.008,
.007,.005,.003));
};
// Function estimated from the CSOUND function (default)
dx7_egraterise_func = 38*pow((127-_)/127,12) : max(0.003);
dx7_egraterisef = dx7_egraterise_func;
//----------------------`(dx.)dx7_egraterisepercf`--------------------------
// DX7 envelope generator percussive rise conversion function. 3 versions of
// this function are available:
//
// * `dx7_egrateriseperc_bpf`: BPF version (same as in the CSOUND toolkit)
// * `dx7_egrateriseperc_func`: estimated mathematical equivalent of `dx7_egrateriseperc_bpf`
// * `dx7_egraterisepercf`: default (sugar for `dx7_egrateriseperc_func`)
//
// #### Usage:
//
// ```
// dx7envelopePercRise : dx7_egraterisepercf : _
// ```
//
// Where:
//
// * `dx7envelopePercRise`: DX7 envelope percussive rise value (0-99)
//----------------------------------------------------------
// CSOUND function implemented as a BPF
// Corresponds to F5 in the CSOUND implementation.
dx7_egrateriseperc_bpf = ba.bpf.start(0,0.00001) : seq(i,10,ba.bpf.point(xPoints(i)+1,yPoints(i))) : ba.bpf.end(127,1)
with{
xPoints(n) = ba.take(n+1,(30,34,39,49,59,69,79,89,94,98));
yPoints(n) = ba.take(n+1,(0.00001,0.02,0.06,0.14,0.24,0.35,0.5,0.7,0.86,1));
};
// Function estimated from the CSOUND function (default)
dx7_egrateriseperc_func = >=(30)*min(_-30,68)/68 : pow(_,1.8);
dx7_egraterisepercf = dx7_egrateriseperc_func;
//----------------------`(dx.)dx7_egratedecayf`--------------------------
// DX7 envelope generator decay conversion function. 3 versions of
// this function are available:
//
// * `dx7_egratedecay_bpf`: BPF version (same as in the CSOUND toolkit)
// * `dx7_egratedecay_func`: estimated mathematical equivalent of `dx7_egratedecay_bpf`
// * `dx7_egratedecayf`: default (sugar for `dx7_egratedecay_func`)
//
// #### Usage:
//
// ```
// dx7envelopeDecay : dx7_egratedecayf : _
// ```
//
// Where:
//
// * `dx7envelopeDecay`: DX7 envelope decay value (0-99)
//----------------------------------------------------------
// CSOUND function implemented as a BPF
// Corresponds to F6 in the CSOUND implementation.
dx7_egratedecay_bpf = ba.bpf.start(0,318) : seq(i,23,ba.bpf.point(xPoints(i)+1,yPoints(i))) : ba.bpf.end(127,.008)
with{
xPoints(n) = ba.take(n+1,(3,7,12,17,22,27,32,40,43,49,52,55,58,63,66,69,72,75,
78,81,84,87,90));
yPoints(n) = ba.take(n+1,(181,115,63,39.7,20,11.2,7,5.66,3.98,1.99,
1.34,.99,.71,.41,.15,.081,.068,.047,.037,.025,.02,.013,.008));
};
// Function estimated from the CSOUND function (default)
dx7_egratedecay_func = 318*pow((127-_)/127,12.6) : max(0.008);
dx7_egratedecayf = dx7_egratedecay_func;
//----------------------`(dx.)dx7_egratedecaypercf`--------------------------
// DX7 envelope generator percussive decay conversion function. 3 versions of
// this function are available:
//
// * `dx7_egratedecayperc_bpf`: BPF version (same as in the CSOUND toolkit)
// * `dx7_egratedecayperc_func`: estimated mathematical equivalent of `dx7_egratedecayperc_bpf`
// * `dx7_egratedecaypercf`: default (sugar for `dx7_egratedecayperc_func`)
//
// #### Usage:
//
// ```
// dx7envelopePercDecay : dx7_egratedecaypercf : _
// ```
//
// Where:
//
// * `dx7envelopePercDecay`: DX7 envelope decay value (0-99)
//----------------------------------------------------------
// CSOUND function implemented as a BPF
// Corresponds to F7 in the CSOUND implementation.
dx7_egratedecayperc_bpf = ba.bpf.start(0,0.00001) : seq(i,10,ba.bpf.point(xPoints(i),yPoints(i))) : ba.bpf.end(127,1)
with{
xPoints(n) = ba.take(n+1,(10,20,30,40,50,60,70,80,90,99));
yPoints(n) = ba.take(n+1,(0.25,0.35,0.43,0.52,0.59,0.7,0.77,0.84,0.92,1));
};
// Function estimated from the CSOUND function (default)
dx7_egratedecayperc_func = min(99)/99 : pow(_,0.7);
dx7_egratedecaypercf = dx7_egratedecayperc_func;
//----------------------`(dx.)dx7_eglv2peakf`--------------------------
// DX7 envelope level to peak conversion function. 3 versions of
// this function are available:
//
// * `dx7_eglv2peak_bpf`: BPF version (same as in the CSOUND toolkit)
// * `dx7_eglv2peak_func`: estimated mathematical equivalent of `dx7_eglv2peak_bpf`
// * `dx7_eglv2peakf`: default (sugar for `dx7_eglv2peak_func`)
//
// #### Usage:
//
// ```
// dx7Level : dx7_eglv2peakf : _
// ```
//
// Where:
//
// * `dx7Level`: DX7 level value (0-99)
//-----------------------------------------------------------
// CSOUND function implemented as a BPF
// Corresponds to F8 in the CSOUND implementation.
dx7_eglv2peak_bpf = ba.bpf.start(0,0) : seq(i,14,ba.bpf.point(xPoints(i)+1,yPoints(i))) : ba.bpf.end(127,2.08795)
with{
xPoints(n) = ba.take(n+1,(9,19,29,39,49,59,64,59,74,79,84,89,94,98));
yPoints(n) = ba.take(n+1,(0.000477,0.002,0.00493,0.01257,0.02992,0.07098,0.10981,0.16997,0.260855,0.39979,0.61974,0.95954,1.47425,2.08795));
};
// Function estimated from the CSOUND function (default)
dx7_eglv2peak_func = min(98)/98 : pow(_,8) : *(2.08795);
dx7_eglv2peakf = dx7_eglv2peak_func;
//----------------------`(dx.)dx7_velsensf`--------------------------
// DX7 velocity sensitivity conversion function.
//
// #### Usage:
//
// ```
// dx7Velocity : dx7_velsensf : _
// ```
//
// Where:
//
// * `dx7Velocity`: DX7 level value (0-8)
//-----------------------------------------------------------
// Corresponds to F10 in the CSOUND implementation
dx7_velsensf = /(8);
//----------------------`(dx.)dx7_fdbkscalef`--------------------------
// DX7 feedback scaling conversion function.
//
// #### Usage:
//
// ```
// dx7Feedback : dx7_fdbkscalef : _
// ```
//
// Where:
//
// * `dx7Feedback`: DX7 feedback value
//-----------------------------------------------------------
// Corresponds to F11 in the CSOUND implementation
dx7_fdbkscalef = *(0.875);
//------------------------------`(dx.)dx7_op`---------------------------
// DX7 Operator. Implements a phase-modulable sine wave oscillator connected
// to a DX7 envelope generator.
//
// #### Usage:
//
// ```
// dx7_op(freq,phaseMod,outLev,R1,R2,R3,R4,L1,L2,L3,L4,keyVel,rateScale,type,gain,gate) : _
// ```
//
// Where:
//
// * `freq`: frequency of the oscillator
// * `phaseMod`: phase deviation (-1 - 1)
// * `outLev`: preset output level (0-99)
// * `R1`: preset envelope rate 1 (0-99)
// * `R2`: preset envelope rate 2 (0-99)
// * `R3`: preset envelope rate 3 (0-99)
// * `R4`: preset envelope rate 4 (0-99)
// * `L1`: preset envelope level 1 (0-99)
// * `L2`: preset envelope level 2 (0-99)
// * `L3`: preset envelope level 3 (0-99)
// * `L4`: preset envelope level 4 (0-99)
// * `keyVel`: preset key velocity sensitivity (0-99)
// * `rateScale`: preset envelope rate scale
// * `type`: preset operator type
// * `gain`: general gain
// * `gate`: trigger signal
//-----------------------------------------------------------------
dx7_op(freq,phaseMod,outLev,R1,R2,R3,R4,L1,L2,L3,L4,keyVel,rateScale,type,gain,gate) =
(en.dx7envelope(egr1,egr2,egr3,egr4,egl1,egl2,egl3,egl4,gate) : envTable)*sineWave
with{
tablesize = 1 << 16;
// phase modulation, not freq modulation
sineWave = rdtable(tablesize, os.sinwaveform(tablesize), ma.modulo(int(os.phasor(tablesize,freq) + phaseMod*tablesize),tablesize));
amp = outLev/99; // the corresponding "CSOUND table" has just been hardcoded here
// computing levels
vFac = keyVel : dx7_velsensf;
egl1 = L1*amp <: *(1-vFac) + *(vFac*gain);
egl2 = L2*amp <: *(1-vFac) + *(vFac*gain);
egl3 = L3*amp <: *(1-vFac) + *(vFac*gain);
egl4 = L4*amp <: *(1-vFac) + *(vFac*gain);
// computing rates
rs = (freq : ba.hz2midikey)-21 : /(105)*6*rateScale;
egr1 = R1+rs : min(99) <:
select2(egl1>egl4,dx7_egratedecayf,dx7_egraterisef) <:
*(egl4 <: select2(egl1>egl4,dx7_egratedecaypercf,dx7_egraterisepercf)),
*(egl1 <: select2(egl1>egl4,dx7_egratedecaypercf,dx7_egraterisepercf)) :
- : abs : max(0.001);
egr2 = R2+rs : min(99) <:
select2(egl2>egl1,dx7_egratedecayf,dx7_egraterisef) <:
*(egl2 <: select2(egl2>egl1,dx7_egratedecaypercf,dx7_egraterisepercf)),
*(egl1 <: select2(egl2>egl1,dx7_egratedecaypercf,dx7_egraterisepercf)) :
- : abs : max(0.001);
egr3 = R3+rs : min(99) <:
select2(egl3>egl2,dx7_egratedecayf,dx7_egraterisef) <:
*(egl2 <: select2(egl3>egl2,dx7_egratedecaypercf,dx7_egraterisepercf)),
*(egl3 <: select2(egl3>egl2,dx7_egratedecaypercf,dx7_egraterisepercf)) :
- : abs : max(0.001);
egr4 = R4+rs : min(99) <:
select2(egl3<=egl4,dx7_egratedecayf,dx7_egraterisef) <:
*(egl3 <: select2(egl3<=egl4,dx7_egratedecaypercf,dx7_egraterisepercf)),
*(egl4 <: select2(egl3<=egl4,dx7_egratedecaypercf,dx7_egraterisepercf)) :
- : abs : max(0.001);
envTable = _ <: select2(type,dx7_eglv2peakf,dx7_ampf);
};
//------------------------------`(dx.)dx7_algo`---------------------------
// DX7 algorithms. Implements the 32 DX7 algorithms (a quick Google search
// should give your more details on this). Each algorithm uses 6 operators.
//
// #### Usage:
//
// ```
// dx7_algo(algN,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) : _
// ```
//
// Where:
//
// * `algN`: algorithm number (0-31, should be an int...)
// * `egR1`: preset envelope rates 1 (a list of 6 values between 0-99)
// * `egR2`: preset envelope rates 2 (a list of 6 values between 0-99)
// * `egR3`: preset envelope rates 3 (a list of 6 values between 0-99)
// * `egR4`: preset envelope rates 4 (a list of 6 values between 0-99)
// * `egL1`: preset envelope levels 1 (a list of 6 values between 0-99)
// * `egL2`: preset envelope levels 2 (a list of 6 values between 0-99)
// * `egL3`: preset envelope levels 3 (a list of 6 values between 0-99)
// * `egL4`: preset envelope levels 4 (a list of 6 values between 0-99)
// * `outLev`: preset output levels (a list of 6 values between 0-99)
// * `keyVel`: preset key velocity sensitivities (a list of 6 values between 0-99)
// * `ampModSens`: preset amplitude sensitivities (a list of 6 values between 0-99)
// * `opMode`: preset operator mode (a list of 6 values between 0-1)
// * `opFreq`: preset operator frequencies (a list of 6 values between 0-99)
// * `opDetune`: preset operator detuning (a list of 6 values between 0-99)
// * `opRateScale`: preset operator rate scale (a list of 6 values between 0-99)
// * `feedback`: preset operator feedback (a list of 6 values between 0-99)
// * `lfoDelay`: preset LFO delay (a list of 6 values between 0-99)
// * `lfoDepth`: preset LFO depth (a list of 6 values between 0-99)
// * `lfoSpeed`: preset LFO speed (a list of 6 values between 0-99)
// * `freq`: fundamental frequency
// * `gain`: general gain
// * `gate`: trigger signal
//-----------------------------------------------------------------
// Alg 1
// NOTE: the .2 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(0,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2 : op1),(op6~*(feedback*.2) : op5 : op4 : op3) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 2
// NOTE: the .2 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(1,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2~*(feedback*.2) : op1),(op6 : op5 : op4 : op3) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 3
// Note: weird rand and delay implemented in the csound orchestra and not
// really sure why...
dx7_algo(2,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op3 : op2 : op1),(op6~*(feedback) : op5 : op4) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 4
dx7_algo(3,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op3 : op2 : op1),(op6 : op5 : op4)~*(feedback) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 5
// NOTE: the .1 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(4,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2 : op1),(op4 : op3),(op6~*(feedback*.1) : op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 6
dx7_algo(5,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2 : op1),(op4 : op3),(op6 : op5)~*(feedback) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 7
dx7_algo(6,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2 : op1),(op4,(op6~*(feedback) : op5) :> op3) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 8
// NOTE: the .1 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(7,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2 : op1),(op4~*(feedback*.1),(op6 : op5) :> op3) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 9
// NOTE: the .4 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(8,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2~*(feedback*.4) : op1),(op4,(op6 : op5) :> op3) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 10
// NOTE: the .2 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(9,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op5,op6 :> op4),(op3~*(feedback*.2) : op2 : op1) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 11
// NOTE: the .2 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(10,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op5,op6~*(feedback*.2) :> op4),(op3 : op2 : op1) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 12
// NOTE: the .2 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(11,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op4,op5,op6 :> op3),(op2~*(feedback*.2) : op1) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 13
dx7_algo(12,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op4,op5,op6~*(feedback) :> op3),(op2 : op1) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 14
dx7_algo(13,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2 : op1),(op5,op6~*(feedback) :> op4 : op3) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 15
// NOTE: the .4 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(14,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2~*(feedback*.4) : op1),(op5,op6 :> op4 : op3) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 16
dx7_algo(15,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op2,(op4 : op3),(op6~*(feedback) : op5) :> op1
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 17
// NOTE: the .5 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(16,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op2~*(feedback*.5),(op4 : op3),(op6 : op5) :> op1
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 18
dx7_algo(17,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op2,op3~*(feedback),(op6 : op5 : op4) :> op1
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 19
// NOTE: the .4 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(18,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op3 : op2 : op1),(op6~*(feedback*.4) <: op4,op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 20
dx7_algo(19,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op3~*(feedback) <: op1,op2),(op5,op6 :> op4) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 21
dx7_algo(20,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op3~*(feedback) <: op1,op2),(op6 <: op4,op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 22
// NOTE: the .1 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(21,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2 : op1),(op6~*(feedback*.1) <: op3,op4,op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 23
dx7_algo(22,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,(op3 : op2),(op6~*(feedback) <: op4,op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 24
// NOTE: the .6 for feedback was hardcoded in the csound orchestra, not sure why
// we need it
dx7_algo(23,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,op2,(op6~*(feedback*.6) <: op3,op4,op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 25
dx7_algo(24,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,op2,op3,(op6~*(feedback) <: op4,op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 26
dx7_algo(25,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,(op3 : op2),(op5,op6~*(feedback) :> op4) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 27
dx7_algo(26,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,(op3~*(feedback) : op2),(op5,op6 :> op4) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),1,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,_,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 28
dx7_algo(27,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
(op2 : op1),(op5~*(feedback) : op4 : op3),op6 :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),0,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),1,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,_,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 29
dx7_algo(28,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,op2,(op4 : op3),(op6~*(feedback) : op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 30
dx7_algo(29,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,op2,(op5~*(feedback) : op4 : op3),op6 :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),0,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),1,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,_,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),1,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,_,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 31
dx7_algo(30,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,op2,op3,op4,(op6~*(feedback) : op5) :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,_,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),1,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,_,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
// Alg 32
dx7_algo(31,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) =
op1,op2,op3,op4,op5,op6 :> _
with{
op6Freq = select2(opMode(5),opFreq(5)*freq,opFreq(5)) + opDetune(5)/4;
op6 = dx7_op(op6Freq,0,outLevel(5),egR1(5),egR2(5),egR3(5),egR4(5),egL1(5),egL2(5),egL3(5),egL4(5),keyVelSens(5),opRateScale(5),0,gain,gate);
op5Freq = select2(opMode(4),opFreq(4)*freq,opFreq(4)) + opDetune(4)/4;
op5 = dx7_op(op5Freq,0,outLevel(4),egR1(4),egR2(4),egR3(4),egR4(4),egL1(4),egL2(4),egL3(4),egL4(4),keyVelSens(4),opRateScale(4),0,gain,gate);
op4Freq = select2(opMode(3),opFreq(3)*freq,opFreq(3)) + opDetune(3)/4;
op4 = dx7_op(op4Freq,0,outLevel(3),egR1(3),egR2(3),egR3(3),egR4(3),egL1(3),egL2(3),egL3(3),egL4(3),keyVelSens(3),opRateScale(3),0,gain,gate);
op3Freq = select2(opMode(2),opFreq(2)*freq,opFreq(2)) + opDetune(2)/4;
op3 = dx7_op(op3Freq,0,outLevel(2),egR1(2),egR2(2),egR3(2),egR4(2),egL1(2),egL2(2),egL3(2),egL4(2),keyVelSens(2),opRateScale(2),0,gain,gate);
op2Freq = select2(opMode(1),opFreq(1)*freq,opFreq(1)) + opDetune(1)/4;
op2 = dx7_op(op2Freq,0,outLevel(1),egR1(1),egR2(1),egR3(1),egR4(1),egL1(1),egL2(1),egL3(1),egL4(1),keyVelSens(1),opRateScale(1),0,gain,gate);
op1Freq = select2(opMode(0),opFreq(0)*freq,opFreq(0)) + opDetune(0)/4;
op1 = dx7_op(op1Freq,0,outLevel(0),egR1(0),egR2(0),egR3(0),egR4(0),egL1(0),egL2(0),egL3(0),egL4(0),keyVelSens(0),opRateScale(0),0,gain,gate);
};
//------------------------------`(dx.)dx7_ui`---------------------------
// Generic DX7 function where all parameters are controllable using UI elements.
// The `master-with-mute` branch must be used for this function to work...
// This function is MIDI-compatible.
//
// #### Usage
//
// ```
// dx7_ui : _
// ```
//-----------------------------------------------------------------
dx7_ui =
par(i,32,dx7_algo(i,egR1,egR2,egR3,egR4,egL1,egL2,egL3,egL4,outLevel,keyVelSens,ampModSens,opMode,opFreq,opDetune,opRateScale,feedback,lfoDelay,lfoDepth,lfoSpeed,freq,gain,gate) : control(algorithm == i)) :> _
with{
algorithm = nentry("h:dx7/v:global/[0]algorithm",0,0,31,1) : int;
feedback = nentry("h:dx7/v:global/[1]feedback",0,0,99,1) : dx7_fdbkscalef/(2*ma.PI);
lfoDelay = nentry("h:dx7/v:global/[2]lfoDelay",0,0,99,1);