Closed anthofoxo closed 2 years ago
I was hesitant at first to add this because it's easy enough to just do this yourself in terms of *_in_pcm_frames()
and the sample rate. However, considering I've had other people ask this question outside of your request I think it could be useful so I've added support for this. It's in the dev branch.
In case you were curious, your proposed implementation is slightly off. You wouldn't add a dependency to ma_engine
to ma_data_source_get_length_in_seconds()
and instead you'd grab the sample rate with ma_data_source_get_data_format()
. I've also not added your ma_convert_pcm_to_seconds()
proposal as that's just basic multiplication and division and as such is just an unnecessary maintenance cost.
Commit: https://github.com/mackron/miniaudio/commit/252de0f0ad96069dcb8f1c95e10737477a5b0f29
alright awesome, I'll check that out, thanks!
This has been released.
Having an easy way to get the length of a data source in seconds could be helpful in a few cases. Similar to getting the length in pcm frames. A possible implementation could be as follows. However I'm unsure if this will fail on any certain edge cases.
A way to fairly easily convert between the two could be helpful may be a better choice to have as it could freely convert between the two.