0

While decoding file using superpowered i get samplePosition but i want current position in miliseconds / seconds. samplePosition is the current position in samples. but what i actually need is current position in milliseconds. while decoding i want to mute / unmute at certain millisecond positions in audio file.

while (true) {

    currentSamplesDecoded = decoder->samplesPerFrame;
    status = decoder->decode(intBuffer, &currentSamplesDecoded);

    baseCurrentPosition = decoder->samplePosition;

    // What i want is :- 
    // currentMiliseconds = decoder-> how to get current position in Miliseconds

}

Thanks in Advance

Kathan Shah
  • 1,655
  • 17
  • 25

1 Answers1

0

Math!, I was not sure about the terms of samplePosition and durationSamples

decoder->durationSeconds * ((double)decoder->samplePosition / (double)decoder->durationSamples)

So it seems samplePosition divide by durationSamples gives % progress

Thank You

Kathan Shah
  • 1,655
  • 17
  • 25