AudioEffectDelay with multiple channels

I’ve noticed some strange behavior when using the AudioEffectDelay library object. I have tried to make a simple delay program modeled off the BasicGain example: AudioInputI2S → AudioEffectDelay → AudioOutputI2S.

  • If I only connect I2S input channel 0 to a single delay object, everything works fine.
  • If I connect I2S input channel 1 to anything, even if only channel 0 is connected to a delay and channel 1 is connected to something else, the system crashes and reboots repeatedly on Tympan.enable().
  • If I connect the inputs of two delay objects, even to the same source, the output is a screech. This also happens if I connect a delay and a gain to the same source.

Is there additional setup required when using AudioEffectDelay with multiple channels, or could this be a pointer bug in the library?

Can you paste the actual code? Esp where you create your audio classes and audio connections?

Chip

Here is the test program that isn’t working.

#include <Tympan_Library.h>

Tympan                    myTympan(TympanRev::E);  
AudioInputI2S_F32         i2s_in;        
AudioEffectDelay_F32      delay1;
AudioEffectDelay_F32      delay2;  
AudioOutputI2S_F32        i2s_out;      

AudioConnection_F32       patchCordI1D1(i2s_in, 0, delay1, 0);
AudioConnection_F32       patchCordD1O1(delay1, 0, i2s_out, 0);

// The program works if I comment these two lines
AudioConnection_F32       patchCordI2D2(i2s_in, 1, delay2, 0);
AudioConnection_F32       patchCordD2O2(delay2, 0, i2s_out, 1);

void setup() {
  Serial.begin(115200);  delay(500);
  Serial.println("delay_test: starting setup()...");

  AudioMemory_F32(100); 
  
  delay1.delay(0,4);
  delay2.delay(0,4);

  Serial.println("About to call Tympan.enable()"); // Reaches this line
  myTympan.enable();
  Serial.println("Done calling Tympan.enable()"); // Never reaches this line

  myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_MIC);
  myTympan.volume_dB(0);
  myTympan.setInputGain_dB(20.0f);

  Serial.println("Setup complete.");
}

void loop() {

}

That code looks pretty good to my eye…but I’ve tried it myself and confirmed that it dies. I am digging in now.

I found the bug! There was a memory leak in the delay class. Sorry!

If you update your Tympan_Library, it should work now.

Chip

Thank you for the quick fix, Chip!