In this post, I will show you how to do a batch conversion of whole sample packs (e.g from MusicRadar) into the right format for the Erica Sample Drum by combining Sox and shell scripting.

The backstory

A while ago, I got an Erica Sample Drum module and am loving it so far. The reason why I like it so much is because it combines everything I loved about the Elektron Digitakt and the freedom that comes from Eurorack patchability.

I soon found that, although there’s plenty of free and interesting samples out there (e.g. from MusicRadar), their format is not always compatible with what the Erica Sample Drum can play. You can of course convert them into the right format using Audacity for example, but this gets tedious real quick when you have to convert +10 samples. In this post, I will show you how to do a batch conversion of whole sample packs into the right format for the Erica Sample Drum. I’ll do so by combining Sox and shell scripting.

The Erica Sample Drum requires that the samples on it’s memory card are 16-bit *.wav files with a sample rate of 48kHz. Furthermore, to make efficient use of the space on the memory card, I recommend to only use mono samples, as the Sample Drum does not handle Stereo files (well, it does handle them, but you have to select which channel that you want to load to memory).

For music production, I mainly use a Mac, so this tutorial will show you how to do it on a Mac. I’m guessing that on Linux things will be quite similar. On Windows, the required Sox command should be identical, but the shell scripting will look different. The latter is out of scope for this tutorial.

Basic Sox conversion command

You can get the installers for Sox from Sourceforge. First install Sox. Next open up a terminal and navigate to the directory where your sample pack is located. Finally, use the following conversion command :

sox -G input.wav --norm=-1 -b 16 -r 48k -c 1 output.wav

Let’s dissect this command

  • -G, –guard, Use temporary files to guard against clipping
  • input.wav, the input file, you can also use an mp3 file or many other input formats
  • –norm=-1, normalises the output to -1dB, this can be quite useful to compensate for volume differences between sampleps
  • -b 16, sets bit-depth of the output file, 16 bits in this case
  • -r 48k sets the sample rate of the output file to 48 kHz
  • -c 1 converts the output to a 1-channel file, i.e. mono
  • output.wav, the output file

Batch conversion of MusicRadar sample packs

Below is the shell script I use to convert whole sample packs that contain multiple subdirectories. To use my script, first navigate in the terminal to where your sample pack is located, then copy paste this script into your terminal.

rmdir ../temp #if there's a temp dir, let's remove it
mkdir ../temp #now make a new temp dir
find . -type d -print0 | while read -d $'\0' subdir; #find all subdirectories
do echo $subdir; mkdir ../temp/${subdir// /}; #and recreate them in the temp dir
done
find . -name "*.wav" -print0 | while read -d $'\0' file; #find all *.wav files to convert
do echo $file; # for each file found
sox -G "$file" --norm=-1 -b 16 -r 48k -c 1 ../temp/${file// /}; #convert to temp directory and remove spaces from filename
done

First, my script will create a temporary directory one level above the current directory, where it will put all converted samples, with the same directory structure. In addition, my script will also remove any spaces from the output filenames and directories. The latter is important because the Erica Sample Drum can only show a limited number of characters on its screen. Thus, by kicking out the spaces, we get more information onto the screen.

Here’s an example of what the script’s output looks like when converting the Ambient Drum Samples pack from Musicradar.

Ozzy:Ambient Electronic samples tverscho$ ls
Electro effects	Hats		Kicks		Snares		Toms
Ozzy:Ambient Electronic samples tverscho$ rmdir ../temp
rmdir: ../temp: No such file or directory
Ozzy:Ambient Electronic samples tverscho$ mkdir ../temp
Ozzy:Ambient Electronic samples tverscho$ find . -type d -print0 | while read -d $'\0' subdir; 
> do echo $subdir; mkdir ../temp/${subdir// /};
> done
.
mkdir: ../temp/.: File exists
./Hats
./Toms
./Electro effects
./Snares
./Kicks
Ozzy:Ambient Electronic samples tverscho$ find . -name "*.wav" -print0 | while read -d $'\0' file; 
> do echo $file;
> sox -G "$file" --norm=-1 -b 16 -r 48k -c 1 ../temp/${file// /};
> done
./Hats/Closed_Hat_001.wav
./Hats/Closed_Hat_038.wav
./Hats/Closed_Hat_012.wav

...

./Kicks/Kick_140.wav
./Kicks/Kick_808_ish01.wav
./Kicks/Kick_034.wav

Ozzy:Ambient Electronic samples tverscho$ 

When we go and have a look at the outputs in Finder, we can clearly see that all subdirectories have been copied, spaces have been removed, and that the conversion has taken place. The latter we can see from the slightly larger file sizes, as the original encoding was 16-bit, 44.1 kHz, and the new one is 16-bit, 48 kHz.

Here’s how the output of the batch conversion script looks in Finder.

As a final step, copy the contents of the temp directory to Sample Drum’s SD card and start enjoying your freshly pressed samples.

And now for some music

Here’s a track I made with my newly converted samples. The patch consists of one channel of the Erica Sample Drum, sequenced by a Korg SQ-1 and Mutable Instruments Plaits and Rings being sequenced by the Music Thing Turing Machine. Tip-top Z-DSP (Valhalla Reverb cartridge) and Strymon Magneto take care of the reverb and delay.

Sources

Here’s a few articles on which I based this post.

Finally,

If you enjoyed this tutorial I’d love to hear! Feel free to drop a comment, send me an e-mail our like my Facebook page.

Also, have a look at my upcoming module, Steve’s MS-22.

Regards,
Tom

PS: Have a look at the follow-up post to this one: