ref: fbcb2f5f56f2b78a0cde85a214045b6008ac0358
parent: b68eb076ca57e489d38ba0ed128a113176d3c1f7
author: Clownacy <Clownacy@users.noreply.github.com>
date: Thu Sep 3 12:01:46 EDT 2020
Optimise the linear-interpolator a little Doesn't have to do two sets of shifts
--- a/src/Backends/Audio/SoftwareMixer.cpp
+++ b/src/Backends/Audio/SoftwareMixer.cpp
@@ -202,12 +202,12 @@
// 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;
+ const signed char output_sample = (sound->samples[sound->position] * (0x100 - interpolation_scale)
+ + sound->samples[sound->position + 1] * interpolation_scale) >> 8;
// Mix, and apply volume
- *stream_pointer++ += (output_sample * sound->volume_l) >> 8;
- *stream_pointer++ += (output_sample * sound->volume_r) >> 8;
+ *stream_pointer++ += output_sample * sound->volume_l;
+ *stream_pointer++ += output_sample * sound->volume_r;
#endif
// Increment sample