Getting Stats on a Sound File

with No Comments

Here are a few ways to obtain stats and other useful info about a sound file using a Mac.

Use libsndfile

How to install libsndfile.

Run the following command in the Terminal app (tips: make sure the sound file is in your current directory or else provide a path; put quotes around sound files with spaces):

sndfile-info soundfile.wav

Here is an example read-out:

File : soundfile.wav
Length : 34552556
RIFF : 34552548
WAVE
fmt  : 16
  Format        : 0x1 => WAVE_FORMAT_PCM
  Channels      : 1
  Sample Rate   : 48000
  Block Align   : 3
  Bit Width     : 24
  Bytes/sec     : 144000
data : 34552512
End

----------------------------------------
Sample Rate : 48000
Frames      : 11517504
Channels    : 1
Format      : 0x00010003
Sections    : 1
Seekable    : TRUE
Duration    : 00:03:59.948
Signal Max  : 3.6503e+06 (-7.23 dB)

Use SoX

How to install SoX.

Invoke the following in the Terminal (once again, make sure the sound file is in your current directory or else provide a path):

sox soundfile.wav -n stat

Here is an example read-out:

Samples read:          11517504
Length (seconds):    239.948000
Scaled by:         2147483647.0
Maximum amplitude:     0.435150
Minimum amplitude:    -0.415886
Midline amplitude:     0.009632
Mean    norm:          0.037648
Mean    amplitude:    -0.000052
RMS     amplitude:     0.056270
Maximum delta:         0.052995
Minimum delta:         0.000000
Mean    delta:         0.004222
RMS     delta:         0.006267
Rough   frequency:          850
Volume adjustment:        2.298

Or, you can use the following command (note the “s” on the end of the word stats):

sox soundfile.wav -n stats

Here is the example read-out:

DC offset  -0.000052
Min level  -0.415886
Max level   0.435150
Pk lev dB      -7.23
RMS lev dB    -24.99
RMS Pk dB     -15.07
RMS Tr dB   -3202.27
Crest factor    7.73
Flat factor     0.00
Pk count           2
Bit-depth      23/24
Num samples    11.5M
Length s     239.948
Scale max   1.000000
Window s       0.050

You can also use this command (note, you can replace ‐‐info with ‐‐i, if desired):

sox --info soundfile.wav

Here is an example read-out:

Input File     : '/Users/name/soundfile.wav'
Channels       : 1
Sample Rate    : 48000
Precision      : 24-bit
Duration       : 00:03:59.95 = 11517504 samples ~ 17996.1 CDDA sectors
File Size      : 34.6M
Bit Rate       : 1.15M
Sample Encoding: 24-bit Signed Integer PCM

Using QuickTime

Apple’s QuickTime Player also provides useful info.

Open the file with the QuickTime Player, then go to Window–>Show Movie Inspector (or cmd-i).

Here is an example read-out:

Inspector
soundfile.wav
Source: /Users/name/soundfile.wav
Format: Linear PCM, 24 bit little-endian signed integer, 1 channels, 48000 Hz
Data Size: 34.6 MB

Leave a Reply