1

I am using the SuperpoweredAdvancedAudioPlayer class to play a potentially very large audio file whose encoding varies (different bitrates, samplerates, even codecs). I need to be able to sync playback of this file with another file at the sample level.

I would like to know how many samples have been copied to the audio buffer for each SuperpoweredAdvancedAudioPlayer::Process call but so far can only find an approximation by calling SuperpoweredAdvancedAudioPlayer::lastProcessMs() * SuperpoweredAdvancedAudioPlayer::sampleRate.

I assume the approximation would be good-enough, but the inability to access sample-level timing is frustrating as it can lead to some phase glitching when I synchronize two streams.

NSMustache
  • 55
  • 5

1 Answers1

1

The process() method of SuperpoweredAdvancedAudioPlayer takes a numberOfSamples parameter. If the process() method returns true, it puts numberOfSamples samples into the buffer. So just cumulate numberOfSamples.

Gabor Szanto
  • 1,329
  • 8
  • 12
  • 1
    Thanks, but if SuperPoweredAudioPlayer.looping=false, the process method will pad with silencewhen numberOfSamples > remaining_before_EOF. In that case numberOfSamples does not reflect the number of actual frames played. – NSMustache Oct 28 '16 at 18:44
  • 1
    Use longer files in this case with some silence (0.1 seconds) at the end. Please also note that most compressed audio formats (such as mp3 or aac) will also "pad" with silence, as the size of one frame is fixed. – Gabor Szanto Dec 02 '16 at 17:25