AudioTransportSource and sample rates



In looking over the documentation and skimming the source code of the AudioTransportSource class, I see that in the constructor its samplerate member variable is initialized to 44100. When you call setSource( ) you can specify a different sample rate for your audio source and this will be compensated for on playback. What I found was when I call getCurrentPosition( ) or getTotalLength( ) the AudioTransportSource is returning values based on its internal 44100 sample rate, and not the sample rate of the actual audio source. My question is can you get the transport source to report back time values based on the source sample rate, and if not, what is the best way to do that?



I’m posting my solution in case anyone stumbles across this. In our case the AudioTransportSource is using an AudioFormatReaderSource, which takes an AudioFormatReader. I can use the AudioFormatReader to get the total file length in samples, and the actual sample rate of the file.