From a69da0b47ec082a411ac93de38ef0f16c52a08fe Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 24 Oct 2019 08:20:17 +0200 Subject: [PATCH] Fixing AudioEffectStereoMono. --- effect_stereo_mono.cpp | 16 ++++++---------- effect_stereo_mono.h | 9 +++++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/effect_stereo_mono.cpp b/effect_stereo_mono.cpp index 3d1038d..2d60188 100644 --- a/effect_stereo_mono.cpp +++ b/effect_stereo_mono.cpp @@ -38,23 +38,19 @@ void AudioEffectStereoMono::update(void) { audio_block_t *block[2]; + block[0] = receiveWritable(0); + block[1] = receiveWritable(1); + if (_enabled == true) { - block[0] = receiveWritable(0); - block[1] = receiveReadOnly(1); - if (block[0] && block[1]) { int16_t *bp[2] = { block[0]->data, block[1]->data }; for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) { - *bp[0] = (long(*bp[0]) + *bp[1]) >> 1; - *bp[1] = *bp[0]; - - // push the pointers forward - bp[0]++; // next audio data - bp[1]++; // next audio data + *bp[0]++ = *bp[0] >> 1 + *bp[1] >> 1; + *bp[1]++ = *bp[0]; } } } @@ -66,7 +62,7 @@ void AudioEffectStereoMono::update(void) } if (block[1]) { - transmit(block[1], 0); + transmit(block[1], 1); release(block[1]); } } diff --git a/effect_stereo_mono.h b/effect_stereo_mono.h index 8e225cb..0379326 100644 --- a/effect_stereo_mono.h +++ b/effect_stereo_mono.h @@ -31,17 +31,18 @@ // Written by Holger Wirtz // 20191023 - inital version -class AudioEffectStereoMono : - public AudioStream +class AudioEffectStereoMono : public AudioStream { public: AudioEffectStereoMono(void): AudioStream(2, inputQueueArray) - { _enabled=false; } + { + _enabled = false; + } virtual void update(void); virtual void stereo(bool mode); - + private: audio_block_t *inputQueueArray[2]; bool _enabled;