ref: 4d6376baddc42450a9ee0f5f862960fd0edd77ab
parent: 1969e6763675792f743c5299de1d78bbe342da22
author: Olav Sørensen <olav.sorensen@live.no>
date: Wed Nov 18 10:16:18 EST 2020
Fix: Filter coeffs were not recalculated during MOD2WAV
--- a/src/pt2_audio.c
+++ b/src/pt2_audio.c
@@ -750,6 +750,28 @@
calcRCFilterCoeffs(audio.outputRate, fc, &filterHiA1200);
}
+void recalcFilterCoeffs(int32_t outputRate) // for MOD2WAV
+{
+ const bool audioWasntLocked = !audio.locked;
+ if (audioWasntLocked)
+ lockAudio();
+
+ const int32_t oldOutputRate = audio.outputRate;
+ audio.outputRate = outputRate;
+
+ clearRCFilterState(&filterLoA500);
+ clearRCFilterState(&filterLoA1200);
+ clearRCFilterState(&filterHiA500);
+ clearRCFilterState(&filterHiA1200);
+ clearLEDFilterState(&filterLED);
+
+ calculateFilterCoeffs();
+
+ audio.outputRate = oldOutputRate;
+ if (audioWasntLocked)
+ unlockAudio();
+}
+
static void setVoicePan(int32_t ch, double pan) // pan = 0.0 .. 1.0
{
// constant power panning
--- a/src/pt2_audio.h
+++ b/src/pt2_audio.h
@@ -54,6 +54,7 @@
void normalizeFloatTo8Bit(float *fSampleData, uint32_t sampleLength);
void normalizeDoubleTo8Bit(double *dSampleData, uint32_t sampleLength);
+void recalcFilterCoeffs(int32_t outputRate); // for MOD2WAV
void setLEDFilter(bool state, bool doLockAudio);
void toggleLEDFilter(void);
void toggleAmigaPanMode(void);
--- a/src/pt2_mod2wav.c
+++ b/src/pt2_mod2wav.c
@@ -35,6 +35,9 @@
// skip wav header place, render data first
fseek(f, sizeof (wavHeader_t), SEEK_SET);
+ if (MOD2WAV_FREQ != audio.outputRate)
+ recalcFilterCoeffs(MOD2WAV_FREQ);
+
wavRenderingDone = false;
uint32_t sampleCounter = 0;
@@ -88,6 +91,9 @@
if (samplesInChunk > 0)
fwrite(mod2WavBuffer, sizeof (int16_t), samplesInChunk, f);
}
+
+ if (MOD2WAV_FREQ != audio.outputRate)
+ recalcFilterCoeffs(audio.outputRate);
free(mod2WavBuffer);