Skip to content

MemoryStream: Converting a File to Flash Memory

Phil Schatzmann edited this page Apr 20, 2022 · 14 revisions

An audio file (raw audio, wav, mp3, etc) can be stored as array in flash memory. We can then use the MemoryStream class as a source to read the data.

You can convert the original file to a c file with the xxd tool.

e.g. with "xxd -i file_example_WAV_1MG.raw file_example_WAV_1MG.c"

After you generated the file you need to add the const qualifier to the generated array definition. E.g

const unsigned char file_example_WAV_1MG_raw[] = {

to make sure that the data is ending up in PROGMEM.

You also might want to compile with the Partition Scheme: Huge App!

Here are some examples: