I have developed an audio system for mobile robots that allow them to vocalize recorded speech. It is a simple system that uses mp3 files on flash memory that are spit out to a VLSI VS1063 encoder/decoder IC. The control for the system is done by Mega 1284P. Note that the files are stored on the flash linearly via SPI and there is no file system (FAT32) used.
When a file is played, I detect the end of the file by keeping track of the number of bytes of data in the file and stopping the playback when I reach that number. This requires me to keep audio file length in memory, which is cumbersome.
It would be better to play the file until I reach an end of file marker and then terminate playback, but, mp3 does not have an end of file marker. It just has a series of frames. The end of the file is the end of the frames. However, the way I store them on the flash, one file follows another (with some empty bytes between), and I need a good way to tell I have reached the end of the file I am playing so I don't just run on into the next one.
I suppose I could use Chan's FATFS, but that would require a major change that I'd like to avoid. So, I am hoping for some suggestions on a better way to identify the end of a particular mp3 file. I suppose I could look for a sequence of empty bytes, but maybe there is a better way. Any thoughts on this?