Music Theories Blog

audio-collager

For years I've wanted a simple commandline utility for audio collaging. This was a big problem when I was making a lot of click tracks because in that situation you often need some way to take a whole set of .wav files of count-ins, metronome-clicks and reference pitches and arrange them into an output file.

I've previously made something that filled this function in Supercollider, but then, even if it's running headless, it's still around 40MB, which is far too large, given what I'm asking it to do. A couple of hundred kilobytes sounds much more reasonable. So, I made audio-collager. It takes in a file written in a simple, declaratice Domain Specific Language that references any number of input wav files, and outputs a single wav file that has collaged together all the inputs files.

It is written completely in nim and the code can be downloaded at https://github.com/dpocknee/audio-collager.

Here is an example file:

LENGTH 1m
FILE test/tester.wav ALIAS testAlias

// Comment

AT 0s INSERT SINE 440Hz FOR 1s VOLUME 0.25
AT 1s INSERT NOISE FOR 0.9s VOLUME 0.25

AT 2 seconds INSERT test/tester.wav FROM 5s FOR 50ms
AT 2 seconds 300ms INSERT testAlias FROM 5s FOR 50ms
AT 2 seconds 800 milliseconds INSERT testAlias FROM 10s FOR 25ms
AT 3 seconds INSERT testAlias FROM 10.1s FOR 25ms
AT 3.1s INSERT testAlias FROM 10.3s FOR 25ms

AT 4s INSERT SINE 440Hz FOR 2s VOLUME 0.25
AT 4s MIX test/tester.wav FROM 10s TO 12s
AT 8s MIX test/tester.wav FROM 10s TO 12s VOLUME 1.0 0.0
AT 10s MIX test/tester.wav FROM 10s TO 12s VOLUME 0.0 1.0