-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathMonstro.cpp
1978 lines (1646 loc) · 76.7 KB
/
Monstro.cpp
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
/*
* Monstro.cpp - a monstrous semi-modular 3-osc synth with modulation matrix
*
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#include <QDomElement>
#include "Monstro.h"
#include "Engine.h"
#include "InstrumentTrack.h"
#include "templates.h"
#include "gui_templates.h"
#include "ToolTip.h"
#include "Song.h"
#include "lmms_math.h"
#include "interpolation.h"
#include "embed.cpp"
extern "C"
{
Plugin::Descriptor PLUGIN_EXPORT monstro_plugin_descriptor =
{
STRINGIFY( PLUGIN_NAME ),
"Monstro",
QT_TRANSLATE_NOOP( "pluginBrowser",
"Monstrous 3-oscillator synth with modulation matrix" ),
"Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>",
0x0100,
Plugin::Instrument,
new PluginPixmapLoader( "logo" ),
NULL,
NULL
} ;
}
MonstroSynth::MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ) :
m_parent( _i ),
m_nph( _nph )
{
m_osc1l_phase = 0.0f;
m_osc1r_phase = 0.0f;
m_osc2l_phase = 0.0f;
m_osc2r_phase = 0.0f;
m_osc3l_phase = 0.0f;
m_osc3r_phase = 0.0f;
m_ph2l_last = 0.0f;
m_ph2r_last = 0.0f;
m_ph3l_last = 0.0f;
m_ph3r_last = 0.0f;
m_env_phase[0] = 0.0f;
m_env_phase[1] = 0.0f;
m_lfo_phase[0] = 0.0f;
m_lfo_phase[1] = 0.0f;
m_lfo_next[0] = Oscillator::noiseSample( 0.0f );
m_lfo_next[1] = Oscillator::noiseSample( 0.0f );
m_osc1l_last = 0.0f;
m_osc1r_last = 0.0f;
m_l_last = 0.0f;
m_r_last = 0.0f;
m_invert2l = false;
m_invert2r = false;
m_invert3l = false;
m_invert3r = false;
m_counter2l = 0;
m_counter2r = 0;
m_counter3l = 0;
m_counter3r = 0;
}
MonstroSynth::~MonstroSynth()
{
}
void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf )
{
float modtmp; // temp variable for freq modulation
// macros for modulating with env/lfos
#define modulatefreq( car, mod ) \
modtmp = 0.0f; \
if( mod##_e1 != 0.0f ) modtmp += env[0][f] * mod##_e1; \
if( mod##_e2 != 0.0f ) modtmp += env[1][f] * mod##_e2; \
if( mod##_l1 != 0.0f ) modtmp += lfo[0][f] * mod##_l1; \
if( mod##_l2 != 0.0f ) modtmp += lfo[1][f] * mod##_l2; \
car = qBound( MIN_FREQ, car * powf( 2.0f, modtmp ), MAX_FREQ );
#define modulateabs( car, mod ) \
if( mod##_e1 != 0.0f ) car += env[0][f] * mod##_e1; \
if( mod##_e2 != 0.0f ) car += env[1][f] * mod##_e2; \
if( mod##_l1 != 0.0f ) car += lfo[0][f] * mod##_l1; \
if( mod##_l2 != 0.0f ) car += lfo[1][f] * mod##_l2;
#define modulatephs( car, mod ) \
if( mod##_e1 != 0.0f ) car += env[0][f] * mod##_e1; \
if( mod##_e2 != 0.0f ) car += env[1][f] * mod##_e2; \
if( mod##_l1 != 0.0f ) car += lfo[0][f] * mod##_l1; \
if( mod##_l2 != 0.0f ) car += lfo[1][f] * mod##_l2;
#define modulatevol( car, mod ) \
if( mod##_e1 > 0.0f ) car *= ( 1.0f - mod##_e1 + mod##_e1 * env[0][f] ); \
if( mod##_e1 < 0.0f ) car *= ( 1.0f + mod##_e1 * env[0][f] ); \
if( mod##_e2 > 0.0f ) car *= ( 1.0f - mod##_e2 + mod##_e2 * env[1][f] ); \
if( mod##_e2 < 0.0f ) car *= ( 1.0f + mod##_e2 * env[1][f] ); \
if( mod##_l1 != 0.0f ) car *= ( 1.0f + mod##_l1 * lfo[0][f] ); \
if( mod##_l2 != 0.0f ) car *= ( 1.0f + mod##_l2 * lfo[1][f] ); \
car = qBound( -MODCLIP, car, MODCLIP );
////////////////////
// //
// MODULATORS //
// //
////////////////////
// LFO phase offsets
const float lfo1_po = m_parent->m_lfo1Phs.value() / 360.0f;
const float lfo2_po = m_parent->m_lfo2Phs.value() / 360.0f;
// remove cruft from phase counters to prevent overflow, add phase offset
m_lfo_phase[0] = absFraction( m_lfo_phase[0] + lfo1_po );
m_lfo_phase[1] = absFraction( m_lfo_phase[1] + lfo2_po );
// LFO rates and increment
m_lfo_rate[0] = ( m_parent->m_lfo1Rate.value() * 0.001f * m_parent->m_samplerate );
m_lfo_rate[1] = ( m_parent->m_lfo2Rate.value() * 0.001f * m_parent->m_samplerate );
m_lfo_inc[0] = 1.0f / m_lfo_rate[0];
m_lfo_inc[1] = 1.0f / m_lfo_rate[1];
m_env_sus[0] = m_parent-> m_env1Sus.value();
m_env_sus[1] = m_parent-> m_env2Sus.value();
m_lfovalue[0] = m_parent->m_lfo1Wave.value();
m_lfovalue[1] = m_parent->m_lfo2Wave.value();
m_lfoatt[0] = m_parent->m_lfo1_att;
m_lfoatt[1] = m_parent->m_lfo2_att;
m_env_pre[0] = m_parent->m_env1_pre;
m_env_att[0] = m_parent->m_env1_att;
m_env_hold[0] = m_parent->m_env1_hold;
m_env_dec[0] = m_parent->m_env1_dec;
m_env_rel[0] = m_parent->m_env1_rel;
m_env_pre[1] = m_parent->m_env2_pre;
m_env_att[1] = m_parent->m_env2_att;
m_env_hold[1] = m_parent->m_env2_hold;
m_env_dec[1] = m_parent->m_env2_dec;
m_env_rel[1] = m_parent->m_env2_rel;
// get updated osc1 values
// get pulse width
const float pw = ( m_parent->m_osc1Pw.value() * 0.01f );
const float o1pw_e1 = ( m_parent->m_pw1env1.value() );
const float o1pw_e2 = ( m_parent->m_pw1env2.value() );
const float o1pw_l1 = ( m_parent->m_pw1lfo1.value() * 0.5f );
const float o1pw_l2 = ( m_parent->m_pw1lfo2.value() * 0.5f );
const bool o1pw_mod = o1pw_e1 != 0.0f || o1pw_e2 != 0.0f || o1pw_l1 != 0.0f || o1pw_l2 != 0.0f;
// get phases
const float o1lpo = m_parent->m_osc1l_po;
const float o1rpo = m_parent->m_osc1r_po;
const float o1p_e1 = ( m_parent->m_phs1env1.value() );
const float o1p_e2 = ( m_parent->m_phs1env2.value() );
const float o1p_l1 = ( m_parent->m_phs1lfo1.value() * 0.5f );
const float o1p_l2 = ( m_parent->m_phs1lfo2.value() * 0.5f );
const bool o1p_mod = o1p_e1 != 0.0f || o1p_e2 != 0.0f || o1p_l1 != 0.0f || o1p_l2 != 0.0f;
// get pitch
const float o1lfb = ( m_parent->m_osc1l_freq * m_nph->frequency() );
const float o1rfb = ( m_parent->m_osc1r_freq * m_nph->frequency() );
const float o1f_e1 = ( m_parent->m_pit1env1.value() * 2.0f );
const float o1f_e2 = ( m_parent->m_pit1env2.value() * 2.0f );
const float o1f_l1 = ( m_parent->m_pit1lfo1.value() );
const float o1f_l2 = ( m_parent->m_pit1lfo2.value() );
const bool o1f_mod = o1f_e1 != 0.0f || o1f_e2 != 0.0f || o1f_l1 != 0.0f || o1f_l2 != 0.0f;
// get volumes
const float o1lv = m_parent->m_osc1l_vol;
const float o1rv = m_parent->m_osc1r_vol;
const float o1v_e1 = ( m_parent->m_vol1env1.value() );
const float o1v_e2 = ( m_parent->m_vol1env2.value() );
const float o1v_l1 = ( m_parent->m_vol1lfo1.value() );
const float o1v_l2 = ( m_parent->m_vol1lfo2.value() );
const bool o1v_mod = o1v_e1 != 0.0f || o1v_e2 != 0.0f || o1v_l1 != 0.0f || o1v_l2 != 0.0f;
// update osc2
// get waveform
const int o2w = m_parent->m_osc2Wave.value();
// get phases
const float o2lpo = m_parent->m_osc2l_po;
const float o2rpo = m_parent->m_osc2r_po;
const float o2p_e1 = ( m_parent->m_phs2env1.value() );
const float o2p_e2 = ( m_parent->m_phs2env2.value() );
const float o2p_l1 = ( m_parent->m_phs2lfo1.value() * 0.5f );
const float o2p_l2 = ( m_parent->m_phs2lfo2.value() * 0.5f );
const bool o2p_mod = o2p_e1 != 0.0f || o2p_e2 != 0.0f || o2p_l1 != 0.0f || o2p_l2 != 0.0f;
// get pitch
const float o2lfb = ( m_parent->m_osc2l_freq * m_nph->frequency() );
const float o2rfb = ( m_parent->m_osc2r_freq * m_nph->frequency() );
const float o2f_e1 = ( m_parent->m_pit2env1.value() * 2.0f );
const float o2f_e2 = ( m_parent->m_pit2env2.value() * 2.0f );
const float o2f_l1 = ( m_parent->m_pit2lfo1.value() );
const float o2f_l2 = ( m_parent->m_pit2lfo2.value() );
const bool o2f_mod = o2f_e1 != 0.0f || o2f_e2 != 0.0f || o2f_l1 != 0.0f || o2f_l2 != 0.0f;
// get volumes
const float o2lv = m_parent->m_osc2l_vol;
const float o2rv = m_parent->m_osc2r_vol;
const float o2v_e1 = ( m_parent->m_vol2env1.value() );
const float o2v_e2 = ( m_parent->m_vol2env2.value() );
const float o2v_l1 = ( m_parent->m_vol2lfo1.value() );
const float o2v_l2 = ( m_parent->m_vol2lfo2.value() );
const bool o2v_mod = o2v_e1 != 0.0f || o2v_e2 != 0.0f || o2v_l1 != 0.0f || o2v_l2 != 0.0f;
// update osc3
// get waveforms
const int o3w1 = m_parent->m_osc3Wave1.value();
const int o3w2 = m_parent->m_osc3Wave2.value();
// get phases
const float o3lpo = m_parent->m_osc3l_po;
const float o3rpo = m_parent->m_osc3r_po;
const float o3p_e1 = ( m_parent->m_phs3env1.value() );
const float o3p_e2 = ( m_parent->m_phs3env2.value() );
const float o3p_l1 = ( m_parent->m_phs3lfo1.value() * 0.5f );
const float o3p_l2 = ( m_parent->m_phs3lfo2.value() * 0.5f );
const bool o3p_mod = o3p_e1 != 0.0f || o3p_e2 != 0.0f || o3p_l1 != 0.0f || o3p_l2 != 0.0f;
// get pitch modulators
const float o3fb = ( m_parent->m_osc3_freq * m_nph->frequency() );
const float o3f_e1 = ( m_parent->m_pit3env1.value() * 2.0f );
const float o3f_e2 = ( m_parent->m_pit3env2.value() * 2.0f );
const float o3f_l1 = ( m_parent->m_pit3lfo1.value() );
const float o3f_l2 = ( m_parent->m_pit3lfo2.value() );
const bool o3f_mod = o3f_e1 != 0.0f || o3f_e2 != 0.0f || o3f_l1 != 0.0f || o3f_l2 != 0.0f;
// get volumes
const float o3lv = m_parent->m_osc3l_vol;
const float o3rv = m_parent->m_osc3r_vol;
const float o3v_e1 = ( m_parent->m_vol3env1.value() );
const float o3v_e2 = ( m_parent->m_vol3env2.value() );
const float o3v_l1 = ( m_parent->m_vol3lfo1.value() );
const float o3v_l2 = ( m_parent->m_vol3lfo2.value() );
const bool o3v_mod = o3v_e1 != 0.0f || o3v_e2 != 0.0f || o3v_l1 != 0.0f || o3v_l2 != 0.0f;
// get sub
const float o3sub = ( m_parent->m_osc3Sub.value() + 100.0f ) / 200.0f;
const float o3s_e1 = ( m_parent->m_sub3env1.value() );
const float o3s_e2 = ( m_parent->m_sub3env2.value() );
const float o3s_l1 = ( m_parent->m_sub3lfo1.value() * 0.5f );
const float o3s_l2 = ( m_parent->m_sub3lfo2.value() * 0.5f );
const bool o3s_mod = o3s_e1 != 0.0f || o3s_e2 != 0.0f || o3s_l1 != 0.0f || o3s_l2 != 0.0f;
//o2-o3 modulation
const int omod = m_parent->m_o23Mod.value();
// sync information
const bool o1ssr = m_parent->m_osc1SSR.value();
const bool o1ssf = m_parent->m_osc1SSF.value();
const bool o2sync = m_parent->m_osc2SyncH.value();
const bool o3sync = m_parent->m_osc3SyncH.value();
const bool o2syncr = m_parent->m_osc2SyncR.value();
const bool o3syncr = m_parent->m_osc3SyncR.value();
///////////////////////////
// //
// start buffer loop //
// //
///////////////////////////
// declare working variables for for loop
// phase manipulation vars - these can be reused by all oscs
float leftph;
float rightph;
float pd_l;
float pd_r;
float len_l;
float len_r;
// osc1 vars
float o1l_f;
float o1r_f;
float o1l_p = m_osc1l_phase + o1lpo; // we add phase offset here so we don't have to do it every frame
float o1r_p = m_osc1r_phase + o1rpo; // then substract it again after loop...
float o1_pw;
// osc2 vars
float o2l_f;
float o2r_f;
float o2l_p = m_osc2l_phase + o2lpo;
float o2r_p = m_osc2r_phase + o2rpo;
// osc3 vars
float o3l_f;
float o3r_f;
float o3l_p = m_osc3l_phase + o3lpo;
float o3r_p = m_osc3r_phase + o3rpo;
float sub;
// modulators
float lfo[2][ m_parent->m_fpp ];
float env[2][ m_parent->m_fpp ];
// render modulators: envelopes, lfos
updateModulators( &env[0][0], &env[1][0], &lfo[0][0], &lfo[1][0], _frames );
// begin for loop
for( f_cnt_t f = 0; f < _frames; ++f )
{
/* // debug code
if( f % 10 == 0 ) {
qDebug( "env1 %f -- env1 phase %f", m_env1_buf[f], m_env1_phase );
qDebug( "env1 pre %f att %f dec %f rel %f ", m_parent->m_env1_pre, m_parent->m_env1_att,
m_parent->m_env1_dec, m_parent->m_env1_rel );
}*/
/////////////////////////////
// //
// OSC 1 //
// //
/////////////////////////////
// calc and mod frequencies
o1l_f = o1lfb;
o1r_f = o1rfb;
if( o1f_mod )
{
modulatefreq( o1l_f, o1f )
modulatefreq( o1r_f, o1f )
}
// calc and modulate pulse
o1_pw = pw;
if( o1pw_mod )
{
modulateabs( o1_pw, o1pw )
o1_pw = qBound( PW_MIN, o1_pw, PW_MAX );
}
// calc and modulate phase
leftph = o1l_p;
rightph = o1r_p;
if( o1p_mod )
{
modulatephs( leftph, o1p )
modulatephs( rightph, o1p )
}
// pulse wave osc
sample_t O1L = ( absFraction( leftph ) < o1_pw ) ? 1.0f : -1.0f;
sample_t O1R = ( absFraction( rightph ) < o1_pw ) ? 1.0f : -1.0f;
// check for rise/fall, and sync if appropriate
// sync on rise
if( o1ssr )
{
// hard sync
if( o2sync )
{
if( O1L > m_osc1l_last ) { o2l_p = o2lpo; m_counter2l = m_parent->m_counterMax; }
if( O1R > m_osc1r_last ) { o2r_p = o2rpo; m_counter2r = m_parent->m_counterMax; }
}
if( o3sync )
{
if( O1L > m_osc1l_last ) { o3l_p = o3lpo; m_counter3l = m_parent->m_counterMax; }
if( O1R > m_osc1r_last ) { o3r_p = o3rpo; m_counter3r = m_parent->m_counterMax; }
}
// reverse sync
if( o2syncr )
{
if( O1L > m_osc1l_last ) { m_invert2l = !m_invert2l; m_counter2l = m_parent->m_counterMax; }
if( O1R > m_osc1r_last ) { m_invert2r = !m_invert2r; m_counter2r = m_parent->m_counterMax; }
}
if( o3syncr )
{
if( O1L > m_osc1l_last ) { m_invert3l = !m_invert3l; m_counter3l = m_parent->m_counterMax; }
if( O1R > m_osc1r_last ) { m_invert3r = !m_invert3r; m_counter3r = m_parent->m_counterMax; }
}
}
// sync on fall
if( o1ssf )
{
// hard sync
if( o2sync )
{
if( O1L < m_osc1l_last ) { o2l_p = o2lpo; m_counter2l = m_parent->m_counterMax; }
if( O1R < m_osc1r_last ) { o2r_p = o2rpo; m_counter2r = m_parent->m_counterMax; }
}
if( o3sync )
{
if( O1L < m_osc1l_last ) { o3l_p = o3lpo; m_counter3l = m_parent->m_counterMax; }
if( O1R < m_osc1r_last ) { o3r_p = o3rpo; m_counter3r = m_parent->m_counterMax; }
}
// reverse sync
if( o2syncr )
{
if( O1L < m_osc1l_last ) { m_invert2l = !m_invert2l; m_counter2l = m_parent->m_counterMax; }
if( O1R < m_osc1r_last ) { m_invert2r = !m_invert2r; m_counter2r = m_parent->m_counterMax; }
}
if( o3syncr )
{
if( O1L < m_osc1l_last ) { m_invert3l = !m_invert3l; m_counter3l = m_parent->m_counterMax; }
if( O1R < m_osc1r_last ) { m_invert3r = !m_invert3r; m_counter3r = m_parent->m_counterMax; }
}
}
// update last before signal is touched
// also do a very simple amp delta cap
const sample_t tmpl = m_osc1l_last;
const sample_t tmpr = m_osc1r_last;
m_osc1l_last = O1L;
m_osc1r_last = O1R;
if( tmpl != O1L ) O1L = 0.0f;
if( tmpr != O1R ) O1R = 0.0f;
// modulate volume
O1L *= o1lv;
O1R *= o1rv;
if( o1v_mod )
{
modulatevol( O1L, o1v )
modulatevol( O1R, o1v )
}
// update osc1 phase working variable
o1l_p += 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o1l_f );
o1r_p += 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o1r_f );
/////////////////////////////
// //
// OSC 2 //
// //
/////////////////////////////
// calc and mod frequencies
o2l_f = o2lfb;
o2r_f = o2rfb;
if( o2f_mod )
{
modulatefreq( o2l_f, o2f )
modulatefreq( o2r_f, o2f )
}
// calc and modulate phase
leftph = o2l_p;
rightph = o2r_p;
if( o2p_mod )
{
modulatephs( leftph, o2p )
modulatephs( rightph, o2p )
}
leftph = absFraction( leftph );
rightph = absFraction( rightph );
// phase delta
pd_l = qAbs( leftph - m_ph2l_last );
if( pd_l > 0.5 ) pd_l = 1.0 - pd_l;
pd_r = qAbs( rightph - m_ph2r_last );
if( pd_r > 0.5 ) pd_r = 1.0 - pd_r;
// multi-wave DC Oscillator
len_l = BandLimitedWave::pdToLen( pd_l );
len_r = BandLimitedWave::pdToLen( pd_r );
if( m_counter2l > 0 ) { len_l /= m_counter2l; m_counter2l--; }
if( m_counter2r > 0 ) { len_r /= m_counter2r; m_counter2r--; }
sample_t O2L = oscillate( o2w, leftph, len_l );
sample_t O2R = oscillate( o2w, rightph, len_r );
// modulate volume
O2L *= o2lv;
O2R *= o2rv;
if( o2v_mod )
{
modulatevol( O2L, o2v )
modulatevol( O2R, o2v )
}
// reverse sync - invert waveforms when needed
if( m_invert2l ) O2L *= -1.0;
if( m_invert2r ) O2R *= -1.0;
// update osc2 phases
m_ph2l_last = leftph;
m_ph2r_last = rightph;
o2l_p += 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o2l_f );
o2r_p += 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o2r_f );
/////////////////////////////
// //
// OSC 3 //
// //
/////////////////////////////
// calc and mod frequencies
o3l_f = o3fb;
o3r_f = o3fb;
if( o3f_mod )
{
modulatefreq( o3l_f, o3f )
modulatefreq( o3r_f, o3f )
}
// calc and modulate phase
leftph = o3l_p;
rightph = o3r_p;
if( o3p_mod )
{
modulatephs( leftph, o3p )
modulatephs( rightph, o3p )
}
// o2 modulation?
if( omod == MOD_PM )
{
leftph += O2L * 0.5f;
rightph += O2R * 0.5f;
}
leftph = absFraction( leftph );
rightph = absFraction( rightph );
// phase delta
pd_l = qAbs( leftph - m_ph3l_last );
if( pd_l > 0.5 ) pd_l = 1.0 - pd_l;
pd_r = qAbs( rightph - m_ph3r_last );
if( pd_r > 0.5 ) pd_r = 1.0 - pd_r;
// multi-wave DC Oscillator
len_l = BandLimitedWave::pdToLen( pd_l );
len_r = BandLimitedWave::pdToLen( pd_r );
if( m_counter3l > 0 ) { len_l /= m_counter3l; m_counter3l--; }
if( m_counter3r > 0 ) { len_r /= m_counter3r; m_counter3r--; }
// sub-osc 1
sample_t O3AL = oscillate( o3w1, leftph, len_l );
sample_t O3AR = oscillate( o3w1, rightph, len_r );
// multi-wave DC Oscillator, sub-osc 2
sample_t O3BL = oscillate( o3w2, leftph, len_l );
sample_t O3BR = oscillate( o3w2, rightph, len_r );
// calc and modulate sub
sub = o3sub;
if( o3s_mod )
{
modulateabs( sub, o3s )
sub = qBound( 0.0f, sub, 1.0f );
}
sample_t O3L = linearInterpolate( O3AL, O3BL, sub );
sample_t O3R = linearInterpolate( O3AR, O3BR, sub );
// modulate volume
O3L *= o3lv;
O3R *= o3rv;
if( o3v_mod )
{
modulatevol( O3L, o3v )
modulatevol( O3R, o3v )
}
// o2 modulation?
if( omod == MOD_AM )
{
O3L = qBound( -MODCLIP, O3L * qMax( 0.0f, 1.0f + O2L ), MODCLIP );
O3R = qBound( -MODCLIP, O3R * qMax( 0.0f, 1.0f + O2R ), MODCLIP );
}
// reverse sync - invert waveforms when needed
if( m_invert3l ) O3L *= -1.0;
if( m_invert3r ) O3R *= -1.0;
// update osc3 phases
m_ph3l_last = leftph;
m_ph3r_last = rightph;
len_l = 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o3l_f );
len_r = 1.0f / ( static_cast<float>( m_parent->m_samplerate ) / o3r_f );
// handle FM as PM
if( omod == MOD_FM )
{
len_l += O2L * m_parent->m_fmCorrection;
len_r += O2R * m_parent->m_fmCorrection;
}
o3l_p += len_l;
o3r_p += len_r;
// integrator - very simple filter
sample_t L = O1L + O3L + ( omod == MOD_MIX ? O2L : 0.0f );
sample_t R = O1R + O3R + ( omod == MOD_MIX ? O2R : 0.0f );
_buf[f][0] = linearInterpolate( L, m_l_last, m_parent->m_integrator );
_buf[f][1] = linearInterpolate( R, m_r_last, m_parent->m_integrator );
m_l_last = L;
m_r_last = R;
}
// update phases
m_osc1l_phase = absFraction( o1l_p - o1lpo );
m_osc1r_phase = absFraction( o1r_p - o1rpo );
m_osc2l_phase = absFraction( o2l_p - o2lpo );
m_osc2r_phase = absFraction( o2r_p - o2rpo );
m_osc3l_phase = absFraction( o3l_p - o3lpo );
m_osc3r_phase = absFraction( o3r_p - o3rpo );
m_lfo_phase[0] = absFraction( m_lfo_phase[0] - lfo1_po );
m_lfo_phase[1] = absFraction( m_lfo_phase[1] - lfo2_po );
}
inline void MonstroSynth::updateModulators( float * env1, float * env2, float * lfo1, float * lfo2, int frames )
{
// frames played before
const f_cnt_t tfp = m_nph->totalFramesPlayed();
float * lfo [2];
float * env [2];
lfo[0] = lfo1;
lfo[1] = lfo2;
env[0] = env1;
env[1] = env2;
for( int i = 0; i < 2; ++i )
{
switch( m_lfovalue[i] )
{
case WAVE_SINE:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = Oscillator::sinSample( m_lfo_phase[i] );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_TRI:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = Oscillator::triangleSample( m_lfo_phase[i] );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_SAW:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = Oscillator::sawSample( m_lfo_phase[i] );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_RAMP:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = Oscillator::sawSample( m_lfo_phase[i] ) * -1.0f;
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_SQR:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = Oscillator::squareSample( m_lfo_phase[i] );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_SQRSOFT:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = oscillate( WAVE_SQRSOFT, m_lfo_phase[i], 0 );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_MOOG:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = Oscillator::moogSawSample( m_lfo_phase[i] );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_SINABS:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = oscillate( WAVE_SINABS, m_lfo_phase[i], 0 );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_EXP:
for( f_cnt_t f = 0; f < frames; ++f )
{
lfo[i][f] = Oscillator::expSample( m_lfo_phase[i] );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_RANDOM:
for( f_cnt_t f = 0; f < frames; ++f )
{
if( ( tfp + f ) % static_cast<int>( m_lfo_rate[i] ) == 0 ) m_lfo_last[i] = Oscillator::noiseSample( 0.0f );
lfo[i][f] = m_lfo_last[i];
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
case WAVE_RANDOM_SMOOTH:
for( f_cnt_t f = 0; f < frames; ++f )
{
const f_cnt_t tm = ( tfp + f ) % static_cast<int>( m_lfo_rate[i] );
if( tm == 0 )
{
m_lfo_last[i] = m_lfo_next[i];
m_lfo_next[i] = Oscillator::noiseSample( 0.0f );
}
lfo[i][f] = cosinusInterpolate( m_lfo_last[i], m_lfo_next[i], static_cast<float>( tm ) / m_lfo_rate[i] );
m_lfo_phase[i] += m_lfo_inc[i];
}
break;
}
// attack
for( f_cnt_t f = 0; f < frames; ++f )
{
if( tfp + f < m_lfoatt[i] ) lfo[i][f] *= ( static_cast<sample_t>( tfp ) / m_lfoatt[i] );
}
/////////////////////////////////////////////
// //
// //
// envelopes //
// //
// //
/////////////////////////////////////////////
for( f_cnt_t f = 0; f < frames; ++f )
{
if( m_env_phase[i] < 4.0f && m_nph->isReleased() && f >= m_nph->framesBeforeRelease() )
{
if( m_env_phase[i] < 1.0f ) m_env_phase[i] = 5.0f;
else if( m_env_phase[i] < 2.0f ) m_env_phase[i] = 5.0f - fraction( m_env_phase[i] );
else if( m_env_phase[i] < 3.0f ) m_env_phase[i] = 4.0f;
else m_env_phase[i] = 4.0f + fraction( m_env_phase[i] );
}
// process envelope
if( m_env_phase[i] < 1.0f ) // pre-delay phase
{
env[i][f] = 0.0f;
m_env_phase[i] = qMin( 1.0f, m_env_phase[i] + m_env_pre[i] );
}
else if( m_env_phase[i] < 2.0f ) // attack phase
{
env[i][f] = calcSlope( i, fraction( m_env_phase[i] ) );
m_env_phase[i] = qMin( 2.0f, m_env_phase[i] + m_env_att[i] );
}
else if( m_env_phase[i] < 3.0f ) // hold phase
{
env[i][f] = 1.0f;
m_env_phase[i] = qMin( 3.0f, m_env_phase[i] + m_env_hold[i] );
}
else if( m_env_phase[i] < 4.0f ) // decay phase
{
const sample_t s = calcSlope( i, 1.0f - fraction( m_env_phase[i] ) );
if( s <= m_env_sus[i] )
{
env[i][f] = m_env_sus[i];
}
else
{
env[i][f] = s;
m_env_phase[i] = qMin( 4.0f - m_env_sus[i], m_env_phase[i] + m_env_dec[i] );
if( m_env_phase[i] == 4.0f ) m_env_phase[i] = 5.0f; // jump over release if sustain is zero - fix for clicking
}
}
else if( m_env_phase[i] < 5.0f ) // release phase
{
env[i][f] = calcSlope( i, 1.0f - fraction( m_env_phase[i] ) );
m_env_phase[i] += m_env_rel[i];
}
else env[i][f] = 0.0f;
}
}
}
inline sample_t MonstroSynth::calcSlope( int slope, sample_t s )
{
if( m_parent->m_slope[slope] == 1.0f ) return s;
if( s == 0.0f ) return s;
return fastPow( s, m_parent->m_slope[slope] );
}
MonstroInstrument::MonstroInstrument( InstrumentTrack * _instrument_track ) :
Instrument( _instrument_track, &monstro_plugin_descriptor ),
m_osc1Vol( 33.0, 0.0, 200.0, 0.1, this, tr( "Osc 1 Volume" ) ),
m_osc1Pan( 0.0, -100.0, 100.0, 0.1, this, tr( "Osc 1 Panning" ) ),
m_osc1Crs( 0.0, -24.0, 24.0, 1.0, this, tr( "Osc 1 Coarse detune" ) ),
m_osc1Ftl( 0.0, -100.0, 100.0, 1.0, this, tr( "Osc 1 Fine detune left" ) ),
m_osc1Ftr( 0.0, -100.0, 100.0, 1.0, this, tr( "Osc 1 Fine detune right" ) ),
m_osc1Spo( 0.0, -180.0, 180.0, 0.1, this, tr( "Osc 1 Stereo phase offset" ) ),
m_osc1Pw( 50.0, PW_MIN, PW_MAX, 0.01, this, tr( "Osc 1 Pulse width" ) ),
m_osc1SSR( false, this, tr( "Osc 1 Sync send on rise" ) ),
m_osc1SSF( false, this, tr( "Osc 1 Sync send on fall" ) ),
m_osc2Vol( 33.0, 0.0, 200.0, 0.1, this, tr( "Osc 2 Volume" ) ),
m_osc2Pan( 0.0, -100.0, 100.0, 0.1, this, tr( "Osc 2 Panning" ) ),
m_osc2Crs( 0.0, -24.0, 24.0, 1.0, this, tr( "Osc 2 Coarse detune" ) ),
m_osc2Ftl( 0.0, -100.0, 100.0, 1.0, this, tr( "Osc 2 Fine detune left" ) ),
m_osc2Ftr( 0.0, -100.0, 100.0, 1.0, this, tr( "Osc 2 Fine detune right" ) ),
m_osc2Spo( 0.0, -180.0, 180.0, 0.1, this, tr( "Osc 2 Stereo phase offset" ) ),
m_osc2Wave( this, tr( "Osc 2 Waveform" ) ),
m_osc2SyncH( false, this, tr( "Osc 2 Sync Hard" ) ),
m_osc2SyncR( false, this, tr( "Osc 2 Sync Reverse" ) ),
m_osc3Vol( 33.0, 0.0, 200.0, 0.1, this, tr( "Osc 3 Volume" ) ),
m_osc3Pan( 0.0, -100.0, 100.0, 0.1, this, tr( "Osc 3 Panning" ) ),
m_osc3Crs( 0.0, -24.0, 24.0, 1.0, this, tr( "Osc 3 Coarse detune" ) ),
m_osc3Spo( 0.0, -180.0, 180.0, 0.1, this, tr( "Osc 3 Stereo phase offset" ) ),
m_osc3Sub( 0.0, -100.0, 100.0, 0.1, this, tr( "Osc 3 Sub-oscillator mix" ) ),
m_osc3Wave1( this, tr( "Osc 3 Waveform 1" ) ),
m_osc3Wave2( this, tr( "Osc 3 Waveform 2" ) ),
m_osc3SyncH( false, this, tr( "Osc 3 Sync Hard" ) ),
m_osc3SyncR( false, this, tr( "Osc 3 Sync Reverse" ) ),
m_lfo1Wave( this, tr( "LFO 1 Waveform" ) ),
m_lfo1Att( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "LFO 1 Attack" ) ),
m_lfo1Rate( 1.0f, 0.1, 10000.0, 0.1, 10000.0f, this, tr( "LFO 1 Rate" ) ),
m_lfo1Phs( 0.0, -180.0, 180.0, 0.1, this, tr( "LFO 1 Phase" ) ),
m_lfo2Wave( this, tr( "LFO 2 Waveform" ) ),
m_lfo2Att( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "LFO 2 Attack" ) ),
m_lfo2Rate( 1.0f, 0.1, 10000.0, 0.1, 10000.0f, this, tr( "LFO 2 Rate" ) ),
m_lfo2Phs( 0.0, -180.0, 180.0, 0.1, this, tr( "LFO 2 Phase" ) ),
m_env1Pre( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "Env 1 Pre-delay" ) ),
m_env1Att( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "Env 1 Attack" ) ),
m_env1Hold( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 1 Hold" ) ),
m_env1Dec( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 1 Decay" ) ),
m_env1Sus( 1.0f, 0.0f, 1.0f, 0.001f, this, tr( "Env 1 Sustain" ) ),
m_env1Rel( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 1 Release" ) ),
m_env1Slope( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Env 1 Slope" ) ),
m_env2Pre( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "Env 2 Pre-delay" ) ),
m_env2Att( 0.0f, 0.0f, 2000.0f, 1.0f, 2000.0f, this, tr( "Env 2 Attack" ) ),
m_env2Hold( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 2 Hold" ) ),
m_env2Dec( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 2 Decay" ) ),
m_env2Sus( 1.0f, 0.0f, 1.0f, 0.001f, this, tr( "Env 2 Sustain" ) ),
m_env2Rel( 0.0f, 0.0f, 4000.0f, 1.0f, 4000.0f, this, tr( "Env 2 Release" ) ),
m_env2Slope( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Env 2 Slope" ) ),
m_o23Mod( 0, 0, NUM_MODS - 1, this, tr( "Osc2-3 modulation" ) ),
m_selectedView( 0, 0, 1, this, tr( "Selected view" ) ),
m_vol1env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol1-Env1" ) ),
m_vol1env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol1-Env2" ) ),
m_vol1lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol1-LFO1" ) ),
m_vol1lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol1-LFO2" ) ),
m_vol2env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol2-Env1" ) ),
m_vol2env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol2-Env2" ) ),
m_vol2lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol2-LFO1" ) ),
m_vol2lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol2-LFO2" ) ),
m_vol3env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol3-Env1" ) ),
m_vol3env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol3-Env2" ) ),
m_vol3lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol3-LFO1" ) ),
m_vol3lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Vol3-LFO2" ) ),
m_phs1env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs1-Env1" ) ),
m_phs1env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs1-Env2" ) ),
m_phs1lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs1-LFO1" ) ),
m_phs1lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs1-LFO2" ) ),
m_phs2env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs2-Env1" ) ),
m_phs2env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs2-Env2" ) ),
m_phs2lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs2-LFO1" ) ),
m_phs2lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs2-LFO2" ) ),
m_phs3env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs3-Env1" ) ),
m_phs3env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs3-Env2" ) ),
m_phs3lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs3-LFO1" ) ),
m_phs3lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Phs3-LFO2" ) ),
m_pit1env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit1-Env1" ) ),
m_pit1env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit1-Env2" ) ),
m_pit1lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit1-LFO1" ) ),
m_pit1lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit1-LFO2" ) ),
m_pit2env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit2-Env1" ) ),
m_pit2env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit2-Env2" ) ),
m_pit2lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit2-LFO1" ) ),
m_pit2lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit2-LFO2" ) ),
m_pit3env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit3-Env1" ) ),
m_pit3env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit3-Env2" ) ),
m_pit3lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit3-LFO1" ) ),
m_pit3lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Pit3-LFO2" ) ),
m_pw1env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "PW1-Env1" ) ),
m_pw1env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "PW1-Env2" ) ),
m_pw1lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "PW1-LFO1" ) ),
m_pw1lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "PW1-LFO2" ) ),
m_sub3env1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Sub3-Env1" ) ),
m_sub3env2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Sub3-Env2" ) ),
m_sub3lfo1( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Sub3-LFO1" ) ),
m_sub3lfo2( 0.0f, -1.0f, 1.0f, 0.001f, this, tr( "Sub3-LFO2" ) )
{
// setup waveboxes
setwavemodel( m_osc2Wave )
setwavemodel( m_osc3Wave1 )
setwavemodel( m_osc3Wave2 )
setlfowavemodel( m_lfo1Wave )
setlfowavemodel( m_lfo2Wave )
// make connections:
// updateVolumes
connect( &m_osc1Vol, SIGNAL( dataChanged() ), this, SLOT( updateVolume1() ) );
connect( &m_osc1Pan, SIGNAL( dataChanged() ), this, SLOT( updateVolume1() ) );
connect( &m_osc2Vol, SIGNAL( dataChanged() ), this, SLOT( updateVolume2() ) );
connect( &m_osc2Pan, SIGNAL( dataChanged() ), this, SLOT( updateVolume2() ) );
connect( &m_osc3Vol, SIGNAL( dataChanged() ), this, SLOT( updateVolume3() ) );
connect( &m_osc3Pan, SIGNAL( dataChanged() ), this, SLOT( updateVolume3() ) );
// updateFreq
connect( &m_osc1Crs, SIGNAL( dataChanged() ), this, SLOT( updateFreq1() ) );
connect( &m_osc2Crs, SIGNAL( dataChanged() ), this, SLOT( updateFreq2() ) );
connect( &m_osc3Crs, SIGNAL( dataChanged() ), this, SLOT( updateFreq3() ) );
connect( &m_osc1Ftl, SIGNAL( dataChanged() ), this, SLOT( updateFreq1() ) );
connect( &m_osc2Ftl, SIGNAL( dataChanged() ), this, SLOT( updateFreq2() ) );
connect( &m_osc1Ftr, SIGNAL( dataChanged() ), this, SLOT( updateFreq1() ) );
connect( &m_osc2Ftr, SIGNAL( dataChanged() ), this, SLOT( updateFreq2() ) );
// updatePO
connect( &m_osc1Spo, SIGNAL( dataChanged() ), this, SLOT( updatePO1() ) );
connect( &m_osc2Spo, SIGNAL( dataChanged() ), this, SLOT( updatePO2() ) );
connect( &m_osc3Spo, SIGNAL( dataChanged() ), this, SLOT( updatePO3() ) );
// updateEnvelope1
connect( &m_env1Pre, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ) );
connect( &m_env1Att, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ) );
connect( &m_env1Hold, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ) );
connect( &m_env1Dec, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ) );
connect( &m_env1Rel, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope1() ) );
connect( &m_env1Slope, SIGNAL( dataChanged() ), this, SLOT( updateSlope1() ) );
// updateEnvelope2
connect( &m_env2Pre, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ) );
connect( &m_env2Att, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ) );
connect( &m_env2Hold, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ) );
connect( &m_env2Dec, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ) );
connect( &m_env2Rel, SIGNAL( dataChanged() ), this, SLOT( updateEnvelope2() ) );
connect( &m_env2Slope, SIGNAL( dataChanged() ), this, SLOT( updateSlope2() ) );