I am using oboe lib for sound playback
https://github.com/google/oboe/blob/master/docs/FullGuide.md
as a sound file I am using .wav
file. As far as I know there is a way to get from .wav
file header - sample rate.
So, question is - how to pro grammatically in C++ read the sample rate from an arbitrary .wav
file?
There is no standard functionality in C++ for parsing wav files.
The bytes at indices 24-27 of the header represent a 32 bit integer that is the sample rate in Hz.
If you want to write your own WAV parser, perhaps look at this question (note one error in the code which is corrected in my answer): printing of a wav header in c
But probably it is more convenient to use a library. For instance, libsndfile has an API sf_open
that returns an SF_INFO struct, that includes the sample rate.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.