NSMustache
NSMustache

Reputation: 55

Count samples played with SuperpoweredAdvancedAudioPlayer

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.

Upvotes: 1

Views: 168

Answers (1)

Gabor Szanto
Gabor Szanto

Reputation: 1329

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.

Upvotes: 1

Related Questions