Question can you not simply have the samples stay in flash memory?
If I look at the example sketch SamplePlayer, I see that it's samples are stored in flash memory...
That is if I look at the cpp files. I see stuff like:
Code:
#include "AudioSampleKick.h"
#include <Arduino.h>
// Converted from kick.wav, using 22050 Hz, 16 bit PCM encoding
PROGMEM
const unsigned int AudioSampleKick[2561] = {
0x820013EC,0xFFDC0027,0xFF710095,0x038DFF4C,0xFBA10105,0x0037FB6E,0x09D2011A,0x007504CA,
0x024BF6BF,0xF77B0AFF,0xFB72F723,0xEF3DEBAD,0x0F7009D6,0x09DD1736,0xF26EFA3E,0x0D7002FB,
0xFF4401F1,0x06B20406,0xF83306AF,0xFC9DF1A9,0xFCC601C7,0x0423F387,0x11F011ED,0xF727066F,
...
So the main data should be left in the FLASH and not take up your main memory...
You might take a look at your files and see if they are marked as PROGMEM ?
As I looked at some other examples like the ADAT_DrumSamplePlayer sketch and See for example:
It's gong file starts off like:
Code:
#include "AudioSampleGong.h"
// Converted from gong.wav, using 11025 Hz, u-law encoding
const unsigned int AudioSampleGong[27633] = {
0x0301AFA4,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00008000,0x00000000,0x00000000,0x80800000,
0x00000000,0x00000000,0x00000080,0x00000000,0x00000000,0x00000000,0x00000080,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
So in this case it will eat real memory. I was going to show the differences in size, but appears like this example currently does not build.
Code:
Linking everything together
...
C:\Users\kurte\AppData\Local\Temp\arduino_build_320855\sketch\ADAT_DrumSamplePlayer.ino.cpp.o: In function `AudioOutputADAT::AudioOutputADAT()':
C:\arduino-1.8.13\hardware\teensy\avr\libraries\Audio/output_adat.h:34: undefined reference to `AudioOutputADAT::begin()'
C:\Users\kurte\AppData\Local\Temp\arduino_build_320855\sketch\ADAT_DrumSamplePlayer.ino.cpp.o: In function `AudioStream::AudioStream(unsigned char, audio_block_struct**)':
C:\arduino-1.8.13\hardware\teensy\avr\cores\teensy4/AudioStream.h:133: undefined reference to `vtable for AudioOutputADAT'
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "SPI.h"
Used: C:\Users\kurte\Documents\Arduino\libraries\SPI
Not used: C:\arduino-1.8.13\hardware\teensy\avr\libraries\SPI
Multiple libraries were found for "SD.h"
Used: C:\arduino-1.8.13\hardware\teensy\avr\libraries\SD
Not used: C:\arduino-1.8.13\libraries\SD
Multiple libraries were found for "Wire.h"
Used: C:\Users\kurte\Documents\Arduino\libraries\Wire
Not used: C:\arduino-1.8.13\hardware\teensy\avr\libraries\Wire
Using library Audio at version 1.3 in folder: C:\arduino-1.8.13\hardware\teensy\avr\libraries\Audio
Using library SPI at version 1.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\SPI
Using library SD at version 1.2.2 in folder: C:\arduino-1.8.13\hardware\teensy\avr\libraries\SD
Using library SerialFlash at version 0.5 in folder: C:\arduino-1.8.13\hardware\teensy\avr\libraries\SerialFlash
Using library Wire at version 1.0 in folder: C:\Users\kurte\Documents\Arduino\libraries\Wire
Error compiling for board Teensy 4.1.
Maybe some one who uses this should take a look.