-
-
Notifications
You must be signed in to change notification settings - Fork 237
MemoryStream: Converting a File to Flash Memory
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.
If you want to edit your audio file, I suggest to use a proper tool like Audacity: You can remove or add some silence at the end or you can reduce the file size by decreasing the channels from 2 to 1 and by decreasing the sample rate.
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: