aboutsummaryrefslogtreecommitdiff
path: root/audio/softsynth/mt32/Analog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'audio/softsynth/mt32/Analog.cpp')
-rw-r--r--audio/softsynth/mt32/Analog.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/audio/softsynth/mt32/Analog.cpp b/audio/softsynth/mt32/Analog.cpp
index a345c77656..8ac28e401a 100644
--- a/audio/softsynth/mt32/Analog.cpp
+++ b/audio/softsynth/mt32/Analog.cpp
@@ -1,5 +1,5 @@
/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
- * Copyright (C) 2011-2016 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, 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
@@ -15,12 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cstring>
-
-#include "internals.h"
-
+//#include <cstring>
#include "Analog.h"
-#include "Synth.h"
namespace MT32Emu {
@@ -110,6 +106,7 @@ static const Bit32u ACCURATE_LPF_DELTAS_OVERSAMPLED[][ACCURATE_LPF_NUMBER_OF_PHA
class AbstractLowPassFilter {
public:
static AbstractLowPassFilter &createLowPassFilter(AnalogOutputMode mode, bool oldMT32AnalogLPF);
+ static void muteRingBuffer(SampleEx *ringBuffer, unsigned int length);
virtual ~AbstractLowPassFilter() {}
virtual SampleEx process(SampleEx sample) = 0;
@@ -155,9 +152,9 @@ public:
void addPositionIncrement(unsigned int positionIncrement);
};
-Analog::Analog(const AnalogOutputMode mode, const bool oldMT32AnalogLPF) :
- leftChannelLPF(AbstractLowPassFilter::createLowPassFilter(mode, oldMT32AnalogLPF)),
- rightChannelLPF(AbstractLowPassFilter::createLowPassFilter(mode, oldMT32AnalogLPF)),
+Analog::Analog(const AnalogOutputMode mode, const ControlROMFeatureSet *controlROMFeatures) :
+ leftChannelLPF(AbstractLowPassFilter::createLowPassFilter(mode, controlROMFeatures->isOldMT32AnalogLPF())),
+ rightChannelLPF(AbstractLowPassFilter::createLowPassFilter(mode, controlROMFeatures->isOldMT32AnalogLPF())),
synthGain(0),
reverbGain(0)
{}
@@ -167,7 +164,7 @@ Analog::~Analog() {
delete &rightChannelLPF;
}
-void Analog::process(Sample *outStream, const Sample *nonReverbLeft, const Sample *nonReverbRight, const Sample *reverbDryLeft, const Sample *reverbDryRight, const Sample *reverbWetLeft, const Sample *reverbWetRight, Bit32u outLength) {
+void Analog::process(Sample **outStream, const Sample *nonReverbLeft, const Sample *nonReverbRight, const Sample *reverbDryLeft, const Sample *reverbDryRight, const Sample *reverbWetLeft, const Sample *reverbWetRight, Bit32u outLength) {
if (outStream == NULL) {
leftChannelLPF.addPositionIncrement(outLength);
rightChannelLPF.addPositionIncrement(outLength);
@@ -194,8 +191,8 @@ void Analog::process(Sample *outStream, const Sample *nonReverbLeft, const Sampl
outSampleR = rightChannelLPF.process(inSampleR);
}
- *(outStream++) = Synth::clipSampleEx(outSampleL);
- *(outStream++) = Synth::clipSampleEx(outSampleR);
+ *((*outStream)++) = Synth::clipSampleEx(outSampleL);
+ *((*outStream)++) = Synth::clipSampleEx(outSampleR);
}
}
@@ -239,6 +236,23 @@ AbstractLowPassFilter &AbstractLowPassFilter::createLowPassFilter(AnalogOutputMo
}
}
+void AbstractLowPassFilter::muteRingBuffer(SampleEx *ringBuffer, unsigned int length) {
+
+#if MT32EMU_USE_FLOAT_SAMPLES
+
+ SampleEx *p = ringBuffer;
+ while (length--) {
+ *(p++) = 0.0f;
+ }
+
+#else
+
+ memset(ringBuffer, 0, length * sizeof(SampleEx));
+
+#endif
+
+}
+
bool AbstractLowPassFilter::hasNextSample() const {
return false;
}
@@ -259,7 +273,7 @@ CoarseLowPassFilter::CoarseLowPassFilter(bool oldMT32AnalogLPF) :
LPF_TAPS(oldMT32AnalogLPF ? COARSE_LPF_TAPS_MT32 : COARSE_LPF_TAPS_CM32L),
ringBufferPosition(0)
{
- Synth::muteSampleBuffer(ringBuffer, COARSE_LPF_DELAY_LINE_LENGTH);
+ muteRingBuffer(ringBuffer, COARSE_LPF_DELAY_LINE_LENGTH);
}
SampleEx CoarseLowPassFilter::process(const SampleEx inSample) {
@@ -289,7 +303,7 @@ AccurateLowPassFilter::AccurateLowPassFilter(const bool oldMT32AnalogLPF, const
ringBufferPosition(0),
phase(0)
{
- Synth::muteSampleBuffer(ringBuffer, ACCURATE_LPF_DELAY_LINE_LENGTH);
+ muteRingBuffer(ringBuffer, ACCURATE_LPF_DELAY_LINE_LENGTH);
}
SampleEx AccurateLowPassFilter::process(const SampleEx inSample) {
@@ -331,4 +345,4 @@ void AccurateLowPassFilter::addPositionIncrement(const unsigned int positionIncr
phase = (phase + positionIncrement * phaseIncrement) % ACCURATE_LPF_NUMBER_OF_PHASES;
}
-} // namespace MT32Emu
+}