Hello. I've been working on a digital sampler using the Arduino DUE. The idea is to use an array of 10000 samples which is populated from an SD card. The file on the SD card is built up from a sample from the ADC approx. every 33uS. I need the sampler to be able to switch between several states: forward playback, reverse playback and an adjustable slow playback.
My idea was to make a sort of granular sampler which will load the 10000 samples and then you can either play through at normal speed or just loop it until you want to load the next 10000, etc.
I am seeing a strange problem, however. When feeding it a 1kHz ramp wave, (I have the sampler starting up in normal forward playback,) I should get the 1KHz wave back on the DAC but instead it plays back at the correct speed for a brief second and then it plays back the wave but at about 17 Hz. This is way slower than it should be. Then it plays at 1kHz for a few seconds every 16 seconds. It toggles between the 2 frequencies like this forever.
Here is the code. (Had to do an attachment because it's too long)
Sorry it's a bit messy but I've been trying a lot of different stuff and haven't gotten around to cleaning it up yet. (not all the variables in the beginning are used, etc...) Been banging my head against a brick wall here trying to troubleshoot this thing for a about a week now. Hopefully someone can give me some insight as to what I'm doing wrong.
Thanks.
Digital_Sampler_2-1-15_RevM.ino (17.2 KB)