I’m reading a Wave file using the following steps:
Creating a File object.
Creating a FileInputStream.
Creating a WavAudioFormat reader for the file stream
Creating an AudioFormatReaderSource for the reader.
Then I call prepareToPlay on the AudioFormatReaderSource and I read blocks from it. This works great! However, I want to handle situations where the output sample rate is different than the Wave file’s sample rate. I thought that AudioFormatReaderSource would handle this, because prepareToPlay takes the output sample rate as a parameter, but that’s not the case. So, I’m pretty sure I need to use a ResamplingAudioSource in the chain… somewhere. Unfortunately, I’m really uncertain what to wrap in the ResamplingAudioSource. The only AudioSource that I have is the AudioFormatReaderSource, but if I create a ResamplingAudioSource out of it, I’ll lose functions like setLooping() and getTotalLength() and setNextReadPosition() that I need access to, but which are part of the AudioFormatReaderSource, and aren’t part of ResamplingAudioSource.
What’s the best method for doing this kind of resampling when reading a file?