Fixing AudioEffectStereoMono.

pull/3/head
Holger Wirtz 5 years ago
parent d3bf9fb422
commit a69da0b47e
  1. 16
      effect_stereo_mono.cpp
  2. 9
      effect_stereo_mono.h

@ -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]);
}
}

@ -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;

Loading…
Cancel
Save