How to read an EXTMEM array within an audio object

Status
Not open for further replies.

alex1982

Member
Hello
How would you go about sharing EXTMEM data between main sketch and audio objects?

say if I create a large EXTMEM word audioData[] array in my main sketch, fill it with random data in setup().

How can I access it within the update(void) of a custom audio object?
Sorry if I'm missing something obvious - can't get my head around it
Thanks in advance!
 
I'm replying here because the stuff I've found on using EXTMEM seems over my head. I ran the memory test and apparently have 16MB of ram on this thing that works just fine, but I can't access it like PROGMEM just assigning a table to be EXTMEM. As such, I have two tiny wasted chips on this thing.
 
Hmmm.

I modified the idea in this thread to use EXTMEM ( scroll down in the thread for audio object files and example code that the snippet below is excerpted and modified from )

https://forum.pjrc.com/threads/62739-Audio-Effect-Delay-Pops-amp-Clicks-when-changing-tap-times

I increased the size of the array to an extreme value, saw no change in the processor ram usage reported during compile, and the effect works.

There may be some clue in the audio object files that explains why this works, found in how it uses a regular array in lieu of audio blocks. All I did was drop EXTMEM in front of the array this code uses for the delay line.

Code:
#define DELAY_MAX_LEN 882000 // buffer for samples @44100 samples per second
EXTMEM int16_t sample_delay_line[DELAY_MAX_LEN] = {};

void setup(void) {
  Serial.begin(9600);
  AudioMemory(150 * (128 / AUDIO_BLOCK_SAMPLES));
  codec.enable();
  codec.volume(0.5);

  mixer1.gain(0, 0.7);
  mixer1.gain(1, 0.7);
  mixer1.gain(2, 0.5);
  mixer1.gain(3, 0.0);

  // initialise the delayline
  delay1.begin(sample_delay_line, DELAY_MAX_LEN);

  delay1.delayfade(2, 10000, 3.0);

}
 
Status
Not open for further replies.
Back
Top