-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathMixFuncTable.cpp
91 lines (77 loc) · 2.94 KB
/
MixFuncTable.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
/*
* MixFuncTable.cpp
* ----------------
* Purpose: Table containing all mixer functions.
* Notes : The Visual Studio project settings for this file have been adjusted
* to force function inlining, so that the mixer has a somewhat acceptable
* performance in debug mode. If you need to debug anything here, be sure
* to disable those optimizations if needed.
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#include "stdafx.h"
#include "MixFuncTable.h"
#include "Mixer.h"
#include "ModChannel.h"
#include "Snd_defs.h"
#ifdef MPT_INTMIXER
#include "IntMixer.h"
#else
#include "FloatMixer.h"
#endif // MPT_INTMIXER
OPENMPT_NAMESPACE_BEGIN
namespace MixFuncTable
{
#ifdef MPT_INTMIXER
using I8M = Int8MToIntS;
using I16M = Int16MToIntS;
using I8S = Int8SToIntS;
using I16S = Int16SToIntS;
#else
using I8M = Int8MToFloatS;
using I16M = Int16MToFloatS;
using I8S = Int8SToFloatS;
using I16S = Int16SToFloatS;
#endif // MPT_INTMIXER
// Build mix function table for given resampling, filter and ramping settings: One function each for 8-Bit / 16-Bit Mono / Stereo
#define BuildMixFuncTableRamp(resampling, filter, ramp) \
SampleLoop<I8M, resampling<I8M>, filter<I8M>, MixMono ## ramp<I8M> >, \
SampleLoop<I16M, resampling<I16M>, filter<I16M>, MixMono ## ramp<I16M> >, \
SampleLoop<I8S, resampling<I8S>, filter<I8S>, MixStereo ## ramp<I8S> >, \
SampleLoop<I16S, resampling<I16S>, filter<I16S>, MixStereo ## ramp<I16S> >
// Build mix function table for given resampling, filter settings: With and without ramping
#define BuildMixFuncTableFilter(resampling, filter) \
BuildMixFuncTableRamp(resampling, filter, NoRamp), \
BuildMixFuncTableRamp(resampling, filter, Ramp)
// Build mix function table for given resampling settings: With and without filter
#define BuildMixFuncTable(resampling) \
BuildMixFuncTableFilter(resampling, NoFilter), \
BuildMixFuncTableFilter(resampling, ResonantFilter)
const MixFuncInterface Functions[6 * 16] =
{
BuildMixFuncTable(NoInterpolation), // No SRC
BuildMixFuncTable(LinearInterpolation), // Linear SRC
BuildMixFuncTable(FastSincInterpolation), // Fast Sinc (Cubic Spline) SRC
BuildMixFuncTable(PolyphaseInterpolation), // Kaiser SRC
BuildMixFuncTable(FIRFilterInterpolation), // FIR SRC
BuildMixFuncTable(AmigaBlepInterpolation), // Amiga emulation
};
#undef BuildMixFuncTableRamp
#undef BuildMixFuncTableFilter
#undef BuildMixFuncTable
ResamplingIndex ResamplingModeToMixFlags(ResamplingMode resamplingMode)
{
switch(resamplingMode)
{
case SRCMODE_NEAREST: return ndxNoInterpolation;
case SRCMODE_LINEAR: return ndxLinear;
case SRCMODE_CUBIC: return ndxFastSinc;
case SRCMODE_SINC8LP: return ndxKaiser;
case SRCMODE_SINC8: return ndxFIRFilter;
case SRCMODE_AMIGA: return ndxAmigaBlep;
default: MPT_ASSERT_NOTREACHED();
}
return ndxNoInterpolation;
}
} // namespace MixFuncTable
OPENMPT_NAMESPACE_END