Sandro
Well-known member
Hi all, I'd like to understand how does AudioPlaySdRaw works in order to make few mods. I'd be gratefull if somebody had the patience to answer to one couple of questions.
In AudioPlaySdRaw.cpp it seems to me that .update is the funcion which takes a bunch of samples (AUDIO_BLOCK_SAMPLES*2) and send them to the Connector:
I have two questions:
1) why .update function is not used in arduino sketch?
2) why samples are deleted before being sent?
Thanks a lot!
In AudioPlaySdRaw.cpp it seems to me that .update is the funcion which takes a bunch of samples (AUDIO_BLOCK_SAMPLES*2) and send them to the Connector:
Code:
void AudioPlaySdRaw::update(void)
{
unsigned int i, n;
audio_block_t *block;
// only update if we're playing
if (!playing) return;
// allocate the audio blocks to transmit
block = allocate();
if (block == NULL) return;
if (rawfile.available()) {
// we can read more data from the file...
n = rawfile.read(block->data, AUDIO_BLOCK_SAMPLES*2);
file_offset += n;
for (i=n/2; i < AUDIO_BLOCK_SAMPLES; i++) {
block->data[i] = 0;
}
transmit(block);
} else {
rawfile.close();
#if defined(HAS_KINETIS_SDHC)
if (!(SIM_SCGC3 & SIM_SCGC3_SDHC)) AudioStopUsingSPI();
#else
AudioStopUsingSPI();
#endif
playing = false;
}
release(block);
}
I have two questions:
1) why .update function is not used in arduino sketch?
2) why samples are deleted before being sent?
Code:
for (i=n/2; i < AUDIO_BLOCK_SAMPLES; i++) {
block->data[i] = 0;
}
Thanks a lot!