From 4632800a95e8eccd6be1510e3a50fec4c080eaae Mon Sep 17 00:00:00 2001 From: Javier Nonis Date: Sat, 11 Jan 2025 19:13:53 -0300 Subject: [PATCH] Avoid glitches and noise when distortion fx are loaded --- src/effect_audio/effect_bigmuff.cpp | 14 +++++++++++++- src/effect_audio/effect_bigmuff.h | 4 ++++ src/effect_audio/effect_ds1.cpp | 10 +++++++++- src/effect_audio/effect_ds1.h | 4 ++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/effect_audio/effect_bigmuff.cpp b/src/effect_audio/effect_bigmuff.cpp index 199e5d8..337c111 100644 --- a/src/effect_audio/effect_bigmuff.cpp +++ b/src/effect_audio/effect_bigmuff.cpp @@ -133,6 +133,18 @@ void AudioEffectBigMuff::doProcess(const float32_t* inblockL, const float32_t* i cont = 1; + if (inblockL != outblockL) + { + memcpy(outblockL, inblockL, len * sizeof(float32_t)); + } + if (inblockR != outblockR) + { + memcpy(outblockR, inblockR, len * sizeof(float32_t)); + } + + printf("Realloc Big Muff END\n"); + fflush(NULL); + return; } @@ -231,7 +243,7 @@ void AudioEffectBigMuff::doProcess(const float32_t* inblockL, const float32_t* i /*****************************************************************/ - for (uint32_t i=1; i<=len; i++) + for (uint32_t i=1; i<=len; i++) { outblockL[i-1] = y3[i-1]*OUTPUT_GAIN; //-26dB outblockR[i-1] = outblockL[i-1]; diff --git a/src/effect_audio/effect_bigmuff.h b/src/effect_audio/effect_bigmuff.h index 2f6507b..a20d166 100644 --- a/src/effect_audio/effect_bigmuff.h +++ b/src/effect_audio/effect_bigmuff.h @@ -17,7 +17,11 @@ public: static const unsigned ID = 5; static constexpr const char* NAME = "Big Muff"; +#ifdef ARM_ALLOW_MULTI_CORE static const unsigned TAMANHO_DO_BUFFER = 256; +#else + static const unsigned TAMANHO_DO_BUFFER = 1024; +#endif static constexpr float32_t INPUT_GAIN = 1; static constexpr float32_t OUTPUT_GAIN = 1; diff --git a/src/effect_audio/effect_ds1.cpp b/src/effect_audio/effect_ds1.cpp index f17b5e1..d1676a2 100644 --- a/src/effect_audio/effect_ds1.cpp +++ b/src/effect_audio/effect_ds1.cpp @@ -131,6 +131,14 @@ void AudioEffectDS1::doProcess(const float32_t* inblockL, const float32_t* inblo cont = 1; + if (inblockL != outblockL) + { + memcpy(outblockL, inblockL, len * sizeof(float32_t)); + } + if (inblockR != outblockR) { + memcpy(outblockR, inblockR, len * sizeof(float32_t)); + } + return; } @@ -229,7 +237,7 @@ void AudioEffectDS1::doProcess(const float32_t* inblockL, const float32_t* inblo Down8_Float(outblockL, y2, len); - for (uint32_t i=1; i<=len; i++) + for (uint32_t i=1; i<=len; i++) { outblockL[i-1] = outblockL[i-1]*OUTPUT_GAIN; //-15dB outblockR[i-1] = outblockL[i-1]; diff --git a/src/effect_audio/effect_ds1.h b/src/effect_audio/effect_ds1.h index 501ebad..1379eaf 100644 --- a/src/effect_audio/effect_ds1.h +++ b/src/effect_audio/effect_ds1.h @@ -16,7 +16,11 @@ public: // ID must be unique for each AudioEffect static const unsigned ID = 4; static constexpr const char* NAME = "DS1"; +#ifdef ARM_ALLOW_MULTI_CORE static const unsigned TAMANHO_DO_BUFFER = 256; +#else + static const unsigned TAMANHO_DO_BUFFER = 1024; +#endif static constexpr float32_t INPUT_GAIN = 1; static constexpr float32_t OUTPUT_GAIN = 1;