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-06 12:01:41 +0300
committerJohn Novak <jnovak@skedulo.com>2022-09-06 12:01:41 +0300
commit38a0ff4555078eba22549dd8b273fa1f3ea423eb (patch)
tree1f8dbe66ce65dcc3dbd74c478473fb42ad77599f
parent327ff9e10af5f4fe6cbd098b9a521018ad0722bc (diff)
Make resampling checks more robustjn/modern-sb-filter
-rw-r--r--include/mixer.h4
-rw-r--r--src/hardware/mixer.cpp8
2 files changed, 6 insertions, 6 deletions
diff --git a/include/mixer.h b/include/mixer.h
index e4f3b73a0..836d06e29 100644
--- a/include/mixer.h
+++ b/include/mixer.h
@@ -303,8 +303,8 @@ private:
bool last_samples_were_stereo = false;
bool last_samples_were_silence = true;
-
ResampleMethod resample_method = {};
+ bool do_resample = false;
struct {
float pos = 0.0f;
@@ -322,8 +322,6 @@ private:
SpeexResamplerState *state = nullptr;
} speex_resampler = {};
- bool do_resample = false;
-
struct {
struct {
std::array<Iir::Butterworth::HighPass<max_filter_order>, 2> hpf = {};
diff --git a/src/hardware/mixer.cpp b/src/hardware/mixer.cpp
index a178187f3..4ec58f97f 100644
--- a/src/hardware/mixer.cpp
+++ b/src/hardware/mixer.cpp
@@ -926,8 +926,9 @@ bool MixerChannel::TryParseAndSetCustomFilter(const std::string &filter_prefs)
return false;
}
- const auto do_zoh_upsample = (resample_method ==
- ResampleMethod::ZeroOrderHoldAndResample);
+ const auto do_zoh_upsample = do_resample &&
+ resample_method ==
+ ResampleMethod::ZeroOrderHoldAndResample;
const auto max_cutoff_freq_hz = (do_zoh_upsample ? zoh_upsampler.target_freq
: sample_rate) / 2 - 1;
@@ -1315,7 +1316,8 @@ void MixerChannel::ConvertSamples(const Type *data, const uint16_t frames,
out.emplace_back(out_frame[0]);
out.emplace_back(out_frame[1]);
- if (resample_method == ResampleMethod::ZeroOrderHoldAndResample) {
+ if (do_resample &&
+ resample_method == ResampleMethod::ZeroOrderHoldAndResample) {
zoh_upsampler.pos += zoh_upsampler.step;
if (zoh_upsampler.pos > 1.0f) {
zoh_upsampler.pos -= 1.0f;