aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/MacVST/BassDrive/source/BassDriveProc.cpp
blob: 3e199ea5973a716ad028026565e10220f1b49d8d (plain) (blame)
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
/* ========================================
 *  BassDrive - BassDrive.h
 *  Copyright (c) 2016 airwindows, All rights reserved
 * ======================================== */

#ifndef __BassDrive_H
#include "BassDrive.h"
#endif

void BassDrive::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) 
{
    float* in1  =  inputs[0];
    float* in2  =  inputs[1];
    float* out1 = outputs[0];
    float* out2 = outputs[1];

	double sumL;
	double sumR;
	double presence = pow(A,5) * 8.0;
	double high = pow(B,3) * 4.0;
	double mid = pow(C,2);
	double low = D / 4.0;
	double drive = E * 2.0;
	double bridgerectifier;
	
    while (--sampleFrames >= 0)
    {
		long double inputSampleL = *in1;
		long double inputSampleR = *in2;
		if (fabs(inputSampleL)<1.18e-37) inputSampleL = fpd * 1.18e-37;
		if (fabs(inputSampleR)<1.18e-37) inputSampleR = fpd * 1.18e-37;
		
		sumL = 0.0;
		sumR = 0.0;
		
		
		if (flip)
		{
			presenceInAL[0] = presenceInAL[1]; presenceInAL[1] = presenceInAL[2]; presenceInAL[2] = presenceInAL[3];
			presenceInAL[3] = presenceInAL[4]; presenceInAL[4] = presenceInAL[5]; presenceInAL[5] = presenceInAL[6]; 
			presenceInAL[6] = inputSampleL * presence; presenceOutAL[2] = presenceOutAL[3];
			presenceOutAL[3] = presenceOutAL[4]; presenceOutAL[4] = presenceOutAL[5]; presenceOutAL[5] = presenceOutAL[6]; 
			presenceOutAL[6] = (presenceInAL[0] + presenceInAL[6]) + 1.9152966321 * (presenceInAL[1] + presenceInAL[5]) 
			- (presenceInAL[2] + presenceInAL[4]) - 3.8305932641 * presenceInAL[3]
			+ ( -0.2828214615 * presenceOutAL[2]) + (  0.2613069963 * presenceOutAL[3])
			+ ( -0.8628193852 * presenceOutAL[4]) + (  0.5387164389 * presenceOutAL[5]);
			bridgerectifier = fabs(presenceOutAL[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (presenceOutAL[6] > 0.0){sumL += bridgerectifier;}
			else {sumL -= bridgerectifier;}			
			//presence section L
			presenceInAR[0] = presenceInAR[1]; presenceInAR[1] = presenceInAR[2]; presenceInAR[2] = presenceInAR[3];
			presenceInAR[3] = presenceInAR[4]; presenceInAR[4] = presenceInAR[5]; presenceInAR[5] = presenceInAR[6]; 
			presenceInAR[6] = inputSampleR * presence; presenceOutAR[2] = presenceOutAR[3];
			presenceOutAR[3] = presenceOutAR[4]; presenceOutAR[4] = presenceOutAR[5]; presenceOutAR[5] = presenceOutAR[6]; 
			presenceOutAR[6] = (presenceInAR[0] + presenceInAR[6]) + 1.9152966321 * (presenceInAR[1] + presenceInAR[5]) 
			- (presenceInAR[2] + presenceInAR[4]) - 3.8305932641 * presenceInAR[3]
			+ ( -0.2828214615 * presenceOutAR[2]) + (  0.2613069963 * presenceOutAR[3])
			+ ( -0.8628193852 * presenceOutAR[4]) + (  0.5387164389 * presenceOutAR[5]);
			bridgerectifier = fabs(presenceOutAR[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (presenceOutAR[6] > 0.0){sumR += bridgerectifier;}
			else {sumR -= bridgerectifier;}			
			//presence section R
			
			highInAL[0] = highInAL[1]; highInAL[1] = highInAL[2]; highInAL[2] = highInAL[3];
			highInAL[3] = highInAL[4]; highInAL[4] = highInAL[5]; highInAL[5] = highInAL[6]; 
			bridgerectifier = fabs(inputSampleL) * high;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {highInAL[6] = bridgerectifier;}
			else {highInAL[6] = -bridgerectifier;}
			highInAL[6] *= high; highOutAL[2] = highOutAL[3];
			highOutAL[3] = highOutAL[4]; highOutAL[4] = highOutAL[5]; highOutAL[5] = highOutAL[6]; 
			highOutAL[6] = (highInAL[0] + highInAL[6]) -   0.5141967433 * (highInAL[1] + highInAL[5]) 
			- (highInAL[2] + highInAL[4]) +   1.0283934866 * highInAL[3]
			+ ( -0.2828214615 * highOutAL[2]) + (  1.0195930909 * highOutAL[3])
			+ ( -1.9633013869 * highOutAL[4]) + (  2.1020162751 * highOutAL[5]);
			bridgerectifier = fabs(highOutAL[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (highOutAL[6] > 0.0){sumL += bridgerectifier;}
			else {sumL -= bridgerectifier;}			
			//high section L
			highInAR[0] = highInAR[1]; highInAR[1] = highInAR[2]; highInAR[2] = highInAR[3];
			highInAR[3] = highInAR[4]; highInAR[4] = highInAR[5]; highInAR[5] = highInAR[6]; 
			bridgerectifier = fabs(inputSampleR) * high;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {highInAR[6] = bridgerectifier;}
			else {highInAR[6] = -bridgerectifier;}
			highInAR[6] *= high; highOutAR[2] = highOutAR[3];
			highOutAR[3] = highOutAR[4]; highOutAR[4] = highOutAR[5]; highOutAR[5] = highOutAR[6]; 
			highOutAR[6] = (highInAR[0] + highInAR[6]) -   0.5141967433 * (highInAR[1] + highInAR[5]) 
			- (highInAR[2] + highInAR[4]) +   1.0283934866 * highInAR[3]
			+ ( -0.2828214615 * highOutAR[2]) + (  1.0195930909 * highOutAR[3])
			+ ( -1.9633013869 * highOutAR[4]) + (  2.1020162751 * highOutAR[5]);
			bridgerectifier = fabs(highOutAR[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (highOutAR[6] > 0.0){sumR += bridgerectifier;}
			else {sumR -= bridgerectifier;}			
			//high section R
			
			midInAL[0] = midInAL[1]; midInAL[1] = midInAL[2]; midInAL[2] = midInAL[3];
			midInAL[3] = midInAL[4]; midInAL[4] = midInAL[5]; midInAL[5] = midInAL[6]; 
			bridgerectifier = fabs(inputSampleL) * mid;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {midInAL[6] = bridgerectifier;}
			else {midInAL[6] = -bridgerectifier;}
			midInAL[6] *= mid; midOutAL[2] = midOutAL[3];
			midOutAL[3] = midOutAL[4]; midOutAL[4] = midOutAL[5]; midOutAL[5] = midOutAL[6]; 
			midOutAL[6] = (midInAL[0] + midInAL[6]) - 1.1790257790 * (midInAL[1] + midInAL[5]) 
			- (midInAL[2] + midInAL[4]) + 2.3580515580 * midInAL[3]
			+ ( -0.6292082828 * midOutAL[2]) + (  2.7785843605 * midOutAL[3])
			+ ( -4.6638295236 * midOutAL[4]) + (  3.5142515802 * midOutAL[5]);
			sumL += midOutAL[6];
			//mid section L
			midInAR[0] = midInAR[1]; midInAR[1] = midInAR[2]; midInAR[2] = midInAR[3];
			midInAR[3] = midInAR[4]; midInAR[4] = midInAR[5]; midInAR[5] = midInAR[6]; 
			bridgerectifier = fabs(inputSampleR) * mid;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {midInAR[6] = bridgerectifier;}
			else {midInAR[6] = -bridgerectifier;}
			midInAR[6] *= mid; midOutAR[2] = midOutAR[3];
			midOutAR[3] = midOutAR[4]; midOutAR[4] = midOutAR[5]; midOutAR[5] = midOutAR[6]; 
			midOutAR[6] = (midInAR[0] + midInAR[6]) - 1.1790257790 * (midInAR[1] + midInAR[5]) 
			- (midInAR[2] + midInAR[4]) + 2.3580515580 * midInAR[3]
			+ ( -0.6292082828 * midOutAR[2]) + (  2.7785843605 * midOutAR[3])
			+ ( -4.6638295236 * midOutAR[4]) + (  3.5142515802 * midOutAR[5]);
			sumR += midOutAR[6];
			//mid section R
			
			lowInAL[0] = lowInAL[1]; lowInAL[1] = lowInAL[2]; lowInAL[2] = lowInAL[3];
			lowInAL[3] = lowInAL[4]; lowInAL[4] = lowInAL[5]; lowInAL[5] = lowInAL[6]; 
			bridgerectifier = fabs(inputSampleL) * low;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {lowInAL[6] = bridgerectifier;}
			else {lowInAL[6] = -bridgerectifier;}
			lowInAL[6] *= low; lowOutAL[2] = lowOutAL[3];
			lowOutAL[3] = lowOutAL[4]; lowOutAL[4] = lowOutAL[5]; lowOutAL[5] = lowOutAL[6]; 
			lowOutAL[6] = (lowInAL[0] + lowInAL[6]) - 1.9193504547 * (lowInAL[1] + lowInAL[5]) 
			- (lowInAL[2] + lowInAL[4]) + 3.8387009093 * lowInAL[3]
			+ ( -0.9195964462 * lowOutAL[2]) + (  3.7538173833 * lowOutAL[3])
			+ ( -5.7487775603 * lowOutAL[4]) + (  3.9145559258 * lowOutAL[5]);
			sumL += lowOutAL[6];
			//low section L
			lowInAR[0] = lowInAR[1]; lowInAR[1] = lowInAR[2]; lowInAR[2] = lowInAR[3];
			lowInAR[3] = lowInAR[4]; lowInAR[4] = lowInAR[5]; lowInAR[5] = lowInAR[6]; 
			bridgerectifier = fabs(inputSampleR) * low;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {lowInAR[6] = bridgerectifier;}
			else {lowInAR[6] = -bridgerectifier;}
			lowInAR[6] *= low; lowOutAR[2] = lowOutAR[3];
			lowOutAR[3] = lowOutAR[4]; lowOutAR[4] = lowOutAR[5]; lowOutAR[5] = lowOutAR[6]; 
			lowOutAR[6] = (lowInAR[0] + lowInAR[6]) - 1.9193504547 * (lowInAR[1] + lowInAR[5]) 
			- (lowInAR[2] + lowInAR[4]) + 3.8387009093 * lowInAR[3]
			+ ( -0.9195964462 * lowOutAR[2]) + (  3.7538173833 * lowOutAR[3])
			+ ( -5.7487775603 * lowOutAR[4]) + (  3.9145559258 * lowOutAR[5]);
			sumR += lowOutAR[6];
			//low section R
		}
		else
		{
			presenceInBL[0] = presenceInBL[1]; presenceInBL[1] = presenceInBL[2]; presenceInBL[2] = presenceInBL[3];
			presenceInBL[3] = presenceInBL[4]; presenceInBL[4] = presenceInBL[5]; presenceInBL[5] = presenceInBL[6]; 
			presenceInBL[6] = inputSampleL * presence; presenceOutBL[2] = presenceOutBL[3];
			presenceOutBL[3] = presenceOutBL[4]; presenceOutBL[4] = presenceOutBL[5]; presenceOutBL[5] = presenceOutBL[6]; 
			presenceOutBL[6] = (presenceInBL[0] + presenceInBL[6]) + 1.9152966321 * (presenceInBL[1] + presenceInBL[5]) 
			- (presenceInBL[2] + presenceInBL[4]) - 3.8305932641 * presenceInBL[3]
			+ ( -0.2828214615 * presenceOutBL[2]) + (  0.2613069963 * presenceOutBL[3])
			+ ( -0.8628193852 * presenceOutBL[4]) + (  0.5387164389 * presenceOutBL[5]);
			bridgerectifier = fabs(presenceOutBL[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (presenceOutBL[6] > 0.0){sumL += bridgerectifier;}
			else {sumL -= bridgerectifier;}			
			//presence section L
			presenceInBR[0] = presenceInBR[1]; presenceInBR[1] = presenceInBR[2]; presenceInBR[2] = presenceInBR[3];
			presenceInBR[3] = presenceInBR[4]; presenceInBR[4] = presenceInBR[5]; presenceInBR[5] = presenceInBR[6]; 
			presenceInBR[6] = inputSampleR * presence; presenceOutBR[2] = presenceOutBR[3];
			presenceOutBR[3] = presenceOutBR[4]; presenceOutBR[4] = presenceOutBR[5]; presenceOutBR[5] = presenceOutBR[6]; 
			presenceOutBR[6] = (presenceInBR[0] + presenceInBR[6]) + 1.9152966321 * (presenceInBR[1] + presenceInBR[5]) 
			- (presenceInBR[2] + presenceInBR[4]) - 3.8305932641 * presenceInBR[3]
			+ ( -0.2828214615 * presenceOutBR[2]) + (  0.2613069963 * presenceOutBR[3])
			+ ( -0.8628193852 * presenceOutBR[4]) + (  0.5387164389 * presenceOutBR[5]);
			bridgerectifier = fabs(presenceOutBR[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (presenceOutBR[6] > 0.0){sumR += bridgerectifier;}
			else {sumR -= bridgerectifier;}			
			//presence section R
			
			highInBL[0] = highInBL[1]; highInBL[1] = highInBL[2]; highInBL[2] = highInBL[3];
			highInBL[3] = highInBL[4]; highInBL[4] = highInBL[5]; highInBL[5] = highInBL[6]; 
			bridgerectifier = fabs(inputSampleL) * high;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {highInBL[6] = bridgerectifier;}
			else {highInBL[6] = -bridgerectifier;}
			highInBL[6] *= high; highOutBL[2] = highOutBL[3];
			highOutBL[3] = highOutBL[4]; highOutBL[4] = highOutBL[5]; highOutBL[5] = highOutBL[6]; 
			highOutBL[6] = (highInBL[0] + highInBL[6]) -   0.5141967433 * (highInBL[1] + highInBL[5]) 
			- (highInBL[2] + highInBL[4]) +   1.0283934866 * highInBL[3]
			+ ( -0.2828214615 * highOutBL[2]) + (  1.0195930909 * highOutBL[3])
			+ ( -1.9633013869 * highOutBL[4]) + (  2.1020162751 * highOutBL[5]);
			bridgerectifier = fabs(highOutBL[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (highOutBL[6] > 0.0){sumL += bridgerectifier;}
			else {sumL -= bridgerectifier;}			
			//high section L
			highInBR[0] = highInBR[1]; highInBR[1] = highInBR[2]; highInBR[2] = highInBR[3];
			highInBR[3] = highInBR[4]; highInBR[4] = highInBR[5]; highInBR[5] = highInBR[6]; 
			bridgerectifier = fabs(inputSampleR) * high;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {highInBR[6] = bridgerectifier;}
			else {highInBR[6] = -bridgerectifier;}
			highInBR[6] *= high; highOutBR[2] = highOutBR[3];
			highOutBR[3] = highOutBR[4]; highOutBR[4] = highOutBR[5]; highOutBR[5] = highOutBR[6]; 
			highOutBR[6] = (highInBR[0] + highInBR[6]) -   0.5141967433 * (highInBR[1] + highInBR[5]) 
			- (highInBR[2] + highInBR[4]) +   1.0283934866 * highInBR[3]
			+ ( -0.2828214615 * highOutBR[2]) + (  1.0195930909 * highOutBR[3])
			+ ( -1.9633013869 * highOutBR[4]) + (  2.1020162751 * highOutBR[5]);
			bridgerectifier = fabs(highOutBR[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (highOutBR[6] > 0.0){sumR += bridgerectifier;}
			else {sumR -= bridgerectifier;}			
			//high section R
			
			midInBL[0] = midInBL[1]; midInBL[1] = midInBL[2]; midInBL[2] = midInBL[3];
			midInBL[3] = midInBL[4]; midInBL[4] = midInBL[5]; midInBL[5] = midInBL[6]; 
			bridgerectifier = fabs(inputSampleL) * mid;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {midInBL[6] = bridgerectifier;}
			else {midInBL[6] = -bridgerectifier;}
			midInBL[6] *= mid; midOutBL[2] = midOutBL[3];
			midOutBL[3] = midOutBL[4]; midOutBL[4] = midOutBL[5]; midOutBL[5] = midOutBL[6]; 
			midOutBL[6] = (midInBL[0] + midInBL[6]) - 1.1790257790 * (midInBL[1] + midInBL[5]) 
			- (midInBL[2] + midInBL[4]) + 2.3580515580 * midInBL[3]
			+ ( -0.6292082828 * midOutBL[2]) + (  2.7785843605 * midOutBL[3])
			+ ( -4.6638295236 * midOutBL[4]) + (  3.5142515802 * midOutBL[5]);
			sumL += midOutBL[6];
			//mid section L
			midInBR[0] = midInBR[1]; midInBR[1] = midInBR[2]; midInBR[2] = midInBR[3];
			midInBR[3] = midInBR[4]; midInBR[4] = midInBR[5]; midInBR[5] = midInBR[6]; 
			bridgerectifier = fabs(inputSampleR) * mid;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {midInBR[6] = bridgerectifier;}
			else {midInBR[6] = -bridgerectifier;}
			midInBR[6] *= mid; midOutBR[2] = midOutBR[3];
			midOutBR[3] = midOutBR[4]; midOutBR[4] = midOutBR[5]; midOutBR[5] = midOutBR[6]; 
			midOutBR[6] = (midInBR[0] + midInBR[6]) - 1.1790257790 * (midInBR[1] + midInBR[5]) 
			- (midInBR[2] + midInBR[4]) + 2.3580515580 * midInBR[3]
			+ ( -0.6292082828 * midOutBR[2]) + (  2.7785843605 * midOutBR[3])
			+ ( -4.6638295236 * midOutBR[4]) + (  3.5142515802 * midOutBR[5]);
			sumR += midOutBR[6];
			//mid section R
			
			lowInBL[0] = lowInBL[1]; lowInBL[1] = lowInBL[2]; lowInBL[2] = lowInBL[3];
			lowInBL[3] = lowInBL[4]; lowInBL[4] = lowInBL[5]; lowInBL[5] = lowInBL[6]; 
			bridgerectifier = fabs(inputSampleL) * low;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {lowInBL[6] = bridgerectifier;}
			else {lowInBL[6] = -bridgerectifier;}
			lowInBL[6] *= low; lowOutBL[2] = lowOutBL[3];
			lowOutBL[3] = lowOutBL[4]; lowOutBL[4] = lowOutBL[5]; lowOutBL[5] = lowOutBL[6]; 
			lowOutBL[6] = (lowInBL[0] + lowInBL[6]) - 1.9193504547 * (lowInBL[1] + lowInBL[5]) 
			- (lowInBL[2] + lowInBL[4]) + 3.8387009093 * lowInBL[3]
			+ ( -0.9195964462 * lowOutBL[2]) + (  3.7538173833 * lowOutBL[3])
			+ ( -5.7487775603 * lowOutBL[4]) + (  3.9145559258 * lowOutBL[5]);
			sumL += lowOutBL[6];
			//low section L
			lowInBR[0] = lowInBR[1]; lowInBR[1] = lowInBR[2]; lowInBR[2] = lowInBR[3];
			lowInBR[3] = lowInBR[4]; lowInBR[4] = lowInBR[5]; lowInBR[5] = lowInBR[6]; 
			bridgerectifier = fabs(inputSampleR) * low;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {lowInBR[6] = bridgerectifier;}
			else {lowInBR[6] = -bridgerectifier;}
			lowInBR[6] *= low; lowOutBR[2] = lowOutBR[3];
			lowOutBR[3] = lowOutBR[4]; lowOutBR[4] = lowOutBR[5]; lowOutBR[5] = lowOutBR[6]; 
			lowOutBR[6] = (lowInBR[0] + lowInBR[6]) - 1.9193504547 * (lowInBR[1] + lowInBR[5]) 
			- (lowInBR[2] + lowInBR[4]) + 3.8387009093 * lowInBR[3]
			+ ( -0.9195964462 * lowOutBR[2]) + (  3.7538173833 * lowOutBR[3])
			+ ( -5.7487775603 * lowOutBR[4]) + (  3.9145559258 * lowOutBR[5]);
			sumR += lowOutBR[6];
			//low section R
		}
		
		inputSampleL = fabs(sumL) * drive;
		if (inputSampleL > 1.57079633) {inputSampleL = 1.57079633;}
		inputSampleL = sin(inputSampleL);
		if (sumL < 0) inputSampleL = -inputSampleL;
		//output L
		inputSampleR = fabs(sumR) * drive;
		if (inputSampleR > 1.57079633) {inputSampleR = 1.57079633;}
		inputSampleR = sin(inputSampleR);
		if (sumR < 0) inputSampleR = -inputSampleR;
		//output R
		
		flip = !flip;
		
		//begin 32 bit stereo floating point dither
		int expon; frexpf((float)inputSampleL, &expon);
		fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
		inputSampleL += ((double(fpd)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62));
		frexpf((float)inputSampleR, &expon);
		fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
		inputSampleR += ((double(fpd)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62));
		//end 32 bit stereo floating point dither
		
		*out1 = inputSampleL;
		*out2 = inputSampleR;

		*in1++;
		*in2++;
		*out1++;
		*out2++;
    }
}

void BassDrive::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) 
{
    double* in1  =  inputs[0];
    double* in2  =  inputs[1];
    double* out1 = outputs[0];
    double* out2 = outputs[1];
	
	double sumL;
	double sumR;
	double presence = pow(A,5) * 8.0;
	double high = pow(B,3) * 4.0;
	double mid = pow(C,2);
	double low = D / 4.0;
	double drive = E * 2.0;
	double bridgerectifier;
	
    while (--sampleFrames >= 0)
    {
		long double inputSampleL = *in1;
		long double inputSampleR = *in2;
		if (fabs(inputSampleL)<1.18e-43) inputSampleL = fpd * 1.18e-43;
		if (fabs(inputSampleR)<1.18e-43) inputSampleR = fpd * 1.18e-43;
		
		sumL = 0.0;
		sumR = 0.0;
		
		
		if (flip)
		{
			presenceInAL[0] = presenceInAL[1]; presenceInAL[1] = presenceInAL[2]; presenceInAL[2] = presenceInAL[3];
			presenceInAL[3] = presenceInAL[4]; presenceInAL[4] = presenceInAL[5]; presenceInAL[5] = presenceInAL[6]; 
			presenceInAL[6] = inputSampleL * presence; presenceOutAL[2] = presenceOutAL[3];
			presenceOutAL[3] = presenceOutAL[4]; presenceOutAL[4] = presenceOutAL[5]; presenceOutAL[5] = presenceOutAL[6]; 
			presenceOutAL[6] = (presenceInAL[0] + presenceInAL[6]) + 1.9152966321 * (presenceInAL[1] + presenceInAL[5]) 
			- (presenceInAL[2] + presenceInAL[4]) - 3.8305932641 * presenceInAL[3]
			+ ( -0.2828214615 * presenceOutAL[2]) + (  0.2613069963 * presenceOutAL[3])
			+ ( -0.8628193852 * presenceOutAL[4]) + (  0.5387164389 * presenceOutAL[5]);
			bridgerectifier = fabs(presenceOutAL[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (presenceOutAL[6] > 0.0){sumL += bridgerectifier;}
			else {sumL -= bridgerectifier;}			
			//presence section L
			presenceInAR[0] = presenceInAR[1]; presenceInAR[1] = presenceInAR[2]; presenceInAR[2] = presenceInAR[3];
			presenceInAR[3] = presenceInAR[4]; presenceInAR[4] = presenceInAR[5]; presenceInAR[5] = presenceInAR[6]; 
			presenceInAR[6] = inputSampleR * presence; presenceOutAR[2] = presenceOutAR[3];
			presenceOutAR[3] = presenceOutAR[4]; presenceOutAR[4] = presenceOutAR[5]; presenceOutAR[5] = presenceOutAR[6]; 
			presenceOutAR[6] = (presenceInAR[0] + presenceInAR[6]) + 1.9152966321 * (presenceInAR[1] + presenceInAR[5]) 
			- (presenceInAR[2] + presenceInAR[4]) - 3.8305932641 * presenceInAR[3]
			+ ( -0.2828214615 * presenceOutAR[2]) + (  0.2613069963 * presenceOutAR[3])
			+ ( -0.8628193852 * presenceOutAR[4]) + (  0.5387164389 * presenceOutAR[5]);
			bridgerectifier = fabs(presenceOutAR[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (presenceOutAR[6] > 0.0){sumR += bridgerectifier;}
			else {sumR -= bridgerectifier;}			
			//presence section R
			
			highInAL[0] = highInAL[1]; highInAL[1] = highInAL[2]; highInAL[2] = highInAL[3];
			highInAL[3] = highInAL[4]; highInAL[4] = highInAL[5]; highInAL[5] = highInAL[6]; 
			bridgerectifier = fabs(inputSampleL) * high;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {highInAL[6] = bridgerectifier;}
			else {highInAL[6] = -bridgerectifier;}
			highInAL[6] *= high; highOutAL[2] = highOutAL[3];
			highOutAL[3] = highOutAL[4]; highOutAL[4] = highOutAL[5]; highOutAL[5] = highOutAL[6]; 
			highOutAL[6] = (highInAL[0] + highInAL[6]) -   0.5141967433 * (highInAL[1] + highInAL[5]) 
			- (highInAL[2] + highInAL[4]) +   1.0283934866 * highInAL[3]
			+ ( -0.2828214615 * highOutAL[2]) + (  1.0195930909 * highOutAL[3])
			+ ( -1.9633013869 * highOutAL[4]) + (  2.1020162751 * highOutAL[5]);
			bridgerectifier = fabs(highOutAL[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (highOutAL[6] > 0.0){sumL += bridgerectifier;}
			else {sumL -= bridgerectifier;}			
			//high section L
			highInAR[0] = highInAR[1]; highInAR[1] = highInAR[2]; highInAR[2] = highInAR[3];
			highInAR[3] = highInAR[4]; highInAR[4] = highInAR[5]; highInAR[5] = highInAR[6]; 
			bridgerectifier = fabs(inputSampleR) * high;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {highInAR[6] = bridgerectifier;}
			else {highInAR[6] = -bridgerectifier;}
			highInAR[6] *= high; highOutAR[2] = highOutAR[3];
			highOutAR[3] = highOutAR[4]; highOutAR[4] = highOutAR[5]; highOutAR[5] = highOutAR[6]; 
			highOutAR[6] = (highInAR[0] + highInAR[6]) -   0.5141967433 * (highInAR[1] + highInAR[5]) 
			- (highInAR[2] + highInAR[4]) +   1.0283934866 * highInAR[3]
			+ ( -0.2828214615 * highOutAR[2]) + (  1.0195930909 * highOutAR[3])
			+ ( -1.9633013869 * highOutAR[4]) + (  2.1020162751 * highOutAR[5]);
			bridgerectifier = fabs(highOutAR[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (highOutAR[6] > 0.0){sumR += bridgerectifier;}
			else {sumR -= bridgerectifier;}			
			//high section R
			
			midInAL[0] = midInAL[1]; midInAL[1] = midInAL[2]; midInAL[2] = midInAL[3];
			midInAL[3] = midInAL[4]; midInAL[4] = midInAL[5]; midInAL[5] = midInAL[6]; 
			bridgerectifier = fabs(inputSampleL) * mid;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {midInAL[6] = bridgerectifier;}
			else {midInAL[6] = -bridgerectifier;}
			midInAL[6] *= mid; midOutAL[2] = midOutAL[3];
			midOutAL[3] = midOutAL[4]; midOutAL[4] = midOutAL[5]; midOutAL[5] = midOutAL[6]; 
			midOutAL[6] = (midInAL[0] + midInAL[6]) - 1.1790257790 * (midInAL[1] + midInAL[5]) 
			- (midInAL[2] + midInAL[4]) + 2.3580515580 * midInAL[3]
			+ ( -0.6292082828 * midOutAL[2]) + (  2.7785843605 * midOutAL[3])
			+ ( -4.6638295236 * midOutAL[4]) + (  3.5142515802 * midOutAL[5]);
			sumL += midOutAL[6];
			//mid section L
			midInAR[0] = midInAR[1]; midInAR[1] = midInAR[2]; midInAR[2] = midInAR[3];
			midInAR[3] = midInAR[4]; midInAR[4] = midInAR[5]; midInAR[5] = midInAR[6]; 
			bridgerectifier = fabs(inputSampleR) * mid;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {midInAR[6] = bridgerectifier;}
			else {midInAR[6] = -bridgerectifier;}
			midInAR[6] *= mid; midOutAR[2] = midOutAR[3];
			midOutAR[3] = midOutAR[4]; midOutAR[4] = midOutAR[5]; midOutAR[5] = midOutAR[6]; 
			midOutAR[6] = (midInAR[0] + midInAR[6]) - 1.1790257790 * (midInAR[1] + midInAR[5]) 
			- (midInAR[2] + midInAR[4]) + 2.3580515580 * midInAR[3]
			+ ( -0.6292082828 * midOutAR[2]) + (  2.7785843605 * midOutAR[3])
			+ ( -4.6638295236 * midOutAR[4]) + (  3.5142515802 * midOutAR[5]);
			sumR += midOutAR[6];
			//mid section R
			
			lowInAL[0] = lowInAL[1]; lowInAL[1] = lowInAL[2]; lowInAL[2] = lowInAL[3];
			lowInAL[3] = lowInAL[4]; lowInAL[4] = lowInAL[5]; lowInAL[5] = lowInAL[6]; 
			bridgerectifier = fabs(inputSampleL) * low;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {lowInAL[6] = bridgerectifier;}
			else {lowInAL[6] = -bridgerectifier;}
			lowInAL[6] *= low; lowOutAL[2] = lowOutAL[3];
			lowOutAL[3] = lowOutAL[4]; lowOutAL[4] = lowOutAL[5]; lowOutAL[5] = lowOutAL[6]; 
			lowOutAL[6] = (lowInAL[0] + lowInAL[6]) - 1.9193504547 * (lowInAL[1] + lowInAL[5]) 
			- (lowInAL[2] + lowInAL[4]) + 3.8387009093 * lowInAL[3]
			+ ( -0.9195964462 * lowOutAL[2]) + (  3.7538173833 * lowOutAL[3])
			+ ( -5.7487775603 * lowOutAL[4]) + (  3.9145559258 * lowOutAL[5]);
			sumL += lowOutAL[6];
			//low section L
			lowInAR[0] = lowInAR[1]; lowInAR[1] = lowInAR[2]; lowInAR[2] = lowInAR[3];
			lowInAR[3] = lowInAR[4]; lowInAR[4] = lowInAR[5]; lowInAR[5] = lowInAR[6]; 
			bridgerectifier = fabs(inputSampleR) * low;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {lowInAR[6] = bridgerectifier;}
			else {lowInAR[6] = -bridgerectifier;}
			lowInAR[6] *= low; lowOutAR[2] = lowOutAR[3];
			lowOutAR[3] = lowOutAR[4]; lowOutAR[4] = lowOutAR[5]; lowOutAR[5] = lowOutAR[6]; 
			lowOutAR[6] = (lowInAR[0] + lowInAR[6]) - 1.9193504547 * (lowInAR[1] + lowInAR[5]) 
			- (lowInAR[2] + lowInAR[4]) + 3.8387009093 * lowInAR[3]
			+ ( -0.9195964462 * lowOutAR[2]) + (  3.7538173833 * lowOutAR[3])
			+ ( -5.7487775603 * lowOutAR[4]) + (  3.9145559258 * lowOutAR[5]);
			sumR += lowOutAR[6];
			//low section R
		}
		else
		{
			presenceInBL[0] = presenceInBL[1]; presenceInBL[1] = presenceInBL[2]; presenceInBL[2] = presenceInBL[3];
			presenceInBL[3] = presenceInBL[4]; presenceInBL[4] = presenceInBL[5]; presenceInBL[5] = presenceInBL[6]; 
			presenceInBL[6] = inputSampleL * presence; presenceOutBL[2] = presenceOutBL[3];
			presenceOutBL[3] = presenceOutBL[4]; presenceOutBL[4] = presenceOutBL[5]; presenceOutBL[5] = presenceOutBL[6]; 
			presenceOutBL[6] = (presenceInBL[0] + presenceInBL[6]) + 1.9152966321 * (presenceInBL[1] + presenceInBL[5]) 
			- (presenceInBL[2] + presenceInBL[4]) - 3.8305932641 * presenceInBL[3]
			+ ( -0.2828214615 * presenceOutBL[2]) + (  0.2613069963 * presenceOutBL[3])
			+ ( -0.8628193852 * presenceOutBL[4]) + (  0.5387164389 * presenceOutBL[5]);
			bridgerectifier = fabs(presenceOutBL[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (presenceOutBL[6] > 0.0){sumL += bridgerectifier;}
			else {sumL -= bridgerectifier;}			
			//presence section L
			presenceInBR[0] = presenceInBR[1]; presenceInBR[1] = presenceInBR[2]; presenceInBR[2] = presenceInBR[3];
			presenceInBR[3] = presenceInBR[4]; presenceInBR[4] = presenceInBR[5]; presenceInBR[5] = presenceInBR[6]; 
			presenceInBR[6] = inputSampleR * presence; presenceOutBR[2] = presenceOutBR[3];
			presenceOutBR[3] = presenceOutBR[4]; presenceOutBR[4] = presenceOutBR[5]; presenceOutBR[5] = presenceOutBR[6]; 
			presenceOutBR[6] = (presenceInBR[0] + presenceInBR[6]) + 1.9152966321 * (presenceInBR[1] + presenceInBR[5]) 
			- (presenceInBR[2] + presenceInBR[4]) - 3.8305932641 * presenceInBR[3]
			+ ( -0.2828214615 * presenceOutBR[2]) + (  0.2613069963 * presenceOutBR[3])
			+ ( -0.8628193852 * presenceOutBR[4]) + (  0.5387164389 * presenceOutBR[5]);
			bridgerectifier = fabs(presenceOutBR[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (presenceOutBR[6] > 0.0){sumR += bridgerectifier;}
			else {sumR -= bridgerectifier;}			
			//presence section R
			
			highInBL[0] = highInBL[1]; highInBL[1] = highInBL[2]; highInBL[2] = highInBL[3];
			highInBL[3] = highInBL[4]; highInBL[4] = highInBL[5]; highInBL[5] = highInBL[6]; 
			bridgerectifier = fabs(inputSampleL) * high;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {highInBL[6] = bridgerectifier;}
			else {highInBL[6] = -bridgerectifier;}
			highInBL[6] *= high; highOutBL[2] = highOutBL[3];
			highOutBL[3] = highOutBL[4]; highOutBL[4] = highOutBL[5]; highOutBL[5] = highOutBL[6]; 
			highOutBL[6] = (highInBL[0] + highInBL[6]) -   0.5141967433 * (highInBL[1] + highInBL[5]) 
			- (highInBL[2] + highInBL[4]) +   1.0283934866 * highInBL[3]
			+ ( -0.2828214615 * highOutBL[2]) + (  1.0195930909 * highOutBL[3])
			+ ( -1.9633013869 * highOutBL[4]) + (  2.1020162751 * highOutBL[5]);
			bridgerectifier = fabs(highOutBL[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (highOutBL[6] > 0.0){sumL += bridgerectifier;}
			else {sumL -= bridgerectifier;}			
			//high section L
			highInBR[0] = highInBR[1]; highInBR[1] = highInBR[2]; highInBR[2] = highInBR[3];
			highInBR[3] = highInBR[4]; highInBR[4] = highInBR[5]; highInBR[5] = highInBR[6]; 
			bridgerectifier = fabs(inputSampleR) * high;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {highInBR[6] = bridgerectifier;}
			else {highInBR[6] = -bridgerectifier;}
			highInBR[6] *= high; highOutBR[2] = highOutBR[3];
			highOutBR[3] = highOutBR[4]; highOutBR[4] = highOutBR[5]; highOutBR[5] = highOutBR[6]; 
			highOutBR[6] = (highInBR[0] + highInBR[6]) -   0.5141967433 * (highInBR[1] + highInBR[5]) 
			- (highInBR[2] + highInBR[4]) +   1.0283934866 * highInBR[3]
			+ ( -0.2828214615 * highOutBR[2]) + (  1.0195930909 * highOutBR[3])
			+ ( -1.9633013869 * highOutBR[4]) + (  2.1020162751 * highOutBR[5]);
			bridgerectifier = fabs(highOutBR[6]);
			if (bridgerectifier > 1.57079633) bridgerectifier = 1.57079633;
			bridgerectifier = sin(bridgerectifier);
			if (highOutBR[6] > 0.0){sumR += bridgerectifier;}
			else {sumR -= bridgerectifier;}			
			//high section R
			
			midInBL[0] = midInBL[1]; midInBL[1] = midInBL[2]; midInBL[2] = midInBL[3];
			midInBL[3] = midInBL[4]; midInBL[4] = midInBL[5]; midInBL[5] = midInBL[6]; 
			bridgerectifier = fabs(inputSampleL) * mid;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {midInBL[6] = bridgerectifier;}
			else {midInBL[6] = -bridgerectifier;}
			midInBL[6] *= mid; midOutBL[2] = midOutBL[3];
			midOutBL[3] = midOutBL[4]; midOutBL[4] = midOutBL[5]; midOutBL[5] = midOutBL[6]; 
			midOutBL[6] = (midInBL[0] + midInBL[6]) - 1.1790257790 * (midInBL[1] + midInBL[5]) 
			- (midInBL[2] + midInBL[4]) + 2.3580515580 * midInBL[3]
			+ ( -0.6292082828 * midOutBL[2]) + (  2.7785843605 * midOutBL[3])
			+ ( -4.6638295236 * midOutBL[4]) + (  3.5142515802 * midOutBL[5]);
			sumL += midOutBL[6];
			//mid section L
			midInBR[0] = midInBR[1]; midInBR[1] = midInBR[2]; midInBR[2] = midInBR[3];
			midInBR[3] = midInBR[4]; midInBR[4] = midInBR[5]; midInBR[5] = midInBR[6]; 
			bridgerectifier = fabs(inputSampleR) * mid;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {midInBR[6] = bridgerectifier;}
			else {midInBR[6] = -bridgerectifier;}
			midInBR[6] *= mid; midOutBR[2] = midOutBR[3];
			midOutBR[3] = midOutBR[4]; midOutBR[4] = midOutBR[5]; midOutBR[5] = midOutBR[6]; 
			midOutBR[6] = (midInBR[0] + midInBR[6]) - 1.1790257790 * (midInBR[1] + midInBR[5]) 
			- (midInBR[2] + midInBR[4]) + 2.3580515580 * midInBR[3]
			+ ( -0.6292082828 * midOutBR[2]) + (  2.7785843605 * midOutBR[3])
			+ ( -4.6638295236 * midOutBR[4]) + (  3.5142515802 * midOutBR[5]);
			sumR += midOutBR[6];
			//mid section R
			
			lowInBL[0] = lowInBL[1]; lowInBL[1] = lowInBL[2]; lowInBL[2] = lowInBL[3];
			lowInBL[3] = lowInBL[4]; lowInBL[4] = lowInBL[5]; lowInBL[5] = lowInBL[6]; 
			bridgerectifier = fabs(inputSampleL) * low;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleL > 0.0) {lowInBL[6] = bridgerectifier;}
			else {lowInBL[6] = -bridgerectifier;}
			lowInBL[6] *= low; lowOutBL[2] = lowOutBL[3];
			lowOutBL[3] = lowOutBL[4]; lowOutBL[4] = lowOutBL[5]; lowOutBL[5] = lowOutBL[6]; 
			lowOutBL[6] = (lowInBL[0] + lowInBL[6]) - 1.9193504547 * (lowInBL[1] + lowInBL[5]) 
			- (lowInBL[2] + lowInBL[4]) + 3.8387009093 * lowInBL[3]
			+ ( -0.9195964462 * lowOutBL[2]) + (  3.7538173833 * lowOutBL[3])
			+ ( -5.7487775603 * lowOutBL[4]) + (  3.9145559258 * lowOutBL[5]);
			sumL += lowOutBL[6];
			//low section L
			lowInBR[0] = lowInBR[1]; lowInBR[1] = lowInBR[2]; lowInBR[2] = lowInBR[3];
			lowInBR[3] = lowInBR[4]; lowInBR[4] = lowInBR[5]; lowInBR[5] = lowInBR[6]; 
			bridgerectifier = fabs(inputSampleR) * low;
			if (bridgerectifier > 1.57079633) {bridgerectifier = 1.57079633;}
			bridgerectifier = sin(bridgerectifier);
			if (inputSampleR > 0.0) {lowInBR[6] = bridgerectifier;}
			else {lowInBR[6] = -bridgerectifier;}
			lowInBR[6] *= low; lowOutBR[2] = lowOutBR[3];
			lowOutBR[3] = lowOutBR[4]; lowOutBR[4] = lowOutBR[5]; lowOutBR[5] = lowOutBR[6]; 
			lowOutBR[6] = (lowInBR[0] + lowInBR[6]) - 1.9193504547 * (lowInBR[1] + lowInBR[5]) 
			- (lowInBR[2] + lowInBR[4]) + 3.8387009093 * lowInBR[3]
			+ ( -0.9195964462 * lowOutBR[2]) + (  3.7538173833 * lowOutBR[3])
			+ ( -5.7487775603 * lowOutBR[4]) + (  3.9145559258 * lowOutBR[5]);
			sumR += lowOutBR[6];
			//low section R
		}
		
		inputSampleL = fabs(sumL) * drive;
		if (inputSampleL > 1.57079633) {inputSampleL = 1.57079633;}
		inputSampleL = sin(inputSampleL);
		if (sumL < 0) inputSampleL = -inputSampleL;
		//output L
		inputSampleR = fabs(sumR) * drive;
		if (inputSampleR > 1.57079633) {inputSampleR = 1.57079633;}
		inputSampleR = sin(inputSampleR);
		if (sumR < 0) inputSampleR = -inputSampleR;
		//output R
		
		flip = !flip;
		
		//begin 64 bit stereo floating point dither
		int expon; frexp((double)inputSampleL, &expon);
		fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
		inputSampleL += ((double(fpd)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62));
		frexp((double)inputSampleR, &expon);
		fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
		inputSampleR += ((double(fpd)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62));
		//end 64 bit stereo floating point dither
		
		*out1 = inputSampleL;
		*out2 = inputSampleR;

		*in1++;
		*in2++;
		*out1++;
		*out2++;
    }
}