Plate reverb - better null block handling

main
pio 1 week ago
parent c4689b5338
commit 58bb5d5d12
  1. 60
      src/effect_platereverb_F32.cpp
  2. 9
      src/effect_platereverb_F32.h

@ -41,9 +41,6 @@
#define RV_MASTER_LOWPASS_F (0.6f) // master lowpass scaled frequency coeff.
AudioEffectPlateReverb_F32::AudioEffectPlateReverb_F32() : AudioStream_F32(2, inputQueueArray_f32) { begin();}
bool AudioEffectPlateReverb_F32::begin()
{
inputGainSet = 0.5f;
@ -124,7 +121,7 @@ void AudioEffectPlateReverb_F32::update()
{
#if defined(__IMXRT1062__)
if (!initialised) return;
audio_block_f32_t *blockL, *blockR;
audio_block_f32_t *blockL, *blockR, *blockSilent;
int16_t i;
float acc;
float rv_time;
@ -159,11 +156,38 @@ void AudioEffectPlateReverb_F32::update()
blockL = AudioStream_F32::receiveReadOnly_f32(0);
blockR = AudioStream_F32::receiveReadOnly_f32(1);
if (!blockL || !blockR)
{
// preapare silent block
blockSilent = AudioStream_F32::allocate_f32();
if (!blockSilent) // no memory,
{
if (blockL) AudioStream_F32::release(blockL);
if (blockR) AudioStream_F32::release(blockR);
return;
}
memset(&blockSilent->data[0], 0, blockSilent->length*sizeof(float32_t));
if (blockL)
{
AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::release(blockL);
}
else
{
AudioStream_F32::transmit(blockSilent, 0);
}
if (blockR)
{
AudioStream_F32::transmit(blockR, 1);
AudioStream_F32::release(blockR);
}
else
{
AudioStream_F32::transmit(blockSilent, 1);
}
AudioStream_F32::release(blockSilent);
return;
}
AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockR, 1);
AudioStream_F32::release(blockL);
@ -171,12 +195,12 @@ void AudioEffectPlateReverb_F32::update()
return;
break;
case BYPASS_MODE_OFF:
blockL = AudioStream_F32::allocate_f32();
if (!blockL) return;
memset(&blockL->data[0], 0, blockL->length*sizeof(float32_t));
AudioStream_F32::transmit(blockL, 0);
AudioStream_F32::transmit(blockL, 1);
AudioStream_F32::release(blockL);
blockSilent = AudioStream_F32::allocate_f32();
if (!blockSilent) return;
memset(&blockSilent->data[0], 0, blockSilent->length*sizeof(float32_t));
AudioStream_F32::transmit(blockSilent, 0);
AudioStream_F32::transmit(blockSilent, 1);
AudioStream_F32::release(blockSilent);
return;
break;
case BYPASS_MODE_TRAILS:
@ -188,11 +212,27 @@ void AudioEffectPlateReverb_F32::update()
blockR = AudioStream_F32::receiveWritable_f32(1);
if (!blockL || !blockR)
{
// preapare silent block
blockSilent = AudioStream_F32::allocate_f32();
if (!blockSilent) // no memory,
{
if (blockL) AudioStream_F32::release(blockL);
if (blockR) AudioStream_F32::release(blockR);
return;
}
memset(&blockSilent->data[0], 0, blockSilent->length*sizeof(float32_t));
if (!blockL)
{
blockL = blockSilent;
}
if (!blockR)
{
blockR = blockSilent;
}
}
flags.cleanup_done = 0;
rv_time = rv_time_k;

@ -44,7 +44,12 @@
class AudioEffectPlateReverb_F32 : public AudioStream_F32
{
public:
AudioEffectPlateReverb_F32();
AudioEffectPlateReverb_F32() : AudioStream_F32(2, inputQueueArray_f32) { begin();}
AudioEffectPlateReverb_F32(const AudioSettings_F32 &settings) : AudioStream_F32(2, inputQueueArray_f32)
{
block_size = settings.audio_block_samples;
begin();
}
~AudioEffectPlateReverb_F32(){};
virtual void update();
@ -510,6 +515,8 @@ private:
const float freeze_hidamp_k = 1.0f;
bool initialised = false;
uint16_t block_size = AUDIO_BLOCK_SAMPLES;
};
#endif // _EFFECT_PLATERVBSTEREO_20COPY_H_

Loading…
Cancel
Save