Page 1 of 1

VSMD001 - Read an auxiliary file

Posted: Tue 2020-01-07 20:26
by vegasys
Dear staff:

I am working with the VS1000 audio module and, in addition to playing audio, I need to read a binary file synchronized with it.
The concept is, for example: while playing 001.OGG, every 10 ms reads sequentially a byte of 001.BIN and put it on GPIO0. With 002.OGG, read 002.BIN and so on.
I have made an interrupt with timer1, which is triggered every 10 ms and I set a random value in GPIO0 (just to test). I used UartLoadCheck to fix the frequency and everything works fine and stable even during playback.

Is there any way to do this? It would be great to do it without adding a microcontroller (which is my last resource). I just need to know how to read the file. The composition of the names (nnn.OGG and nnn.BIN) can be done by me. I also need to know how to "close" the file when playback ends.

Thanks for your constant support.

Re: VSMD001 - Read an auxiliary file

Posted: Wed 2020-01-08 11:17
by pasi
VS1000 can have only one file "open" at a time. The second file you would need to read outside of the filesystem routines.

If you assume non-fragmented files, you would:
1) FileOpen() the side-information file, read and save minifatFragments[0].start (and optionally size). Read a sector with ReadDiskSector.
2) Install your own idle hook handler. Open and start playing the audio file.
3) In the idle hook handler check if you need to read more data. You will probably need two sector-fulls of data stored. If you don't have space for that amount, you can use minifatBuffer[] as a temporary read buffer, as long as you set minifatInfo.currentSector = -1; afterwards.

The VLSI Audio Book example has some code that reads side information - it reads and shows menu lines during audio playback. ... tions.html