Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Novak <jnovak@skedulo.com>2022-09-17 03:16:44 +0300
committerJohn Novak <jnovak@skedulo.com>2022-09-17 03:21:38 +0300
commit50dc5fc3ccdd7c91f6131b09b179401d86174b78 (patch)
treee64023a4da8479f72f85604170647004c6e5e6f4
parentf44124df9d099540cb165c49767c7c59835563ab (diff)
Add explanatory comment about resampling methodsjn/zoh-fixes
Only ZoH upsample is channel rate is below ZoH target rate
-rw-r--r--src/hardware/mixer.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/hardware/mixer.cpp b/src/hardware/mixer.cpp
index da6658d6b..281987a22 100644
--- a/src/hardware/mixer.cpp
+++ b/src/hardware/mixer.cpp
@@ -631,6 +631,31 @@ void MixerChannel::Enable(const bool should_enable)
MIXER_UnlockAudioDevice();
}
+// Depending on the resampling method and the channel, mixer and ZoH upsampler
+// rates, the following scenarios are possible:
+//
+// LinearInterpolation
+// -------------------
+// - Linear interpolation resampling only if channel_rate != mixer_rate
+//
+// ZeroOrderHoldAndResample
+// ------------------------
+// - neither ZoH upsampling nor Speex resampling if:
+// channel_rate >= zoh_target_rate AND channel_rate == mixer_rate
+//
+// - ZoH upsampling only if:
+// channel_rate < zoh_target_freq AND zoh_target_rate == mixer_rate
+//
+// - Speex resampling only if:
+// channel_rate >= zoh_target_freq AND channel_rate != mixer_rate
+//
+// - both ZoH upsampling and Speex resampling if:
+// channel_rate < zoh_target_rate AND zoh_target_rate != mixer_rate
+//
+// Resample
+// --------
+// - Speex resampling only if channel_rate != mixer_rate
+//
void MixerChannel::ConfigureResampler()
{
const auto channel_rate = sample_rate;
@@ -650,7 +675,7 @@ void MixerChannel::ConfigureResampler()
break;
case ResampleMethod::ZeroOrderHoldAndResample:
- do_zoh_upsample = (channel_rate != zoh_upsampler.target_freq);
+ do_zoh_upsample = (channel_rate < zoh_upsampler.target_freq);
if (do_zoh_upsample) {
InitZohUpsamplerState();
// DEBUG_LOG_MSG("%s: Zero-order-hold upsampler is on, target rate: %d Hz ",