Skip to content

Commit 5137f5d

Browse files
committed
Fix a mixer/voice delta problem when voice vol is zero
1 parent 452664b commit 5137f5d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ft2_header.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#endif
1313
#include "ft2_replayer.h"
1414

15-
#define PROG_VER_STR "1.90"
15+
#define PROG_VER_STR "1.91"
1616

1717
// do NOT change these! It will only mess things up...
1818

src/mixer/ft2_silence_mix.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
void silenceMixRoutine(voice_t *v, int32_t numSamples)
88
{
9-
assert((uint32_t)numSamples <= UINT16_MAX);
9+
const uint64_t samplesToMix = (uint64_t)v->delta * (uint32_t)numSamples; // fixed-point
1010

11-
const uint32_t samplesInt = (uint32_t)(v->delta >> MIXER_FRAC_BITS) * (uint32_t)numSamples;
12-
const uint64_t samplesFrac = (uint64_t)(v->delta & MIXER_FRAC_SCALE) * (uint32_t)numSamples;
11+
const uint32_t samples = (uint32_t)(samplesToMix >> MIXER_FRAC_BITS);
12+
const uint64_t samplesFrac = (samplesToMix & MIXER_FRAC_MASK) + v->positionFrac;
1313

14-
uint32_t position = v->position + samplesInt + (uint32_t)(samplesFrac >> MIXER_FRAC_BITS);
15-
uint32_t positionFrac = samplesFrac & MIXER_FRAC_MASK;
14+
uint32_t position = v->position + samples + (uint32_t)(samplesFrac >> MIXER_FRAC_BITS);
15+
uint64_t positionFrac = samplesFrac & MIXER_FRAC_MASK;
1616

1717
if (position < (uint32_t)v->sampleEnd) // we haven't reached the sample's end yet
1818
{

0 commit comments

Comments
 (0)