News:

Let's find out together what makes a PIC Tick!

Main Menu

Is it possible, audio file play from flash

Started by Fanie, Jun 17, 2025, 11:34 AM

Previous topic - Next topic

Fanie

Is it possible to make an audio file "part of the program" which will play from flash ?
The same audio loop over and over.

top204

#1
Playing audio from a flash memory source is quite straightforward, by using a PWM channel as an 8-bit DAC, or combining two of them to make a 16-bit DAC. However, the 8-bit devices do not have enough flash memory for a lot of audio, even 8-bit audio. Some of the 16-bit devices have quite a bit of flash, but, again, not enough for a lot of audio signal. There are several methods of simple audio compression, but they are mainly for voice data, with a very low bandwidth, and they sound dreadful.

Placing the audio data into flash, is, again, quite straightforward, by writing a simple PC program that removes a '.WAV' file's header, and converts the binary data into hex data, so it can sit in a Dim As Flashx table. Then just read the data, and what is read is transferred directly to the PWM as the DAC.

If more eleborate audio is required, it will need an interrupt and a form of double buffering, so no glitches are heard if it is having to read from an external flash memory source. But, again, it is very straightforward to do with the compiler.

Fanie