Updated the Munt code to 2.4.0 (port from VARCem).

This commit is contained in:
OBattler
2020-06-07 02:06:15 +02:00
parent e109a59a56
commit b2a7a5b90f
74 changed files with 747 additions and 310 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2015-2017 Sergey V. Mikayev
/* Copyright (C) 2015-2020 Sergey V. Mikayev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -14,13 +14,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstddef>
#include "SampleRateConverter.h"
#if MT32EMU_WITH_LIBSOXR_RESAMPLER
#include "srchelper/SoxrAdapter.h"
#elif MT32EMU_WITH_LIBSAMPLERATE_RESAMPLER
#include "srchelper/SamplerateAdapter.h"
#else
#elif MT32EMU_WITH_INTERNAL_RESAMPLER
#include "srchelper/InternalResampler.h"
#endif
@@ -33,8 +35,11 @@ static inline void *createDelegate(Synth &synth, double targetSampleRate, Sample
return new SoxrAdapter(synth, targetSampleRate, quality);
#elif MT32EMU_WITH_LIBSAMPLERATE_RESAMPLER
return new SamplerateAdapter(synth, targetSampleRate, quality);
#else
#elif MT32EMU_WITH_INTERNAL_RESAMPLER
return new InternalResampler(synth, targetSampleRate, quality);
#else
(void)synth, (void)targetSampleRate, (void)quality;
return NULL;
#endif
}
@@ -47,6 +52,15 @@ AnalogOutputMode SampleRateConverter::getBestAnalogOutputMode(double targetSampl
return AnalogOutputMode_COARSE;
}
double SampleRateConverter::getSupportedOutputSampleRate(double desiredSampleRate) {
#if MT32EMU_WITH_LIBSOXR_RESAMPLER || MT32EMU_WITH_LIBSAMPLERATE_RESAMPLER || MT32EMU_WITH_INTERNAL_RESAMPLER
return desiredSampleRate > 0 ? desiredSampleRate : 0;
#else
(void)desiredSampleRate;
return 0;
#endif
}
SampleRateConverter::SampleRateConverter(Synth &useSynth, double targetSampleRate, SamplerateConversionQuality useQuality) :
synthInternalToTargetSampleRateRatio(SAMPLE_RATE / targetSampleRate),
useSynthDelegate(useSynth.getStereoOutputSampleRate() == targetSampleRate),
@@ -59,7 +73,7 @@ SampleRateConverter::~SampleRateConverter() {
delete static_cast<SoxrAdapter *>(srcDelegate);
#elif MT32EMU_WITH_LIBSAMPLERATE_RESAMPLER
delete static_cast<SamplerateAdapter *>(srcDelegate);
#else
#elif MT32EMU_WITH_INTERNAL_RESAMPLER
delete static_cast<InternalResampler *>(srcDelegate);
#endif
}
@@ -75,8 +89,10 @@ void SampleRateConverter::getOutputSamples(float *buffer, unsigned int length) {
static_cast<SoxrAdapter *>(srcDelegate)->getOutputSamples(buffer, length);
#elif MT32EMU_WITH_LIBSAMPLERATE_RESAMPLER
static_cast<SamplerateAdapter *>(srcDelegate)->getOutputSamples(buffer, length);
#else
#elif MT32EMU_WITH_INTERNAL_RESAMPLER
static_cast<InternalResampler *>(srcDelegate)->getOutputSamples(buffer, length);
#else
Synth::muteSampleBuffer(buffer, length);
#endif
}