-1

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?

Guilherme Poleto
  • 327
  • 1
  • 2
  • 13
  • I don't know if there's a API function for that, but this might be interesting to you http://soundfile.sapp.org/doc/WaveFormat/ – Federico klez Culloca May 22 '17 at 13:41
  • [This too](https://stackoverflow.com/questions/16075233/reading-and-processing-wav-file-data-in-c-c) – Badda May 22 '17 at 13:47
  • Isn't SIGIL something for e-books? Anyway, there is no function in standard C that tells you the duration of a WAV file. *If it is possible to approximate by dividing file length by a constant you want `fseek()` and `ftell()`* – pmg May 22 '17 at 13:49
  • 1
    @pmg there's an e-book reader, yes, but, there's also a library for user input, audio, image and user interface processing in C, [here](http://www.libsigil.com) – Guilherme Poleto May 22 '17 at 13:52

1 Answers1

1

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.

Gnqz
  • 3,292
  • 3
  • 25
  • 35
  • Yes, I've tought about it before, but, I didn't had a way to read that information, but, now with the comment from Frederico, I think I can do it, thanks. – Guilherme Poleto May 22 '17 at 13:55