Sandro
Well-known member
Hi all, I'm trying to read in "reverse" direction an audio .RAW file from flash memory chip; I quote olly the relevant part of my code.
First, inside play(filename) function I set rawfile.seek to the last byte of the .RAW file:
Than, each time update() is called, I read a bunch of 128 samples (beginning from the end), reverse them (last sample in --> first sample out), and send to the next stage:
Anyone can please help me to find what's wrong with this code? I apologize becasue I didn't include a check for the end of .RAW file, but problems comes soon at the beginnig of reading 8far from the end of file)
Thank you!
First, inside play(filename) function I set rawfile.seek to the last byte of the .RAW file:
Code:
bool Audio_expander_serialflash_raw::play(const char *filename)
{
....
rawfile = SerialFlash.open(filename);
file_size = rawfile.size();
file_offset = file_size-1;
rawfile.seek(file_offset);
....
}
Than, each time update() is called, I read a bunch of 128 samples (beginning from the end), reverse them (last sample in --> first sample out), and send to the next stage:
Code:
void Audio_expander_serialflash_raw::update(void)
{
unsigned int i;
audio_block_t *block;
int16_t r_samples_vector[128];
rawfile.read(r_samples_vector, 128<<1);
for (i=0; i<128; i++)
{
block->data[i]=r_samples_vector[127-i];
}
transmit(block);
file_offset -= (128<<1);
rawfile.seek(file_offset);
}
Anyone can please help me to find what's wrong with this code? I apologize becasue I didn't include a check for the end of .RAW file, but problems comes soon at the beginnig of reading 8far from the end of file)
Thank you!