2

I'm writing an audio library that includes reading and writing wave files and I understand the differences between the three possible wave file formats, but it's unclear when to use the extensible format when dealing with mono or stereo PCM data. I've been using this as my main reference and it clears up the obvious cases of when to use the extensible format. However, the link mentions that the extensible format should be used if PCM data greater than 16-bits, but when I try exporting 24 or 32-bit audio using Audacity they aren't using the extensible format.

I haven't found any mention in the specification that the extensible format should be favored in this case, or if all files should use the extensible format. Would a modern library even support the older formats? Should I simplify file writing to using the extensible format for all cases?

Update:

I found this resource from Microsoft about the format chunk. From what I understand, PCM data could use the extensible format or the 18 byte format, but the older 16 byte format is obsolete. Does anyone know if you can play WAVE PCM files with a 16 byte header on a Windows machine? How about 24-bit PCM with the 16 byte header? That was another edge case I found online. I don't have a Windows image, so I can't check it myself.

riban
  • 41
  • 3
  • 7

4 Answers4

1

It was on MSDN but moved or gone, now the trace remained is:

According to the MSDN docs "Any PCM format that has more than 2 channels, more than 16 bits per sample, or more than 44,100 samples per second must be described by WAVEFORMATEXTENSIBLE"

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • 1
    I'll add that the above means that if you're **generating/sourcing** audio, you _may_ have to use `WAVEFORMATEXTENSIBLE`. However, if you're **consuming** audio, it may use `WAVEFORMATEXTENSIBLE` even though it could be specified using `WAVEFORMATEX`, so you should write your code to handle both. – Scott Smith Dec 13 '20 at 20:52
1

According to http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html

 "The WAVE_FORMAT_EXTENSIBLE format should be used whenever:
    1) PCM data has more than 16 bits/sample.
    2) The number of channels is more than 2.
    3) The actual number of bits/sample is not equal to the container size.
    4) The mapping from channels to speakers needs to be specified."
Omer Cohen
  • 11
  • 2
0

You can specify 24 or 32 bits in the normal wav format - as demonstrated by Audacity. The extensible format is more for dealing with multiple (more than 2) channels. In my experience, WAV format is more broadly supported than the extensible version. Given you are dealing with mono and stereo, I would recommend you stick with WAV.

jaket
  • 9,140
  • 2
  • 25
  • 44
0

I would use 16-bit PCM and then change the sample rate to 48000 Hz, little-endian, and 2 channel stereo for the cleanest results, since most CDs are 44100 Hz, changing to 48000 Hz can be useful for a bit higher quality for purposes other than consumer quality audio (commercial audio). This would be the cleanest option.

JohnColtraneisJC
  • 198
  • 1
  • 13
  • 2
    You've misunderstood the question. He's not asking which bit depth/sample rate provides the "cleanest" means of saving audio (and in fact, upsampling can introduce unnecessary artefacts and result in no addition "cleanness"). He's basically asking when is it appropriate (or best) to use the extensible format. – Sam Oct 14 '15 at 20:50