Playing with the sampling rate

1. Writing a user-specified sampling rate to the header of an audio file:

sox -r 48k source.wav destiny.wav

Audio applications will now interpret destiny.wav as a 48 KHz file, even if this is different from the sampling rate originally used to record the file. In that case the pitch and duration of the file with be changed (akin to altering the playback speed of analogue media). I use this occasionally to fix things (or to break them on purpose..).

2. Resampling:

sox source.wav -r 48k destiny.wav

modifies the audio data in the file without altering the pitch and duration of the recording. The rate effect can be used for the same purpose:

sox source.wav destiny.wav rate -v 48k

(-v = Very High Quality Resampling, the documentation recommends to use this option for bit depths > 16 bit)
For further options see here and here.

3. The speed effect is actually a combination of #1 and #2:

sox source.wav destiny.wav speed 1.0884

changes the playback speed of the source file by a certain ratio, and resamples it back to the source sampling rate.

Leave a Reply

Your email address will not be published. Required fields are marked *