Might be the wrong place to ask this but I kinda need help figuring out what the real issue is...
Basically, I'm programming a microcontroller to do USB audio recording (using USB Audio Class 2.0 / high speed USB). Seems like I'm getting pretty close to getting it" aright" but I'm getting this when I record a chirp into audacity [below is an excerpt]:
I guess what I'm asking is why am I getting these weird interruptions and jumps in my recording session? Is it because I'm not reading my codec input buffers quickly enough or perhaps the frame length isn't being set correctly?
How I'm calculating my frame length which I got from a USB Audio guide from Apple (using 44.1kHz sample rate and 16 bit rate):
#define AUDIO_POLL_INT 4
#define FRAME_BYTES (BIT_RATE_16 / 8)
#define NUM_CHANNELS STEREO
uint16_t frame_len = 44 (44.1kHz/1000 samples) * NUM_CHANNELS * FRAME_BYTES;
if (!(frame_pos % 9)) frame_len += (1 * NUM_CHANNELS * FRAME_BYTES)
frame_len = (frame_len / 8) * (2 << (AUDIO_POLL_INT-1));
// 10 ms frames
frame_pos = (((frame_pos + 1) / 8) * (2 << (AUDIO_POLL_INT-1))) % 10;
This is also the process of reading codec input:
1) Read Codec Input; Load samples into temporary buffer (transfers from codec peripheral to a memory peripheral)
2) Memory Peripheral interrupt occurs when a transfer is complete (buffer is full; frame_len capacity has been fulfilled), send buffer samples to USB. Afterwards, read codec input again
Hopefully this isn't too confusing... let me know and I can add more info/clear up things. Thanks!