From 3361fbfb7e44ed2e1c2a89034de3b46840f2de02 Mon Sep 17 00:00:00 2001 From: Iscle Date: Tue, 16 May 2023 03:12:51 +0200 Subject: [PATCH] Disable sampling rate cap Only some of the effects rely on the sampling rate being at most 48kHz, it's better to handle this inside the effects themselves. --- src/ViperContext.cpp | 16 ++++++++-------- src/viper/utils/Crossfeed.cpp | 1 + src/viper/utils/MinPhaseIIRCoeffs.cpp | 8 +++----- src/viper/utils/MinPhaseIIRCoeffs.h | 1 - 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/ViperContext.cpp b/src/ViperContext.cpp index c8bed19..1c63bf2 100644 --- a/src/ViperContext.cpp +++ b/src/ViperContext.cpp @@ -37,27 +37,27 @@ void ViperContext::handleSetConfig(effect_config_t *newConfig) { if (newConfig->inputCfg.buffer.frameCount != newConfig->outputCfg.buffer.frameCount) { VIPER_LOGE("ViPER4Android disabled, reason [in.FC = %ld, out.FC = %ld]", newConfig->inputCfg.buffer.frameCount, newConfig->outputCfg.buffer.frameCount); - setDisableReason(DisableReason::INVALID_FRAME_COUNT); + setDisableReason(DisableReason::INVALID_FRAME_COUNT, "Input and output frame count mismatch"); return; } if (newConfig->inputCfg.samplingRate != newConfig->outputCfg.samplingRate) { VIPER_LOGE("ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]", newConfig->inputCfg.samplingRate, newConfig->outputCfg.samplingRate); - setDisableReason(DisableReason::INVALID_SAMPLING_RATE); + setDisableReason(DisableReason::INVALID_SAMPLING_RATE, "Input and output sampling rate mismatch"); return; } - if (newConfig->inputCfg.samplingRate > 48000) { - VIPER_LOGE("ViPER4Android disabled, reason [SR out of range]"); - setDisableReason(DisableReason::INVALID_SAMPLING_RATE, "Sampling rate out of range: " + std::to_string(newConfig->inputCfg.samplingRate)); - return; - } +// if (newConfig->inputCfg.samplingRate > 48000) { +// VIPER_LOGE("ViPER4Android disabled, reason [SR out of range]"); +// setDisableReason(DisableReason::INVALID_SAMPLING_RATE, "Sampling rate out of range: " + std::to_string(newConfig->inputCfg.samplingRate)); +// return; +// } if (newConfig->inputCfg.channels != newConfig->outputCfg.channels) { VIPER_LOGE("ViPER4Android disabled, reason [in.CH = %d, out.CH = %d]", newConfig->inputCfg.channels, newConfig->outputCfg.channels); - setDisableReason(DisableReason::INVALID_CHANNEL_COUNT); + setDisableReason(DisableReason::INVALID_CHANNEL_COUNT, "Input and output channel count mismatch"); return; } diff --git a/src/viper/utils/Crossfeed.cpp b/src/viper/utils/Crossfeed.cpp index 6786ea2..dbcba65 100644 --- a/src/viper/utils/Crossfeed.cpp +++ b/src/viper/utils/Crossfeed.cpp @@ -5,6 +5,7 @@ // Basically Bauer-to-Stereophonic Binaural filter // See: http://bs2b.sourceforge.net/ + Crossfeed::Crossfeed() { this->a0_lo = 0.f; this->b1_lo = 0.f; diff --git a/src/viper/utils/MinPhaseIIRCoeffs.cpp b/src/viper/utils/MinPhaseIIRCoeffs.cpp index 4f54a81..8819ce4 100644 --- a/src/viper/utils/MinPhaseIIRCoeffs.cpp +++ b/src/viper/utils/MinPhaseIIRCoeffs.cpp @@ -99,7 +99,6 @@ static const float MIN_PHASE_IIR_COEFFS_FREQ_31BANDS[] = { MinPhaseIIRCoeffs::MinPhaseIIRCoeffs() { this->coeffs = nullptr; - this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE; this->bands = 0; } @@ -153,12 +152,11 @@ int MinPhaseIIRCoeffs::SolveRoot(double param_2, double param_3, double param_4, } int MinPhaseIIRCoeffs::UpdateCoeffs(uint32_t bands, uint32_t samplingRate) { - if ((bands != 10 && bands != 15 && bands != 25 && bands != 31) || samplingRate < 44100) { + if (bands != 10 && bands != 15 && bands != 25 && bands != 31) { return 0; } this->bands = bands; - this->samplingRate = samplingRate; delete[] this->coeffs; this->coeffs = new double[bands * 4](); // TODO: Check this array size, original type: float @@ -191,8 +189,8 @@ int MinPhaseIIRCoeffs::UpdateCoeffs(uint32_t bands, uint32_t samplingRate) { Find_F1_F2(bandFreqs[i], tmp, &ret2, &ret1); - double x = (2.0 * M_PI * (double) bandFreqs[i]) / (double) this->samplingRate; - double y = (2.0 * M_PI * ret2) / (double) this->samplingRate; + double x = (2.0 * M_PI * (double) bandFreqs[i]) / (double) samplingRate; + double y = (2.0 * M_PI * ret2) / (double) samplingRate; double cosX = cos(x); double cosY = cos(y); diff --git a/src/viper/utils/MinPhaseIIRCoeffs.h b/src/viper/utils/MinPhaseIIRCoeffs.h index 0ae1aed..a7a2e2f 100644 --- a/src/viper/utils/MinPhaseIIRCoeffs.h +++ b/src/viper/utils/MinPhaseIIRCoeffs.h @@ -18,6 +18,5 @@ private: int SolveRoot(double param_2, double param_3, double param_4, double *param_5); double *coeffs; - uint32_t samplingRate; uint32_t bands; }; \ No newline at end of file