In my video episode "Technology", I state that the WAV file format is "so simple that it's future-proof; writing a decoder for WAV is easy...". To justify saying this, I wrote a little utility, called Wavdump, which displays the contents of a WAV audio file. And this really was simple; so simple that I got this app working, from scratch, in an afternoon.

I spent a few hours since then tweaking it. It's still pretty basic, and doesn't cover all the possible options for a WAV file; but it at least gives you an idea of how much work is really involved in this. You can browse the code below, to see for yourself.

Browsing Wavdump

The Wavdump app consists of just 2 Java files, linked below. To view the code, just click the links below.

Please note that this code is provided as-is, and for educational purposes only. You're really not supposed to use this for anything serious; it certainly doesn't support all the features of WAV files, and certainly has bugs.

The files are:

Using Wavdump

You will need to have a Java run-time installed, and you will need a command-line window; Wavdump doesn't have any kind of graphical user interface. You'll also need to know how to build a Java app. The package name is org.hermit.wavdump, so to build the app you will need to place the files within folders accordingly.

Once you've downloaded and built it, get onto a command line, and run the command

java -ea org.hermit.wavdump.WavDump [ flags ] wav-file ...

The [ flags ] part is zero or more of the following options (leave it off to get the default behaviour):

-fullsamples
Display all audio samples: this produces a MASSIVE quantity of output!
-shortsamples
Display a summary of audio samples
-nosamples
Don't display audio samples
-fullxml
Display all of the contents of XML-formatted chunks
-shortxml
Display a summary of XML-formatted chunks
-noxml
Don't display the contents of XML-formatted chunks

Capabilities

Wavdump was written just to demonstrate the core structure of WAV files; as such, it doesn't support all of the many varied options that the WAV format supports. Then again, most of those options aren't really used much anyhow.

In particular, Wavdump doesn't support any compressed modes, though it might just tell you that the file does contain compressed audio. Even for non-compressed audio, I've really only tested it with 24-bit integer and 32-bit float; and I'm not convinced about the decoding of float data. So by all means browse the code to see how a WAV decoder could work, but if you actually use this code for anything, be it on your own head.

It does at least seem to show what chunks are in a WAV file, and display the contents of the text and XML chunks that I know of, as well as the core WAV chunks.