Another Lanczos optimisation

This commit is contained in:
Clownacy 2020-09-03 14:38:56 +01:00
parent 67ee8b9829
commit 47543eb382

View file

@ -195,18 +195,20 @@ ATTRIBUTE_HOT void Mixer_MixSounds(long *stream, size_t frames_total)
}
}
const short output_sample = (short)(accumulator * 0x100);
// Mix, and apply volume
*stream_pointer++ += (short)(accumulator * sound->volume_l);
*stream_pointer++ += (short)(accumulator * sound->volume_r);
#else
// Perform linear interpolation
const unsigned char interpolation_scale = sound->position_subsample >> 8;
const short output_sample = sound->samples[sound->position] * (0x100 - interpolation_scale)
+ sound->samples[sound->position + 1] * interpolation_scale;
#endif
// Mix, and apply volume
*stream_pointer++ += (output_sample * sound->volume_l) >> 8;
*stream_pointer++ += (output_sample * sound->volume_r) >> 8;
#endif
// Increment sample
const unsigned long next_position_subsample = sound->position_subsample + sound->advance_delta;