-
Notifications
You must be signed in to change notification settings - Fork 0
/
fastmix.cpp
2277 lines (2040 loc) · 64.1 KB
/
fastmix.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
/*
* This source code is public domain.
*
* Authors: Olivier Lapicque <[email protected]>
* Markus Fick <[email protected]> spline + fir-resampler
*/
#include "stdafx.h"
#include "sndfile.h"
#include <math.h>
#ifdef MSC_VER
#pragma bss_seg(".modplug")
#endif
// Front Mix Buffer (Also room for interleaved rear mix)
int MixSoundBuffer[MIXBUFFERSIZE*4];
// Reverb Mix Buffer
#ifndef NO_REVERB
int MixReverbBuffer[MIXBUFFERSIZE*2];
extern UINT gnReverbSend;
#endif
#ifndef FASTSOUNDLIB
int MixRearBuffer[MIXBUFFERSIZE*2];
float MixFloatBuffer[MIXBUFFERSIZE*2];
#endif
#ifdef MSC_VER
#pragma bss_seg()
#endif
extern LONG gnDryROfsVol;
extern LONG gnDryLOfsVol;
extern LONG gnRvbROfsVol;
extern LONG gnRvbLOfsVol;
// 4x256 taps polyphase FIR resampling filter
extern short int gFastSinc[];
extern short int gKaiserSinc[]; // 8-taps polyphase
/*
------------------------------------------------------------------------------------------------
cubic spline interpolation doc,
(derived from "digital image warping", g. wolberg)
interpolation polynomial: f(x) = A3*(x-floor(x))**3 + A2*(x-floor(x))**2 + A1*(x-floor(x)) + A0
with Y = equispaced data points (dist=1), YD = first derivates of data points and IP = floor(x)
the A[0..3] can be found by solving
A0 = Y[IP]
A1 = YD[IP]
A2 = 3*(Y[IP+1]-Y[IP])-2.0*YD[IP]-YD[IP+1]
A3 = -2.0 * (Y[IP+1]-Y[IP]) + YD[IP] - YD[IP+1]
with the first derivates as
YD[IP] = 0.5 * (Y[IP+1] - Y[IP-1]);
YD[IP+1] = 0.5 * (Y[IP+2] - Y[IP])
the coefs becomes
A0 = Y[IP]
A1 = YD[IP]
= 0.5 * (Y[IP+1] - Y[IP-1]);
A2 = 3.0 * (Y[IP+1]-Y[IP])-2.0*YD[IP]-YD[IP+1]
= 3.0 * (Y[IP+1] - Y[IP]) - 0.5 * 2.0 * (Y[IP+1] - Y[IP-1]) - 0.5 * (Y[IP+2] - Y[IP])
= 3.0 * Y[IP+1] - 3.0 * Y[IP] - Y[IP+1] + Y[IP-1] - 0.5 * Y[IP+2] + 0.5 * Y[IP]
= -0.5 * Y[IP+2] + 2.0 * Y[IP+1] - 2.5 * Y[IP] + Y[IP-1]
= Y[IP-1] + 2 * Y[IP+1] - 0.5 * (5.0 * Y[IP] + Y[IP+2])
A3 = -2.0 * (Y[IP+1]-Y[IP]) + YD[IP] + YD[IP+1]
= -2.0 * Y[IP+1] + 2.0 * Y[IP] + 0.5 * (Y[IP+1] - Y[IP-1]) + 0.5 * (Y[IP+2] - Y[IP])
= -2.0 * Y[IP+1] + 2.0 * Y[IP] + 0.5 * Y[IP+1] - 0.5 * Y[IP-1] + 0.5 * Y[IP+2] - 0.5 * Y[IP]
= 0.5 * Y[IP+2] - 1.5 * Y[IP+1] + 1.5 * Y[IP] - 0.5 * Y[IP-1]
= 0.5 * (3.0 * (Y[IP] - Y[IP+1]) - Y[IP-1] + YP[IP+2])
then interpolated data value is (horner rule)
out = (((A3*x)+A2)*x+A1)*x+A0
this gives parts of data points Y[IP-1] to Y[IP+2] of
part x**3 x**2 x**1 x**0
Y[IP-1] -0.5 1 -0.5 0
Y[IP] 1.5 -2.5 0 1
Y[IP+1] -1.5 2 0.5 0
Y[IP+2] 0.5 -0.5 0 0
--------------------------------------------------------------------------------------------------
*/
// number of bits used to scale spline coefs
#define SPLINE_QUANTBITS 14
#define SPLINE_QUANTSCALE (1L<<SPLINE_QUANTBITS)
#define SPLINE_8SHIFT (SPLINE_QUANTBITS-8)
#define SPLINE_16SHIFT (SPLINE_QUANTBITS)
// forces coefsset to unity gain
#define SPLINE_CLAMPFORUNITY
// log2(number) of precalculated splines (range is [4..14])
#define SPLINE_FRACBITS 10
#define SPLINE_LUTLEN (1L<<SPLINE_FRACBITS)
class CzCUBICSPLINE
{ public:
CzCUBICSPLINE( );
~CzCUBICSPLINE( );
static signed short lut[4*(1L<<SPLINE_FRACBITS)];
};
signed short CzCUBICSPLINE::lut[4*(1L<<SPLINE_FRACBITS)];
CzCUBICSPLINE::CzCUBICSPLINE( )
{ int _LIi;
int _LLen = (1L<<SPLINE_FRACBITS);
float _LFlen = 1.0f / (float)_LLen;
float _LScale = (float)SPLINE_QUANTSCALE;
for(_LIi=0;_LIi<_LLen;_LIi++)
{ float _LCm1, _LC0, _LC1, _LC2;
float _LX = ((float)_LIi)*_LFlen;
int _LSum,_LIdx = _LIi<<2;
_LCm1 = (float)floor( 0.5 + _LScale * (-0.5*_LX*_LX*_LX + 1.0 * _LX*_LX - 0.5 * _LX ) );
_LC0 = (float)floor( 0.5 + _LScale * ( 1.5*_LX*_LX*_LX - 2.5 * _LX*_LX + 1.0 ) );
_LC1 = (float)floor( 0.5 + _LScale * (-1.5*_LX*_LX*_LX + 2.0 * _LX*_LX + 0.5 * _LX ) );
_LC2 = (float)floor( 0.5 + _LScale * ( 0.5*_LX*_LX*_LX - 0.5 * _LX*_LX ) );
lut[_LIdx+0] = (signed short)( (_LCm1 < -_LScale) ? -_LScale : ((_LCm1 > _LScale) ? _LScale : _LCm1) );
lut[_LIdx+1] = (signed short)( (_LC0 < -_LScale) ? -_LScale : ((_LC0 > _LScale) ? _LScale : _LC0 ) );
lut[_LIdx+2] = (signed short)( (_LC1 < -_LScale) ? -_LScale : ((_LC1 > _LScale) ? _LScale : _LC1 ) );
lut[_LIdx+3] = (signed short)( (_LC2 < -_LScale) ? -_LScale : ((_LC2 > _LScale) ? _LScale : _LC2 ) );
#ifdef SPLINE_CLAMPFORUNITY
_LSum = lut[_LIdx+0]+lut[_LIdx+1]+lut[_LIdx+2]+lut[_LIdx+3];
if( _LSum != SPLINE_QUANTSCALE )
{ int _LMax = _LIdx;
if( lut[_LIdx+1]>lut[_LMax] ) _LMax = _LIdx+1;
if( lut[_LIdx+2]>lut[_LMax] ) _LMax = _LIdx+2;
if( lut[_LIdx+3]>lut[_LMax] ) _LMax = _LIdx+3;
lut[_LMax] += (SPLINE_QUANTSCALE-_LSum);
}
#endif
}
}
CzCUBICSPLINE::~CzCUBICSPLINE( )
{ // nothing todo
}
CzCUBICSPLINE sspline;
/*
------------------------------------------------------------------------------------------------
fir interpolation doc,
(derived from "an engineer's guide to fir digital filters", n.j. loy)
calculate coefficients for ideal lowpass filter (with cutoff = fc in 0..1 (mapped to 0..nyquist))
c[-N..N] = (i==0) ? fc : sin(fc*pi*i)/(pi*i)
then apply selected window to coefficients
c[-N..N] *= w(0..N)
with n in 2*N and w(n) being a window function (see loy)
then calculate gain and scale filter coefs to have unity gain.
------------------------------------------------------------------------------------------------
*/
// quantizer scale of window coefs
#define WFIR_QUANTBITS 15
#define WFIR_QUANTSCALE (1L<<WFIR_QUANTBITS)
#define WFIR_8SHIFT (WFIR_QUANTBITS-8)
#define WFIR_16BITSHIFT (WFIR_QUANTBITS)
// log2(number)-1 of precalculated taps range is [4..12]
#define WFIR_FRACBITS 10
#define WFIR_LUTLEN ((1L<<(WFIR_FRACBITS+1))+1)
// number of samples in window
#define WFIR_LOG2WIDTH 3
#define WFIR_WIDTH (1L<<WFIR_LOG2WIDTH)
#define WFIR_SMPSPERWING ((WFIR_WIDTH-1)>>1)
// cutoff (1.0 == pi/2)
#define WFIR_CUTOFF 0.90f
// wfir type
#define WFIR_HANN 0
#define WFIR_HAMMING 1
#define WFIR_BLACKMANEXACT 2
#define WFIR_BLACKMAN3T61 3
#define WFIR_BLACKMAN3T67 4
#define WFIR_BLACKMAN4T92 5
#define WFIR_BLACKMAN4T74 6
#define WFIR_KAISER4T 7
#define WFIR_TYPE WFIR_BLACKMANEXACT
// wfir help
#ifndef M_zPI
#define M_zPI 3.1415926535897932384626433832795
#endif
#define M_zEPS 1e-8
#define M_zBESSELEPS 1e-21
class CzWINDOWEDFIR
{ public:
CzWINDOWEDFIR( );
~CzWINDOWEDFIR( );
float coef( int _PCnr, float _POfs, float _PCut, int _PWidth, int _PType ) //float _PPos, float _PFc, int _PLen )
{ double _LWidthM1 = _PWidth-1;
double _LWidthM1Half = 0.5*_LWidthM1;
double _LPosU = ((double)_PCnr - _POfs);
double _LPos = _LPosU-_LWidthM1Half;
double _LPIdl = 2.0*M_zPI/_LWidthM1;
double _LWc,_LSi;
if( fabs(_LPos)<M_zEPS )
{ _LWc = 1.0;
_LSi = _PCut;
}
else
{ switch( _PType )
{ case WFIR_HANN:
_LWc = 0.50 - 0.50 * cos(_LPIdl*_LPosU);
break;
case WFIR_HAMMING:
_LWc = 0.54 - 0.46 * cos(_LPIdl*_LPosU);
break;
case WFIR_BLACKMANEXACT:
_LWc = 0.42 - 0.50 * cos(_LPIdl*_LPosU) + 0.08 * cos(2.0*_LPIdl*_LPosU);
break;
case WFIR_BLACKMAN3T61:
_LWc = 0.44959 - 0.49364 * cos(_LPIdl*_LPosU) + 0.05677 * cos(2.0*_LPIdl*_LPosU);
break;
case WFIR_BLACKMAN3T67:
_LWc = 0.42323 - 0.49755 * cos(_LPIdl*_LPosU) + 0.07922 * cos(2.0*_LPIdl*_LPosU);
break;
case WFIR_BLACKMAN4T92:
_LWc = 0.35875 - 0.48829 * cos(_LPIdl*_LPosU) + 0.14128 * cos(2.0*_LPIdl*_LPosU) - 0.01168 * cos(3.0*_LPIdl*_LPosU);
break;
case WFIR_BLACKMAN4T74:
_LWc = 0.40217 - 0.49703 * cos(_LPIdl*_LPosU) + 0.09392 * cos(2.0*_LPIdl*_LPosU) - 0.00183 * cos(3.0*_LPIdl*_LPosU);
break;
case WFIR_KAISER4T:
_LWc = 0.40243 - 0.49804 * cos(_LPIdl*_LPosU) + 0.09831 * cos(2.0*_LPIdl*_LPosU) - 0.00122 * cos(3.0*_LPIdl*_LPosU);
break;
default:
_LWc = 1.0;
break;
}
_LPos *= M_zPI;
_LSi = sin(_PCut*_LPos)/_LPos;
}
return (float)(_LWc*_LSi);
}
static signed short lut[WFIR_LUTLEN*WFIR_WIDTH];
};
signed short CzWINDOWEDFIR::lut[WFIR_LUTLEN*WFIR_WIDTH];
CzWINDOWEDFIR::CzWINDOWEDFIR()
{ int _LPcl;
float _LPcllen = (float)(1L<<WFIR_FRACBITS); // number of precalculated lines for 0..1 (-1..0)
float _LNorm = 1.0f / (float)(2.0f * _LPcllen);
float _LCut = WFIR_CUTOFF;
float _LScale = (float)WFIR_QUANTSCALE;
for( _LPcl=0;_LPcl<WFIR_LUTLEN;_LPcl++ )
{ float _LGain,_LCoefs[WFIR_WIDTH];
float _LOfs = ((float)_LPcl-_LPcllen)*_LNorm;
int _LCc,_LIdx = _LPcl<<WFIR_LOG2WIDTH;
for( _LCc=0,_LGain=0.0f;_LCc<WFIR_WIDTH;_LCc++ )
{ _LGain += (_LCoefs[_LCc] = coef( _LCc, _LOfs, _LCut, WFIR_WIDTH, WFIR_TYPE ));
}
_LGain = 1.0f/_LGain;
for( _LCc=0;_LCc<WFIR_WIDTH;_LCc++ )
{ float _LCoef = (float)floor( 0.5 + _LScale*_LCoefs[_LCc]*_LGain );
lut[_LIdx+_LCc] = (signed short)( (_LCoef<-_LScale)?-_LScale:((_LCoef>_LScale)?_LScale:_LCoef) );
}
}
}
CzWINDOWEDFIR::~CzWINDOWEDFIR()
{ // nothing todo
}
CzWINDOWEDFIR sfir;
// ------------------------------------------------------------------------------------------------
// MIXING MACROS
// ------------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////
// Mixing Macros
#define SNDMIX_BEGINSAMPLELOOP8\
register MODCHANNEL * const pChn = pChannel;\
nPos = pChn->nPosLo;\
const signed char *p = (signed char *)(pChn->pCurrentSample+pChn->nPos);\
if (pChn->dwFlags & CHN_STEREO) p += pChn->nPos;\
int *pvol = pbuffer;\
do {
#define SNDMIX_BEGINSAMPLELOOP16\
register MODCHANNEL * const pChn = pChannel;\
nPos = pChn->nPosLo;\
const signed short *p = (signed short *)(pChn->pCurrentSample+(pChn->nPos*2));\
if (pChn->dwFlags & CHN_STEREO) p += pChn->nPos;\
int *pvol = pbuffer;\
do {
#define SNDMIX_ENDSAMPLELOOP\
nPos += pChn->nInc;\
} while (pvol < pbufmax);\
pChn->nPos += nPos >> 16;\
pChn->nPosLo = nPos & 0xFFFF;
#define SNDMIX_ENDSAMPLELOOP8 SNDMIX_ENDSAMPLELOOP
#define SNDMIX_ENDSAMPLELOOP16 SNDMIX_ENDSAMPLELOOP
//////////////////////////////////////////////////////////////////////////////
// Mono
// No interpolation
#define SNDMIX_GETMONOVOL8NOIDO\
int vol = p[nPos >> 16] << 8;
#define SNDMIX_GETMONOVOL16NOIDO\
int vol = p[nPos >> 16];
// Linear Interpolation
#define SNDMIX_GETMONOVOL8LINEAR\
int poshi = nPos >> 16;\
int poslo = (nPos >> 8) & 0xFF;\
int srcvol = p[poshi];\
int destvol = p[poshi+1];\
int vol = (srcvol<<8) + ((int)(poslo * (destvol - srcvol)));
#define SNDMIX_GETMONOVOL16LINEAR\
int poshi = nPos >> 16;\
int poslo = (nPos >> 8) & 0xFF;\
int srcvol = p[poshi];\
int destvol = p[poshi+1];\
int vol = srcvol + ((int)(poslo * (destvol - srcvol)) >> 8);
// spline interpolation (2 guard bits should be enough???)
#define SPLINE_FRACSHIFT ((16-SPLINE_FRACBITS)-2)
#define SPLINE_FRACMASK (((1L<<(16-SPLINE_FRACSHIFT))-1)&~3)
#define SNDMIX_GETMONOVOL8SPLINE \
int poshi = nPos >> 16; \
int poslo = (nPos >> SPLINE_FRACSHIFT) & SPLINE_FRACMASK; \
int vol = (CzCUBICSPLINE::lut[poslo ]*(int)p[poshi-1] + \
CzCUBICSPLINE::lut[poslo+1]*(int)p[poshi ] + \
CzCUBICSPLINE::lut[poslo+3]*(int)p[poshi+2] + \
CzCUBICSPLINE::lut[poslo+2]*(int)p[poshi+1]) >> SPLINE_8SHIFT;
#define SNDMIX_GETMONOVOL16SPLINE \
int poshi = nPos >> 16; \
int poslo = (nPos >> SPLINE_FRACSHIFT) & SPLINE_FRACMASK; \
int vol = (CzCUBICSPLINE::lut[poslo ]*(int)p[poshi-1] + \
CzCUBICSPLINE::lut[poslo+1]*(int)p[poshi ] + \
CzCUBICSPLINE::lut[poslo+3]*(int)p[poshi+2] + \
CzCUBICSPLINE::lut[poslo+2]*(int)p[poshi+1]) >> SPLINE_16SHIFT;
// fir interpolation
#define WFIR_FRACSHIFT (16-(WFIR_FRACBITS+1+WFIR_LOG2WIDTH))
#define WFIR_FRACMASK ((((1L<<(17-WFIR_FRACSHIFT))-1)&~((1L<<WFIR_LOG2WIDTH)-1)))
#define WFIR_FRACHALVE (1L<<(16-(WFIR_FRACBITS+2)))
#define SNDMIX_GETMONOVOL8FIRFILTER \
int poshi = nPos >> 16;\
int poslo = (nPos & 0xFFFF);\
int firidx = ((poslo+WFIR_FRACHALVE)>>WFIR_FRACSHIFT) & WFIR_FRACMASK; \
int vol = (CzWINDOWEDFIR::lut[firidx+0]*(int)p[poshi+1-4]); \
vol += (CzWINDOWEDFIR::lut[firidx+1]*(int)p[poshi+2-4]); \
vol += (CzWINDOWEDFIR::lut[firidx+2]*(int)p[poshi+3-4]); \
vol += (CzWINDOWEDFIR::lut[firidx+3]*(int)p[poshi+4-4]); \
vol += (CzWINDOWEDFIR::lut[firidx+4]*(int)p[poshi+5-4]); \
vol += (CzWINDOWEDFIR::lut[firidx+5]*(int)p[poshi+6-4]); \
vol += (CzWINDOWEDFIR::lut[firidx+6]*(int)p[poshi+7-4]); \
vol += (CzWINDOWEDFIR::lut[firidx+7]*(int)p[poshi+8-4]); \
vol >>= WFIR_8SHIFT;
#define SNDMIX_GETMONOVOL16FIRFILTER \
int poshi = nPos >> 16;\
int poslo = (nPos & 0xFFFF);\
int firidx = ((poslo+WFIR_FRACHALVE)>>WFIR_FRACSHIFT) & WFIR_FRACMASK; \
int vol1 = (CzWINDOWEDFIR::lut[firidx+0]*(int)p[poshi+1-4]); \
vol1 += (CzWINDOWEDFIR::lut[firidx+1]*(int)p[poshi+2-4]); \
vol1 += (CzWINDOWEDFIR::lut[firidx+2]*(int)p[poshi+3-4]); \
vol1 += (CzWINDOWEDFIR::lut[firidx+3]*(int)p[poshi+4-4]); \
int vol2 = (CzWINDOWEDFIR::lut[firidx+4]*(int)p[poshi+5-4]); \
vol2 += (CzWINDOWEDFIR::lut[firidx+5]*(int)p[poshi+6-4]); \
vol2 += (CzWINDOWEDFIR::lut[firidx+6]*(int)p[poshi+7-4]); \
vol2 += (CzWINDOWEDFIR::lut[firidx+7]*(int)p[poshi+8-4]); \
int vol = ((vol1>>1)+(vol2>>1)) >> (WFIR_16BITSHIFT-1);
/////////////////////////////////////////////////////////////////////////////
// Stereo
// No interpolation
#define SNDMIX_GETSTEREOVOL8NOIDO\
int vol_l = p[(nPos>>16)*2] << 8;\
int vol_r = p[(nPos>>16)*2+1] << 8;
#define SNDMIX_GETSTEREOVOL16NOIDO\
int vol_l = p[(nPos>>16)*2];\
int vol_r = p[(nPos>>16)*2+1];
// Linear Interpolation
#define SNDMIX_GETSTEREOVOL8LINEAR\
int poshi = nPos >> 16;\
int poslo = (nPos >> 8) & 0xFF;\
int srcvol_l = p[poshi*2];\
int vol_l = (srcvol_l<<8) + ((int)(poslo * (p[poshi*2+2] - srcvol_l)));\
int srcvol_r = p[poshi*2+1];\
int vol_r = (srcvol_r<<8) + ((int)(poslo * (p[poshi*2+3] - srcvol_r)));
#define SNDMIX_GETSTEREOVOL16LINEAR\
int poshi = nPos >> 16;\
int poslo = (nPos >> 8) & 0xFF;\
int srcvol_l = p[poshi*2];\
int vol_l = srcvol_l + ((int)(poslo * (p[poshi*2+2] - srcvol_l)) >> 8);\
int srcvol_r = p[poshi*2+1];\
int vol_r = srcvol_r + ((int)(poslo * (p[poshi*2+3] - srcvol_r)) >> 8);\
// Spline Interpolation
#define SNDMIX_GETSTEREOVOL8SPLINE \
int poshi = nPos >> 16; \
int poslo = (nPos >> SPLINE_FRACSHIFT) & SPLINE_FRACMASK; \
int vol_l = (CzCUBICSPLINE::lut[poslo ]*(int)p[(poshi-1)*2 ] + \
CzCUBICSPLINE::lut[poslo+1]*(int)p[(poshi )*2 ] + \
CzCUBICSPLINE::lut[poslo+2]*(int)p[(poshi+1)*2 ] + \
CzCUBICSPLINE::lut[poslo+3]*(int)p[(poshi+2)*2 ]) >> SPLINE_8SHIFT; \
int vol_r = (CzCUBICSPLINE::lut[poslo ]*(int)p[(poshi-1)*2+1] + \
CzCUBICSPLINE::lut[poslo+1]*(int)p[(poshi )*2+1] + \
CzCUBICSPLINE::lut[poslo+2]*(int)p[(poshi+1)*2+1] + \
CzCUBICSPLINE::lut[poslo+3]*(int)p[(poshi+2)*2+1]) >> SPLINE_8SHIFT;
#define SNDMIX_GETSTEREOVOL16SPLINE \
int poshi = nPos >> 16; \
int poslo = (nPos >> SPLINE_FRACSHIFT) & SPLINE_FRACMASK; \
int vol_l = (CzCUBICSPLINE::lut[poslo ]*(int)p[(poshi-1)*2 ] + \
CzCUBICSPLINE::lut[poslo+1]*(int)p[(poshi )*2 ] + \
CzCUBICSPLINE::lut[poslo+2]*(int)p[(poshi+1)*2 ] + \
CzCUBICSPLINE::lut[poslo+3]*(int)p[(poshi+2)*2 ]) >> SPLINE_16SHIFT; \
int vol_r = (CzCUBICSPLINE::lut[poslo ]*(int)p[(poshi-1)*2+1] + \
CzCUBICSPLINE::lut[poslo+1]*(int)p[(poshi )*2+1] + \
CzCUBICSPLINE::lut[poslo+2]*(int)p[(poshi+1)*2+1] + \
CzCUBICSPLINE::lut[poslo+3]*(int)p[(poshi+2)*2+1]) >> SPLINE_16SHIFT;
// fir interpolation
#define SNDMIX_GETSTEREOVOL8FIRFILTER \
int poshi = nPos >> 16;\
int poslo = (nPos & 0xFFFF);\
int firidx = ((poslo+WFIR_FRACHALVE)>>WFIR_FRACSHIFT) & WFIR_FRACMASK; \
int vol_l = (CzWINDOWEDFIR::lut[firidx+0]*(int)p[(poshi+1-4)*2 ]); \
vol_l += (CzWINDOWEDFIR::lut[firidx+1]*(int)p[(poshi+2-4)*2 ]); \
vol_l += (CzWINDOWEDFIR::lut[firidx+2]*(int)p[(poshi+3-4)*2 ]); \
vol_l += (CzWINDOWEDFIR::lut[firidx+3]*(int)p[(poshi+4-4)*2 ]); \
vol_l += (CzWINDOWEDFIR::lut[firidx+4]*(int)p[(poshi+5-4)*2 ]); \
vol_l += (CzWINDOWEDFIR::lut[firidx+5]*(int)p[(poshi+6-4)*2 ]); \
vol_l += (CzWINDOWEDFIR::lut[firidx+6]*(int)p[(poshi+7-4)*2 ]); \
vol_l += (CzWINDOWEDFIR::lut[firidx+7]*(int)p[(poshi+8-4)*2 ]); \
vol_l >>= WFIR_8SHIFT; \
int vol_r = (CzWINDOWEDFIR::lut[firidx+0]*(int)p[(poshi+1-4)*2+1]); \
vol_r += (CzWINDOWEDFIR::lut[firidx+1]*(int)p[(poshi+2-4)*2+1]); \
vol_r += (CzWINDOWEDFIR::lut[firidx+2]*(int)p[(poshi+3-4)*2+1]); \
vol_r += (CzWINDOWEDFIR::lut[firidx+3]*(int)p[(poshi+4-4)*2+1]); \
vol_r += (CzWINDOWEDFIR::lut[firidx+4]*(int)p[(poshi+5-4)*2+1]); \
vol_r += (CzWINDOWEDFIR::lut[firidx+5]*(int)p[(poshi+6-4)*2+1]); \
vol_r += (CzWINDOWEDFIR::lut[firidx+6]*(int)p[(poshi+7-4)*2+1]); \
vol_r += (CzWINDOWEDFIR::lut[firidx+7]*(int)p[(poshi+8-4)*2+1]); \
vol_r >>= WFIR_8SHIFT;
#define SNDMIX_GETSTEREOVOL16FIRFILTER \
int poshi = nPos >> 16;\
int poslo = (nPos & 0xFFFF);\
int firidx = ((poslo+WFIR_FRACHALVE)>>WFIR_FRACSHIFT) & WFIR_FRACMASK; \
int vol1_l = (CzWINDOWEDFIR::lut[firidx+0]*(int)p[(poshi+1-4)*2 ]); \
vol1_l += (CzWINDOWEDFIR::lut[firidx+1]*(int)p[(poshi+2-4)*2 ]); \
vol1_l += (CzWINDOWEDFIR::lut[firidx+2]*(int)p[(poshi+3-4)*2 ]); \
vol1_l += (CzWINDOWEDFIR::lut[firidx+3]*(int)p[(poshi+4-4)*2 ]); \
int vol2_l = (CzWINDOWEDFIR::lut[firidx+4]*(int)p[(poshi+5-4)*2 ]); \
vol2_l += (CzWINDOWEDFIR::lut[firidx+5]*(int)p[(poshi+6-4)*2 ]); \
vol2_l += (CzWINDOWEDFIR::lut[firidx+6]*(int)p[(poshi+7-4)*2 ]); \
vol2_l += (CzWINDOWEDFIR::lut[firidx+7]*(int)p[(poshi+8-4)*2 ]); \
int vol_l = ((vol1_l>>1)+(vol2_l>>1)) >> (WFIR_16BITSHIFT-1); \
int vol1_r = (CzWINDOWEDFIR::lut[firidx+0]*(int)p[(poshi+1-4)*2+1]); \
vol1_r += (CzWINDOWEDFIR::lut[firidx+1]*(int)p[(poshi+2-4)*2+1]); \
vol1_r += (CzWINDOWEDFIR::lut[firidx+2]*(int)p[(poshi+3-4)*2+1]); \
vol1_r += (CzWINDOWEDFIR::lut[firidx+3]*(int)p[(poshi+4-4)*2+1]); \
int vol2_r = (CzWINDOWEDFIR::lut[firidx+4]*(int)p[(poshi+5-4)*2+1]); \
vol2_r += (CzWINDOWEDFIR::lut[firidx+5]*(int)p[(poshi+6-4)*2+1]); \
vol2_r += (CzWINDOWEDFIR::lut[firidx+6]*(int)p[(poshi+7-4)*2+1]); \
vol2_r += (CzWINDOWEDFIR::lut[firidx+7]*(int)p[(poshi+8-4)*2+1]); \
int vol_r = ((vol1_r>>1)+(vol2_r>>1)) >> (WFIR_16BITSHIFT-1);
/////////////////////////////////////////////////////////////////////////////
#define SNDMIX_STOREMONOVOL\
pvol[0] += vol * pChn->nRightVol;\
pvol[1] += vol * pChn->nLeftVol;\
pvol += 2;
#define SNDMIX_STORESTEREOVOL\
pvol[0] += vol_l * pChn->nRightVol;\
pvol[1] += vol_r * pChn->nLeftVol;\
pvol += 2;
#define SNDMIX_STOREFASTMONOVOL\
int v = vol * pChn->nRightVol;\
pvol[0] += v;\
pvol[1] += v;\
pvol += 2;
#define SNDMIX_RAMPMONOVOL\
nRampLeftVol += pChn->nLeftRamp;\
nRampRightVol += pChn->nRightRamp;\
pvol[0] += vol * (nRampRightVol >> VOLUMERAMPPRECISION);\
pvol[1] += vol * (nRampLeftVol >> VOLUMERAMPPRECISION);\
pvol += 2;
#define SNDMIX_RAMPFASTMONOVOL\
nRampRightVol += pChn->nRightRamp;\
int fastvol = vol * (nRampRightVol >> VOLUMERAMPPRECISION);\
pvol[0] += fastvol;\
pvol[1] += fastvol;\
pvol += 2;
#define SNDMIX_RAMPSTEREOVOL\
nRampLeftVol += pChn->nLeftRamp;\
nRampRightVol += pChn->nRightRamp;\
pvol[0] += vol_l * (nRampRightVol >> VOLUMERAMPPRECISION);\
pvol[1] += vol_r * (nRampLeftVol >> VOLUMERAMPPRECISION);\
pvol += 2;
///////////////////////////////////////////////////
// Resonant Filters
// Mono
#define MIX_BEGIN_FILTER\
int fy1 = pChannel->nFilter_Y1;\
int fy2 = pChannel->nFilter_Y2;\
#define MIX_END_FILTER\
pChannel->nFilter_Y1 = fy1;\
pChannel->nFilter_Y2 = fy2;
#define SNDMIX_PROCESSFILTER\
vol = (vol * pChn->nFilter_A0 + fy1 * pChn->nFilter_B0 + fy2 * pChn->nFilter_B1 + 4096) >> 13;\
fy2 = fy1;\
fy1 = vol;\
// Stereo
#define MIX_BEGIN_STEREO_FILTER\
int fy1 = pChannel->nFilter_Y1;\
int fy2 = pChannel->nFilter_Y2;\
int fy3 = pChannel->nFilter_Y3;\
int fy4 = pChannel->nFilter_Y4;\
#define MIX_END_STEREO_FILTER\
pChannel->nFilter_Y1 = fy1;\
pChannel->nFilter_Y2 = fy2;\
pChannel->nFilter_Y3 = fy3;\
pChannel->nFilter_Y4 = fy4;\
#define SNDMIX_PROCESSSTEREOFILTER\
vol_l = (vol_l * pChn->nFilter_A0 + fy1 * pChn->nFilter_B0 + fy2 * pChn->nFilter_B1 + 4096) >> 13;\
vol_r = (vol_r * pChn->nFilter_A0 + fy3 * pChn->nFilter_B0 + fy4 * pChn->nFilter_B1 + 4096) >> 13;\
fy2 = fy1; fy1 = vol_l;\
fy4 = fy3; fy3 = vol_r;\
//////////////////////////////////////////////////////////
// Interfaces
typedef VOID (MPPASMCALL * LPMIXINTERFACE)(MODCHANNEL *, int *, int *);
#define BEGIN_MIX_INTERFACE(func)\
VOID MPPASMCALL func(MODCHANNEL *pChannel, int *pbuffer, int *pbufmax)\
{\
LONG nPos;
#define END_MIX_INTERFACE()\
SNDMIX_ENDSAMPLELOOP\
}
// Volume Ramps
#define BEGIN_RAMPMIX_INTERFACE(func)\
BEGIN_MIX_INTERFACE(func)\
LONG nRampRightVol = pChannel->nRampRightVol;\
LONG nRampLeftVol = pChannel->nRampLeftVol;
#define END_RAMPMIX_INTERFACE()\
SNDMIX_ENDSAMPLELOOP\
pChannel->nRampRightVol = nRampRightVol;\
pChannel->nRightVol = nRampRightVol >> VOLUMERAMPPRECISION;\
pChannel->nRampLeftVol = nRampLeftVol;\
pChannel->nLeftVol = nRampLeftVol >> VOLUMERAMPPRECISION;\
}
#define BEGIN_FASTRAMPMIX_INTERFACE(func)\
BEGIN_MIX_INTERFACE(func)\
LONG nRampRightVol = pChannel->nRampRightVol;
#define END_FASTRAMPMIX_INTERFACE()\
SNDMIX_ENDSAMPLELOOP\
pChannel->nRampRightVol = nRampRightVol;\
pChannel->nRampLeftVol = nRampRightVol;\
pChannel->nRightVol = nRampRightVol >> VOLUMERAMPPRECISION;\
pChannel->nLeftVol = pChannel->nRightVol;\
}
// Mono Resonant Filters
#define BEGIN_MIX_FLT_INTERFACE(func)\
BEGIN_MIX_INTERFACE(func)\
MIX_BEGIN_FILTER
#define END_MIX_FLT_INTERFACE()\
SNDMIX_ENDSAMPLELOOP\
MIX_END_FILTER\
}
#define BEGIN_RAMPMIX_FLT_INTERFACE(func)\
BEGIN_MIX_INTERFACE(func)\
LONG nRampRightVol = pChannel->nRampRightVol;\
LONG nRampLeftVol = pChannel->nRampLeftVol;\
MIX_BEGIN_FILTER
#define END_RAMPMIX_FLT_INTERFACE()\
SNDMIX_ENDSAMPLELOOP\
MIX_END_FILTER\
pChannel->nRampRightVol = nRampRightVol;\
pChannel->nRightVol = nRampRightVol >> VOLUMERAMPPRECISION;\
pChannel->nRampLeftVol = nRampLeftVol;\
pChannel->nLeftVol = nRampLeftVol >> VOLUMERAMPPRECISION;\
}
// Stereo Resonant Filters
#define BEGIN_MIX_STFLT_INTERFACE(func)\
BEGIN_MIX_INTERFACE(func)\
MIX_BEGIN_STEREO_FILTER
#define END_MIX_STFLT_INTERFACE()\
SNDMIX_ENDSAMPLELOOP\
MIX_END_STEREO_FILTER\
}
#define BEGIN_RAMPMIX_STFLT_INTERFACE(func)\
BEGIN_MIX_INTERFACE(func)\
LONG nRampRightVol = pChannel->nRampRightVol;\
LONG nRampLeftVol = pChannel->nRampLeftVol;\
MIX_BEGIN_STEREO_FILTER
#define END_RAMPMIX_STFLT_INTERFACE()\
SNDMIX_ENDSAMPLELOOP\
MIX_END_STEREO_FILTER\
pChannel->nRampRightVol = nRampRightVol;\
pChannel->nRightVol = nRampRightVol >> VOLUMERAMPPRECISION;\
pChannel->nRampLeftVol = nRampLeftVol;\
pChannel->nLeftVol = nRampLeftVol >> VOLUMERAMPPRECISION;\
}
/////////////////////////////////////////////////////
//
void MPPASMCALL X86_InitMixBuffer(int *pBuffer, UINT nSamples);
void MPPASMCALL X86_EndChannelOfs(MODCHANNEL *pChannel, int *pBuffer, UINT nSamples);
void MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs);
void X86_StereoMixToFloat(const int *, float *, float *, UINT nCount);
void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount);
/////////////////////////////////////////////////////
// Mono samples functions
BEGIN_MIX_INTERFACE(Mono8BitMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8NOIDO
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Mono16BitMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16NOIDO
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Mono8BitLinearMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8LINEAR
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Mono16BitLinearMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16LINEAR
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Mono8BitSplineMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8SPLINE
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Mono16BitSplineMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16SPLINE
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Mono8BitFirFilterMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8FIRFILTER
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Mono16BitFirFilterMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16FIRFILTER
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
// Volume Ramps
BEGIN_RAMPMIX_INTERFACE(Mono8BitRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8NOIDO
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Mono16BitRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16NOIDO
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Mono8BitLinearRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8LINEAR
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Mono16BitLinearRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16LINEAR
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Mono8BitSplineRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8SPLINE
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Mono16BitSplineRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16SPLINE
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Mono8BitFirFilterRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8FIRFILTER
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Mono16BitFirFilterRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16FIRFILTER
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
//////////////////////////////////////////////////////
// Fast mono mix for leftvol=rightvol (1 less imul)
BEGIN_MIX_INTERFACE(FastMono8BitMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8NOIDO
SNDMIX_STOREFASTMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(FastMono16BitMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16NOIDO
SNDMIX_STOREFASTMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(FastMono8BitLinearMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8LINEAR
SNDMIX_STOREFASTMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(FastMono16BitLinearMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16LINEAR
SNDMIX_STOREFASTMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(FastMono8BitSplineMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8SPLINE
SNDMIX_STOREFASTMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(FastMono16BitSplineMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16SPLINE
SNDMIX_STOREFASTMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(FastMono8BitFirFilterMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8FIRFILTER
SNDMIX_STOREFASTMONOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(FastMono16BitFirFilterMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16FIRFILTER
SNDMIX_STOREFASTMONOVOL
END_MIX_INTERFACE()
// Fast Ramps
BEGIN_FASTRAMPMIX_INTERFACE(FastMono8BitRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8NOIDO
SNDMIX_RAMPFASTMONOVOL
END_FASTRAMPMIX_INTERFACE()
BEGIN_FASTRAMPMIX_INTERFACE(FastMono16BitRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16NOIDO
SNDMIX_RAMPFASTMONOVOL
END_FASTRAMPMIX_INTERFACE()
BEGIN_FASTRAMPMIX_INTERFACE(FastMono8BitLinearRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8LINEAR
SNDMIX_RAMPFASTMONOVOL
END_FASTRAMPMIX_INTERFACE()
BEGIN_FASTRAMPMIX_INTERFACE(FastMono16BitLinearRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16LINEAR
SNDMIX_RAMPFASTMONOVOL
END_FASTRAMPMIX_INTERFACE()
BEGIN_FASTRAMPMIX_INTERFACE(FastMono8BitSplineRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8SPLINE
SNDMIX_RAMPFASTMONOVOL
END_FASTRAMPMIX_INTERFACE()
BEGIN_FASTRAMPMIX_INTERFACE(FastMono16BitSplineRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16SPLINE
SNDMIX_RAMPFASTMONOVOL
END_FASTRAMPMIX_INTERFACE()
BEGIN_FASTRAMPMIX_INTERFACE(FastMono8BitFirFilterRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8FIRFILTER
SNDMIX_RAMPFASTMONOVOL
END_FASTRAMPMIX_INTERFACE()
BEGIN_FASTRAMPMIX_INTERFACE(FastMono16BitFirFilterRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16FIRFILTER
SNDMIX_RAMPFASTMONOVOL
END_FASTRAMPMIX_INTERFACE()
//////////////////////////////////////////////////////
// Stereo samples
BEGIN_MIX_INTERFACE(Stereo8BitMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETSTEREOVOL8NOIDO
SNDMIX_STORESTEREOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Stereo16BitMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETSTEREOVOL16NOIDO
SNDMIX_STORESTEREOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Stereo8BitLinearMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETSTEREOVOL8LINEAR
SNDMIX_STORESTEREOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Stereo16BitLinearMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETSTEREOVOL16LINEAR
SNDMIX_STORESTEREOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Stereo8BitSplineMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETSTEREOVOL8SPLINE
SNDMIX_STORESTEREOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Stereo16BitSplineMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETSTEREOVOL16SPLINE
SNDMIX_STORESTEREOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Stereo8BitFirFilterMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETSTEREOVOL8FIRFILTER
SNDMIX_STORESTEREOVOL
END_MIX_INTERFACE()
BEGIN_MIX_INTERFACE(Stereo16BitFirFilterMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETSTEREOVOL16FIRFILTER
SNDMIX_STORESTEREOVOL
END_MIX_INTERFACE()
// Volume Ramps
BEGIN_RAMPMIX_INTERFACE(Stereo8BitRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETSTEREOVOL8NOIDO
SNDMIX_RAMPSTEREOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Stereo16BitRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETSTEREOVOL16NOIDO
SNDMIX_RAMPSTEREOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Stereo8BitLinearRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETSTEREOVOL8LINEAR
SNDMIX_RAMPSTEREOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Stereo16BitLinearRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETSTEREOVOL16LINEAR
SNDMIX_RAMPSTEREOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Stereo8BitSplineRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETSTEREOVOL8SPLINE
SNDMIX_RAMPSTEREOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Stereo16BitSplineRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETSTEREOVOL16SPLINE
SNDMIX_RAMPSTEREOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Stereo8BitFirFilterRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETSTEREOVOL8FIRFILTER
SNDMIX_RAMPSTEREOVOL
END_RAMPMIX_INTERFACE()
BEGIN_RAMPMIX_INTERFACE(Stereo16BitFirFilterRampMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETSTEREOVOL16FIRFILTER
SNDMIX_RAMPSTEREOVOL
END_RAMPMIX_INTERFACE()
//////////////////////////////////////////////////////
// Resonant Filter Mix
#ifndef NO_FILTER
// Mono Filter Mix
BEGIN_MIX_FLT_INTERFACE(FilterMono8BitMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8NOIDO
SNDMIX_PROCESSFILTER
SNDMIX_STOREMONOVOL
END_MIX_FLT_INTERFACE()
BEGIN_MIX_FLT_INTERFACE(FilterMono16BitMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16NOIDO
SNDMIX_PROCESSFILTER
SNDMIX_STOREMONOVOL
END_MIX_FLT_INTERFACE()
BEGIN_MIX_FLT_INTERFACE(FilterMono8BitLinearMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8LINEAR
SNDMIX_PROCESSFILTER
SNDMIX_STOREMONOVOL
END_MIX_FLT_INTERFACE()
BEGIN_MIX_FLT_INTERFACE(FilterMono16BitLinearMix)
SNDMIX_BEGINSAMPLELOOP16
SNDMIX_GETMONOVOL16LINEAR
SNDMIX_PROCESSFILTER
SNDMIX_STOREMONOVOL