ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

commit 5137f5d5af98159def020f575fe094585fc1f549
parent 452664b3e1586c1f7f8cdc3dc890b6adcc0a8c5b
Author: Olav Sørensen <olav.sorensen@live.no>
Date:   Tue, 10 Dec 2024 21:40:15 +0100

Fix a mixer/voice delta problem when voice vol is zero

Diffstat:
Msrc/ft2_header.h | 2+-
Msrc/mixer/ft2_silence_mix.c | 10+++++-----
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/ft2_header.h b/src/ft2_header.h @@ -12,7 +12,7 @@ #endif #include "ft2_replayer.h" -#define PROG_VER_STR "1.90" +#define PROG_VER_STR "1.91" // do NOT change these! It will only mess things up... diff --git a/src/mixer/ft2_silence_mix.c b/src/mixer/ft2_silence_mix.c @@ -6,13 +6,13 @@ void silenceMixRoutine(voice_t *v, int32_t numSamples) { - assert((uint32_t)numSamples <= UINT16_MAX); + const uint64_t samplesToMix = (uint64_t)v->delta * (uint32_t)numSamples; // fixed-point - const uint32_t samplesInt = (uint32_t)(v->delta >> MIXER_FRAC_BITS) * (uint32_t)numSamples; - const uint64_t samplesFrac = (uint64_t)(v->delta & MIXER_FRAC_SCALE) * (uint32_t)numSamples; + const uint32_t samples = (uint32_t)(samplesToMix >> MIXER_FRAC_BITS); + const uint64_t samplesFrac = (samplesToMix & MIXER_FRAC_MASK) + v->positionFrac; - uint32_t position = v->position + samplesInt + (uint32_t)(samplesFrac >> MIXER_FRAC_BITS); - uint32_t positionFrac = samplesFrac & MIXER_FRAC_MASK; + uint32_t position = v->position + samples + (uint32_t)(samplesFrac >> MIXER_FRAC_BITS); + uint64_t positionFrac = samplesFrac & MIXER_FRAC_MASK; if (position < (uint32_t)v->sampleEnd) // we haven't reached the sample's end yet {