Read audio data from part of audio file


#1

I know how load an entire file into an audioBuffer. But is there a way to get say 5-10 seconds worth from a given point.

I basically have an audio playback component which works great with upto 10 mins worth but I want to be effiecient with ram for larger files.


#2

int lentoread = 44100;
int positiontostartreadingfrom = 100*44100;
reader->read(buffer, 0, lentoread, positiontostartreadingfrom , true, true);

“reader” is assumed to be an AudioFormatReader and “buffer” an AudioBuffer.


#3

Maybe BufferingAudioReader or BufferingAudioSource is what you are looking for…


#4

Yeah, if he wants to stream the audio from disk. But it wasn’t clear from the original post if he wants to do that or not.


#5

Yes, was just meant as additional option… your solution is the least invasive!


#6

Awesome. I thought there would be something like that.

Cheers for quick response.