How to get a WAV file duration in C?

848 Views Asked by At

I'm writing a WAV Player in C with SIGIL API and windows.h library, I'm using GetOpenFileName from the windows.h library to open the file, and I need a way to the program "read" the duration of the WAV file, there is some function to do so?

1

There are 1 best solutions below

1
On BEST ANSWER

As far as I know:

Time = [Size of file]/[Byte rate]

You may also have some more factors:

  • Frequency in cycles per second;

  • Number of channels (1, 2, 4, 8...);

  • A bit value (8, 16, etc.) determining the resolution per cycle;

This information should be in the header.