# What software do you use to decimate (downsample) your large acoustic files?

I have a large acoustic dataset (multiple years) with 6 hour recordings at 48 kHz sample rate. I am looking at patterns in humpback whale chatter and want to downsample my data to a 4 or 6 kHz sample rate. I have been using the Triton package in Matlab, developed by the Scripps Whale Acoustic Lab/Acoustic Ecology Lab. When I use the 'decimate' function to downsample my data, I find that it loses some data at the edge of the specified sample rate - i.e. if I decimate my 48 kHz sample rate to a 4 kHz sample rate, the produced sound file only has good data from 0 - 1800 Hz, roughly. While it's unlikely that I am missing a lot of humpback vocalizations in this 1800-2000 Hz window, I am wondering if there are other softwares that will downsample without losing samples near the nyquist frequency. Additionally, it takes several days to decimate a 3-4 month deployment in the Triton package.

A colleague recommended SoX (Sound eXchange), but I have had trouble getting it to work. They said it doesn't lose any data near the nyquist, and that it decimates much faster than Matlab.

Does anyone else use Sox? Or another software to decimate their large datasets?

You should be able to decimate files using Pamguard and apply the proper anti-aliasing filter to avoid losing samples. See the attached image below of the help menu for the decimator module.

If you want to also save those files rather than just decimating and running a detector within the program, you should be able to do it within the software by setting up a sound recorder module. You then direct the sound recorder to save those decimated .wav files.

Unfortunately, before down-sampling you have to apply an anti-aliasing filter that removes all energy at and above Nyquist. what you are looking for is sharp anti-aliasing filters, which indicates large filters (lot of taps in case of FIR filters).

There are two ways to help you, decimate not in one step 48/12 = 4, but in 3 steps 48/2/2/3. Such sequential down-sampling helps in terms of numerical stability as you use shorter filters. The other way is to down-sample to 6 kHz 48/2/2/2. The trade off is your decision (loosing frequency, or larger files)

my go to for batch processing/downsampling is Adobe Audition. There is a cost associated with this software but think Adobe largely moved to a monthly subscription model. If you do go that route, here's a short video about how to batch process a set of files - selecting your sample rate and adding filters, etc. are also functions of the same.

Matlab got a command that includes (zero delay) filtering: https://se.mathworks.com/help/signal/ref/resample.html

If you want to go forward with using SoX, once installed it's pretty easy to use. It is much faster than other programs that need GUIs to run, and I have never noticed data loss. However the set up can be a trip.

Next, install it as per the installers instructions. I find it useful to keep in my Program Files directory, as I use it in the Command Prompt and in Python. Then, you'll need to add it to your Path:

1. Go to My Computer → Properties → Advanced System Settings → Environment Variables → System variables.
2. Select Path.
3. Click Edit → New :

Next, open your command prompt window, and navigate to your working directory. Type sox and you should see that it is properly installed.

cd c:\Files\YourDir
sox


This will spit out a bunch of help text, which is easier to read here.

Next you can run a simple for loop to downsample your files. Here, I am making a new directory for the files, adding a prefix to the filename, and downsampling to 16k.

mkdir downsampled
for %f in (*.wav) do sox "%f" "downsampled\16k_%f" rate 16k

• I was having issues getting it set up - thanks to your answer I was able to get it working and have begun downsampling. Thank you! Jul 7, 2022 at 16:43

If you are in the world of Intel-processor macOS, try xACT (stands for x Audio Compression Toolkit). It is a nice app that does many different batch tasks with audio files. It was built on top of many of the tasks performed by SoX. Once there, check the util tab.

http://xact.scottcbrown.org/xACT2.50.zip