4

I created an application using libsndfile and wasapi, it allows playing an audio file slowly and manually with the cursor using QSlider.

I see that libsndfile uses frames, I want to know how to get the duration of this audio file but I can not find it in the documentation of libsndfile and play parts of the audio file using ms.

I managed to make it work with the frames but I want to understand how to do it with the milliseconds.

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
IT World
  • 165
  • 1
  • 10

1 Answers1

5

The objects libsndfile creates have a frames() method that gives you this information. samplerate() gives you the sampling rate, so then the duration is:

static_cast<double>(frames())/samplerate()
Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62