Search code examples
caudiowavpcmsox

Coverting PCM 16bit LE to WAV


I'm trying to write a program in C that converts a captured Raw 16kHz PCM 16-bit file to a 16-bit WAV.

I've read some posts and people recommended using libsox. Installed it and now i'm really struggling with understanding the man-page.

So far (by reading the example in the source dist) I've figured out that the structs:

  • sox_format_t
  • sox_signalinfo_t

can probably be used to describe the data I'm inputting. I also know how much info i'm processing (time) if that is somehow necessary?

Some guidance is appreciated!


Solution

  • I would recommend to write WAV header and data manually, it is really very simple for PCM : https://web.archive.org/web/20080706175634/https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

    Update: original link https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ became invalid.