Reverb + PitchShifter exceeding RAM

Hi Guy, I’m Italo. I’m just starting to learn about the Daisy Seed platform, I’m really excited to use Daisy Seed, but I still don’t really understand how to make things work. I have a development experience with the FV-1 and Arduino, but I’m still lost in trying to implement some functions in my code, because I’m trying to combine a reverb with a pitchshifter, but I get a RAM error.

I’ve already seen that the function to use external RAM memory is DSY_SDRAM_BSS, but I have no idea where to insert this function in the code. I already tried to insert as follows “ReverbSc DSY_SDRAM_BSS verb;” however the code generates a syntax error, I also tried “ReverbSc DSY_SDRAM_BSS, verb;” and I do not receive a syntax error, but the code does not compile, pointing to the following error:
c:/users/italo/documents/daisytoolchain-0.3.1/windows/bin/…/lib/gcc/arm-none-eabi/10.2.1/…/…/…/…/arm- none-eabi/bin/ld.exe: build/Verb.elf section .bss' will not fit in region SRAM’
c:/users/italo/documents/daisytoolchain-0.3.1/windows/bin/…/lib/gcc/arm-none-eabi/10.2.1/…/…/…/…/arm- none-eabi/bin/ld.exe: region `SRAM’ overflowed by 143524 bytes.

Below is my code:

#include “daisy_petal.h”
#include “daisysp.h”

using namespace daisy;
using namespace daisysp;

// Declare the daisy_petal location for hardware access
static DaisyPetal hw;
static PitchShifter ps;
static ReverbSc DSY_SDRAM_BSS verb;

static Parameter vtime, vfreq, vsend;
bypass bool;

// This runs at a fixed rate, to prepare audio samples
void callback(AudioHandle::InterleavingInputBuffer in,
AudioHandle::InterleavingOutputBuffer out,
size_t size)
{
float dryl, dryr, wetl, wetr, sendl, sendr;
hw.ProcessDigitalControls();
verb.SetFeedback(vtime.Process());
verb.SetLpFreq(vfreq.Process());
vsend.Process(); // Process Send to use later
//bypass = hw.switches[DaisyPetal::SW_5].Pressed();
//if(hw.switches[DaisyPetal::SW_1].RisingEdge())
//bypass = !bypass;
bypass = false;
for(size_t i = 0; i < size; i += 2)
{
dryl = in[i];
dryr = in[i + 1];
sendl = ps.Process(dryl);//dryl * vsend.Value();
sendr = ps.Process(dryr);//dryr * vsend.Value();
verb.Process(sendl, sendr, &wetl, &wetr);
if(bypass)
{
out[i] = in[i]; // left
out[i + 1] = in[i + 1]; // right
}
else
{
out[i] = wetl;
out[i + 1] = dryr + wetr;
}
}
}

int main(void)
{
float samplerate;
hw.Init();
hw.SetAudioBlockSize(4);
samplerate = hw.AudioSampleRate();

ps.Init(samplerate);
ps.SetTransposition(12.0f);

vtime.Init(hw.knob[hw.KNOB_1], 0.6f, 0.999f, Parameter::LOGARITHMIC);
vfreq.Init(hw.knob[hw.KNOB_2], 1000.0f, 20000.0f, Parameter::LOGARITHMIC);
vsend.Init(hw.knob[hw.KNOB_3], 0.0f, 1.0f, Parameter::LINEAR);
verb.Init(samplerate);

hw.StartAdc();
hw.StartAudio(callback);
while(1)
{
    // Do Stuff Infinitely Here
    System::Delay(10);
    hw.ClearLeds();
    hw.SetFootswitchLed(hw.FOOTSWITCH_LED_1, bypass ? 0.0f : 1.0f);
    hw.UpdateLeds();
}

}

I’ll not be able to test to compile your code until tomorrow, but did you try to put also the PitchShifter on DSY_SDRAM_BS (both the verb and ps variables)?

Hi Guy!

I don’t know how to explain the reason very well, but I closed my VS and when I opened it again the syntax “static ReverbSc DSY_SDRAM_BSS verb;” started to be accepted. I managed to compile the code and get the expected result, now I need to be able to create a loop for the pitchshifter signal to feed back, thus creating a shimmer effect.

@frotaitalos

Your use of the SDRAM for ReverbSC looks okay to me.

I have seen the formatter occasionally get upset with a few things (and falsely claim there are undefined macros, etc.), but usually this gets resolved by building the code/resaving the file.

If you’re seeing syntax errors for that when compiling then those would be worth sharing here as well, but it sounds like it started to work for you.

I am having the same issue. Every time I add ReverbSc as a class member, the linker returns a SRAM overflow. Examples:

class declaration:

class Synth {
...
  daisysp::ReverbSc rev_;
};

Memory usage when linked with this declaration:

  SRAM:      859568 B       512 KB    163.95%

Memory usage when ReverbSc is declared as static outside of the class:

SRAM:      463464 B       512 KB     88.40%

I am wondering if it is safe to decrease the buffer size in reverbsc.h. Currently, it is set to

#define DSY_REVERBSC_MAX_SIZE 98936

Why do you want the reverb to be a class member?

I have all of the sound generation encapsulated in the Synth class, along with MidiEngine, another class that handles MIDI events. The Audio callback only calls synth.Process(), allowing for very clean and elegant code.