Sample rate conversion explained with SoX examples

Sample rate conversion is a big dilemma that comes up quite often. You know you need it sometimes but not sure when and why. This entry will help you out with real world examples using one of the best – and actually free – sample rate converters called SoX.

The sampling rate of an audio file is very similar to the frames per second of a film. For example in CD audio you have a standard sample rate of 44,100 Hz, which means that each second of the audio file is “built up” using 44,100 samples. These samples are captured during the analogue-to-digital conversion when a continuous analogue signal is converted to discrete samples.

What samlple rate should you choose for recording your tracks?

The upper limit of human hearing is 20,000 Hz. According to the Nyquist-Shannon sampling theorem you can restore the original analogue signal without information loss if you choose a sampling rate which is at least the duplicate of the highest frequency present in your analogue signal. Otherwise some ugly distortion will occur (called aliasing). So if your analogue source goes up to 20,000 Hz, you will need a sampling rate of at least 40,000 Hz; the standard has been set to 44,100 Hz.

Why to choose higher than 44,100 Hz sampling rates?

When your tracks are processed with digital processors (including software plugins), these tools will usually work more precisely (i.e. with less artifacts) at higher samlple rates thus the results will sound better.

I usually suggest recording audio files at a sampling rate of 48,000 Hz and keep this rate until the end of the mastering stage, then convert in the very last step.

The final sample rate of your songs will be determined by the standard requirements of the medium it will be published on. For example if you’re planning to release your music on DVD, you should use a sample rate of 96,000 Hz from the very beginning. However, most often a CD audio format will be needed too, so conversion will most likely be necessary. And here can things go pretty ugly…

The built in sample rate converter in most DAWs are not that top-notch at all. If you simply load your files in your DAW and export them at a lower sample rate setting you will probably lose sound quality. Fortunately there are many great tools to overcome this issue including my go-to high-end sample rate converter called SoX, which I think is the best free sample rate converter. But using it can be tricky as it has no graphical user interface. But no worries, here comes the solution:

  • Download a copy of the latest SoX version for Windows here: http://sourceforge.net/projects/sox/files/sox-win/
  • Extract the files or install the program (I prefer zip packages but it’s up to you)
  • Unzip the archive below and copy the files to the directory where you unzipped/installed SoX:
    sox-examples.zip
  • Create shortcuts to the .bat files on your desktop (right click->send to->desktop (create shortcut))
  • Now simply drag the wave files (yes, you can add more simultaneously!) to the desired shortcut icon
  • The converted files will be put to a directory named ‘converted’ within SoX’s folder. Each example is set to the best available very high quality conversion.

In my examples there’s a file called ‘44.1kHz_16bit_dither_noise_shaping_VHQ.bat‘, use this only for final masters: no audio processing should be done to the files afterwards!

If you wish to convert to a different sample rate just open the bat files with a text editor and change the number 44100 to whatever you’d like to.

For advanced users: I added the -G option to every conversion to prevent clipping. If you want to leave the gain unchanged simply delete the -G switch in the bat files using a text editor.

If you’d like to see how SoX actually performs in sample rate conversion compared to your DAW or even high-end hardware boxes then take a look here: http://src.infinitewave.ca/

Happy converting!

Sample rate conversion explained with SoX examples