1 /*
2 * MixFuncTable.cpp
3 * ----------------
4 * Purpose: Table containing all mixer functions.
5 * Notes : The Visual Studio project settings for this file have been adjusted
6 * to force function inlining, so that the mixer has a somewhat acceptable
7 * performance in debug mode. If you need to debug anything here, be sure
8 * to disable those optimizations if needed.
9 * Authors: OpenMPT Devs
10 * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
11 */
12
13
14 #include "stdafx.h"
15
16 #include "Mixer.h"
17 #include "Snd_defs.h"
18 #include "ModChannel.h"
19 #include "MixFuncTable.h"
20
21 #ifdef MPT_INTMIXER
22 #include "IntMixer.h"
23 #else
24 #include "FloatMixer.h"
25 #endif // MPT_INTMIXER
26
27 OPENMPT_NAMESPACE_BEGIN
28
29 namespace MixFuncTable
30 {
31 #ifdef MPT_INTMIXER
32 using I8M = Int8MToIntS;
33 using I16M = Int16MToIntS;
34 using I8S = Int8SToIntS;
35 using I16S = Int16SToIntS;
36 #else
37 using I8M = Int8MToFloatS;
38 using I16M = Int16MToFloatS;
39 using I8S = Int8SToFloatS;
40 using I16S = Int16SToFloatS;
41 #endif // MPT_INTMIXER
42
43 // Build mix function table for given resampling, filter and ramping settings: One function each for 8-Bit / 16-Bit Mono / Stereo
44 #define BuildMixFuncTableRamp(resampling, filter, ramp) \
45 SampleLoop<I8M, resampling<I8M>, filter<I8M>, MixMono ## ramp<I8M> >, \
46 SampleLoop<I16M, resampling<I16M>, filter<I16M>, MixMono ## ramp<I16M> >, \
47 SampleLoop<I8S, resampling<I8S>, filter<I8S>, MixStereo ## ramp<I8S> >, \
48 SampleLoop<I16S, resampling<I16S>, filter<I16S>, MixStereo ## ramp<I16S> >
49
50 // Build mix function table for given resampling, filter settings: With and without ramping
51 #define BuildMixFuncTableFilter(resampling, filter) \
52 BuildMixFuncTableRamp(resampling, filter, NoRamp), \
53 BuildMixFuncTableRamp(resampling, filter, Ramp)
54
55 // Build mix function table for given resampling settings: With and without filter
56 #define BuildMixFuncTable(resampling) \
57 BuildMixFuncTableFilter(resampling, NoFilter), \
58 BuildMixFuncTableFilter(resampling, ResonantFilter)
59
60 const MixFuncInterface Functions[6 * 16] =
61 {
62 BuildMixFuncTable(NoInterpolation), // No SRC
63 BuildMixFuncTable(LinearInterpolation), // Linear SRC
64 BuildMixFuncTable(FastSincInterpolation), // Fast Sinc (Cubic Spline) SRC
65 BuildMixFuncTable(PolyphaseInterpolation), // Kaiser SRC
66 BuildMixFuncTable(FIRFilterInterpolation), // FIR SRC
67 BuildMixFuncTable(AmigaBlepInterpolation), // Amiga emulation
68 };
69
70 #undef BuildMixFuncTableRamp
71 #undef BuildMixFuncTableFilter
72 #undef BuildMixFuncTable
73
74
ResamplingModeToMixFlags(ResamplingMode resamplingMode)75 ResamplingIndex ResamplingModeToMixFlags(ResamplingMode resamplingMode)
76 {
77 switch(resamplingMode)
78 {
79 case SRCMODE_NEAREST: return ndxNoInterpolation;
80 case SRCMODE_LINEAR: return ndxLinear;
81 case SRCMODE_CUBIC: return ndxFastSinc;
82 case SRCMODE_SINC8LP: return ndxKaiser;
83 case SRCMODE_SINC8: return ndxFIRFilter;
84 case SRCMODE_AMIGA: return ndxAmigaBlep;
85 default: MPT_ASSERT_NOTREACHED();
86 }
87 return ndxNoInterpolation;
88 }
89
90 } // namespace MixFuncTable
91
92 OPENMPT_NAMESPACE_END
93