Alright. Is there a way to jump to specific sectors of a file other than looping the Move_To_Next_File_Sector macro?
It might be possible for me to make a skip to function that allows you to skip directly to an offset sector in the file and maybe also directly to the end of the file if appending data using the high speed technique rather then the append string function. I will have a play around in the next few days and see how easy it is.
Can you explain any further on what you are doing and what you need the system to be able to do. eg. how you intend to sync the playback up on the chip, do all the data formats have to match etc. This may help me to give you a better solution.
So basically what I am doing is creating a piece for an interactive museum for children. I have attached a layout of how it is going to work. Basically there is a carpeted floor that has 12 on/off triggers in a 3x4 grid under it that are about 1x1 feet in size. On top of the carpet is a 1x1 colored tile, indicating that something will happen when you step on that particular spot. When you step on each trigger, it is supposed to play a sound. A few of the sounds are a xylophone, pot clang, and a drum hit. The point is to get kids to come up with some way of creating a musical orchestra by having their buddies step on certain tiles at certain times. I have been trying to create basically a sampler that plays these samples when kids depress the triggers. I need to create the sampler myself because the budget is very tight, and I like the challenge of making my own.
Each sample is a .WAV in a PCM format, 8bits at 44.1khz. As you know, the microcontroller I am using will be an AVR. The audio will be ouputted by a 12bit serial DAC. The particular one I had in mind is the DAC7611. http://www.ti.com/lit/ds/symlink/dac7611.pdf
Here is where the trouble starts, each sample needs to be capable of playing polyphonically. The reason it needs to be capable of polyphony is because if one kid may step on one trigger, then another kid might step on another trigger at the same time.
Here is my code structure that I have been trying: Read triggers (finds that trigger 1,2, and 5 are pressed) => Get first audio byte of sample1, add to 16bit sum variable => Get first audio byte of sample2, add to 16bit sum variable => Get first audio byte of sample5, add to 16bit sum variable => Divide 16bit sum variable by 3 (3 samples being played) => Convert 16bit sum variable to 8bit variable => Fill up 112 byte buffer by looping back to start => When buffer is full, send buffer to buffer chip (another, smaller AVR) => Loop back to start => END
The second buffer AVR receives the buffer and sends it out to the DAC at a sample rate of 44.1khz. On the AVR, there is a interrupt that triggers on a Port change. Inside this interrupt it sends the audio bytes to the DAC. The interrupt port is triggered by the PWM generator connected to the change Port which has a period frequency of 44.1khz. This allows precise timing of the output to the DAC.
By having another AVR receive the buffer and output the buffer, the first AVR is given a little time to do its processes. This will prevent any glitches in the audio.
Hopefully that made a little sense. Thank you so, so much for helping me!