SoundStats (v1.1.1)
by Alexander Thomas (aka Dr. Lex)
What is it?
This program analyses sound files and outputs the following information:
- the length of the file(s),
- the minimum (most negative) and maximum (most positive) sample value,
- the maximum number of consecutive samples that clip,
- the total percentage of samples that clip in the file,
- the effective number of bits required to represent the files when quantised to 16-bit integers,
- the most occurring sample value,
- the average power assuming that the sound is played through a purely resistive loudspeaker of 1 Ω with the minimum and maximum 16-bit sample values corresponding to respectively -1 and 1 Volts,
- the ReplayGain adjustment,
- a histogram of how often a stretch of continuous samples clips,
- a histogram of how often each sample value occurs.
The histograms, either stereo or mono, can be printed as ASCII art on the console, or saved to tab-delimited text files for further processing.
Why this program?
SoundStats can be useful for various applications in sound and music, but the main reason why I wrote it is to see how badly some recent music albums are mastered thanks to the infamous Loudness Wars. The most important statistics that this program outputs in that respect are the clipping statistics, the sample value histogram, and the ReplayGain value. If you're going to analyse a typical original CD from the eighties, you will see that it:
- almost never has clipping samples and uses an effective number of bits somewhere in between 15 and 16,
- has a logarithmic sample value histogram that is mostly pyramid-shaped (or diamond-shaped in SoundStats' stereo display),
- has a ReplayGain value mostly between -6dB and 0dB.
SoundStats prints a logarithmic histogram, which implies that if is diamond-shaped (i.e. it falls off linearly) the distribution of amplitudes itself is exponential. This is not a coincidence because that is also the distribution of many naturally occurring sounds. If one would make a raw recording of a live band or orchestra, chances are that it will have a similar distribution. Therefore, by reproducing the audio such that it maintains the same distribution it will still sound ‘live’ in all meanings of the word.
However, when analyzing many recent albums you will see something more like in the screenshot above, or worse: one big lump that comes closer and closer to a uniform distribution with more recent releases. Clipping also becomes considerable. The ReplayGain value will often go below -10dB. The reason why this is the case and why this is generally bad is explained in my article on the Loudness Wars and in the ReadMe file included with SoundStats.
Compiling and using
SoundStats is a basic console command written in C++ and uses only standard libraries, plus optionally supports OGG Vorbis and MP3 through libMAD. Support for WAV and AIFF is built-in. I do not provide precompiled binaries because I really don't have the time to provide support for a gazillion different architectures, therefore you need to compile it yourself. The easiest way to compile is to use CMake with the included CMakeLists.txt file. Or, you can manually tweak the included Makefile. Read the included INSTALL file for more details.
Built-in help can be invoked with the ‘-h’ switch.
If anyone feels like wrapping this into a neat Linux/OS X/Windows package with GUI, feel free. As you can see below, this program is released under the New BSD License.
Download
Download the source code (bzipped TAR archive, 36.9 kB)
Read the included README.txt for more details.
Disclaimer
SoundStats is released under the New BSD License. This software is provided “as is”, without any implied warranty or claim of fitness for a particular purpose. Use of this software is completely at your own risk.