namespace MixFuncTable { #ifdef MPT_INTMIXER typedef Int8MToIntS I8M; typedef Int16MToIntS I16M; typedef Int8SToIntS I8S; typedef Int16SToIntS I16S; #else typedef Int8MToFloatS I8M; typedef Int16MToFloatS I16M; typedef Int8SToFloatS I8S; typedef Int16SToFloatS I16S; #endif // MPT_INTMIXER // Table index: // [b1-b0] format (8-bit-mono, 16-bit-mono, 8-bit-stereo, 16-bit-stereo) // [b2] ramp // [b3] filter // [b6-b4] src type // Sample type / processing type index enum FunctionIndex { ndx16Bit = 0x01, ndxStereo = 0x02, ndxRamp = 0x04, ndxFilter = 0x08, }; // SRC index enum ResamplingIndex { ndxNoInterpolation = 0x00, ndxLinear = 0x10, ndxFastSinc = 0x20, ndxKaiser = 0x30, ndxFIRFilter = 0x40, }; // 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[5 * 16] = { BuildMixFuncTable(NoInterpolation), // No SRC BuildMixFuncTable(LinearInterpolation), // Linear SRC BuildMixFuncTable(FastSincInterpolation), // Fast Sinc (Cubic Spline) SRC BuildMixFuncTable(PolyphaseInterpolation), // Kaiser SRC BuildMixFuncTable(FIRFilterInterpolation), // FIR SRC }; #undef BuildMixFuncTableRamp #undef BuildMixFuncTableFilter #undef BuildMixFuncTable static forceinline ResamplingIndex ResamplingModeToMixFlags(uint8 resamplingMode) //------------------------------------------------------------------------------- { switch(resamplingMode) { case SRCMODE_NEAREST: return ndxNoInterpolation; case SRCMODE_LINEAR: return ndxLinear; case SRCMODE_SPLINE: return ndxFastSinc; case SRCMODE_POLYPHASE: return ndxKaiser; case SRCMODE_FIRFILTER: return ndxFIRFilter; } return ndxNoInterpolation; } } // namespace MixFuncTable
namespace MixFuncTable { #ifdef MPT_INTMIXER typedef Int8MToIntS I8M; typedef Int16MToIntS I16M; typedef Int8SToIntS I8S; typedef Int16SToIntS I16S; #else typedef Int8MToFloatS I8M; typedef Int16MToFloatS I16M; typedef Int8SToFloatS I8S; typedef Int16SToFloatS I16S; #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_SPLINE: return ndxFastSinc; case SRCMODE_POLYPHASE: return ndxKaiser; case SRCMODE_FIRFILTER: return ndxFIRFilter; case SRCMODE_AMIGA: return ndxAmigaBlep; default: MPT_ASSERT_NOTREACHED(); } return ndxNoInterpolation; } } // namespace MixFuncTable