Skip to content

Commit

Permalink
Fixed MOD2WAV bug when tracker audio freq >= 96kHz
Browse files Browse the repository at this point in the history
  • Loading branch information
8bitbubsy committed Dec 26, 2022
1 parent 88b7810 commit 02378ef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pt2_mod2wav.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ static void showMod2WavProgress(void)

static void resetAudio(void)
{
audio.oversamplingFlag = (audio.outputRate < 96000);
const int32_t paulaMixFrequency = audio.oversamplingFlag ? audio.outputRate*2 : audio.outputRate;
paulaSetup(paulaMixFrequency, audio.amigaModel);
generateBpmTable(audio.outputRate, editor.timingMode == TEMPO_MODE_VBLANK);
Expand Down Expand Up @@ -351,7 +352,7 @@ bool mod2WavRender(char *filename)

strncpy(lastFilename, filename, PATH_MAX-1);

const int32_t paulaMixFrequency = config.mod2WavOutputFreq * 2; // *2 for oversampling
const int32_t paulaMixFrequency = config.mod2WavOutputFreq * 2; // *2 for oversampling (we always do oversampling in MOD2WAV)
const uint32_t maxSamplesToMix = (int32_t)ceil(paulaMixFrequency / (REPLAYER_MIN_BPM / 2.5));

mod2WavBuffer = (int16_t *)malloc(((TICKS_PER_RENDER_CHUNK * maxSamplesToMix) + 1) * sizeof (int16_t) * 2);
Expand All @@ -365,6 +366,7 @@ bool mod2WavRender(char *filename)
editor.mod2WavOngoing = true; // set this first

// do some prep work
audio.oversamplingFlag = true;
generateBpmTable(config.mod2WavOutputFreq, editor.timingMode == TEMPO_MODE_VBLANK);
paulaSetup(paulaMixFrequency, audio.amigaModel);
storeTempVariables();
Expand Down

0 comments on commit 02378ef

Please sign in to comment.