DAISY DELAY + REVERB in ARDUINO

Hi All, TOTAL NOOB in Daisy programming. I know that Delay and Reverb can be combined in one program but I am not fortunate to do it. Can someone guide me or give simple examples? Thank you in advance folks.

Have you taken a look at the Reverb and Delay examples in Examples->Seed.

You may surprise yourself with being able to combine them just by looking over those (relatively short) examples.

You’ll notice the ReverbSc object is stereo, and the DelayLine is a single channel.

Most of the Delay example is commented to explain what the various interactions are doing, and most of the code in that example is actually for generating a sound source.

Hope that gives you some direction. Feel free to ask any specific questions as well :slight_smile:

1 Like

Thanks @shensley.

Here’s what I came up from the examples. But I am getting errors when compiling (I think RAM is not sufficient, bad coding). Sorry but I am lost on this one. Appreciate if you could enlighten me. Thank you

#include “DaisyDuino.h”

DaisyHardware hw;

size_t num_channels;

ReverbSc verb;

// two DelayLine of 24000 floats.
DelayLine<float, 24000> del_left, del_right;

void MyCallback(float **in, float **out, size_t size) {
for (size_t i = 0; i < size; i++) {
float dry_left, dry_right, wet_left, wet_right;
float out1, out2;
// Read Dry from I/O
dry_left = in[0][i];
dry_right = in[1][i];

// Read Wet from Delay Lines
wet_left = del_left.Read();
wet_right = del_right.Read();

// Write to Delay with some feedback
del_left.Write((wet_left * 0.5) + dry_left);
del_right.Write((wet_right * 0.5) + dry_right);

// Mix Dry and Wet and send to I/O
out[0][i] = wet_left * 0.707 + dry_left * 0.707;
out[1][i] = wet_right * 0.707 + dry_right * 0.707;

verb.Process(in[0][i], in[1][i], &out1, &out2);

}
}

void setup() {
float samplerate;
// Initialize for Daisy pod at 48kHz
hw = DAISY.init(DAISY_SEED, AUDIO_SR_48K);
num_channels = hw.num_channels;
samplerate = DAISY.get_samplerate();
// Init Delay Lines
del_left.Init();
del_right.Init();

// Set Delay Times in Samples
del_left.SetDelay(12000.0f);
del_right.SetDelay(8000.0f);

//Reverb
verb.Init(samplerate);
verb.SetFeedback(0.85f);
verb.SetLpFreq(18000.0f);

// Start Audio
DAISY.begin(MyCallback);
}

void loop() {}

Error: c:/users/repc/appdata/local/arduino15/packages/stm32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: C:\temp\arduino_build_19138/StereoDelay.ino.elf section .bss' will not fit in region RAM_D1’

c:/users/repc/appdata/local/arduino15/packages/stm32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: region `RAM_D1’ overflowed by 89848 bytes

Oh, after suggesting that, I just have noted that the memory for those objects would exceed the internal SRAM available. You can relocate the delay lines to the external SDRAM, and it should compile

This is easy enough to resolve.

To have an object located in the external SDRAM it needs to be a global object and it needs to have the DSY_SDRAM_BSS attribute added to object, like so:

DelayLine<float, 24000> DSY_SDRAM_BSS del_left;
DelayLine<float, 24000> DSY_SDRAM_BSS del_right;

In addition, since you shared the code I’d point out one thing about your audio loop: You set the outputs to your mixed delay signal, and then you process the dry signal through the reverb. The result is going to be that the actual outputs will be only the delayed signal with no reverb.

To fix that you can either add, or mix the out1 and out2 variables into the out[x][y] buffer. so that the reverb is mixed in with your dry and delayed signals.

Hope that helps!

2 Likes

Got it working! Thank you so much!

3 Likes