Skip to content

Instantly share code, notes, and snippets.

@mcandre
Last active November 26, 2019 02:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcandre/ad90653d9874e38007114d5b625f54a9 to your computer and use it in GitHub Desktop.
Save mcandre/ad90653d9874e38007114d5b625f54a9 to your computer and use it in GitHub Desktop.
patches, bb!

patches: Creating sound kits

a lil shell guide by mcandre

EXAMPLE

Ol' Rolly Ate-Oh-Ate Backup

ABOUT

Sound kits (pronounced "patches") are a great way to expand the power of musical instruments, such as the Bastl microGranny, KORG Volca Sample, Teenage Engineering OP-1, OP-Z, PO-33 Sample, PO-35 Speak, PO-137 Rick & Morty synthesizers, and many more. Of course, you can load sounds one at a time into synthesizers, but that's for slowpokes. And you may be limited by number of samples or by filenames, depending on the synth.

Alright, cool. You can sample from 3.5mm T(R(R))S line-in, perhaps a hot mic, or some digital audio files. Now you want manage all these sounds and queue them up faster. Maybe you don't own a synthesizer (gasp!), in which case patches still serve a useful function. Patches can give you a quick impression of all the different sounds in a collection, much faster than you can trigger them by hand.

We recommend patches!

Packing multiple sounds into patches is a convenient way to quickly transfer and load hundreds of amazing sounds into your devices. Then you can spread samples across the controls. You can assign favorite sounds to each keyboard key or button as you wish. This is performed by scrobbling (that's the technical term) the start/stop timing of each sample within a patch.

Old and busted: Compressed archives and deep folder hierarchies with mixed audio formats.

New hotness: Patches, bb!

With a few terminal commands, you can quickly convert large folders of individual sounds into sound kit bundles suitable for patching synthesizers.

OPEN SOURCE PATCHING SOFTWARE (FREE OF CHARGE)

With limited command line knowledge, you can quickly assemble complex patch files using these UNIX tools.

Windows users: See the Windows Linux Subsystem or Git, etc. for access to bash and findutils.

Recommended

  • mplayer command line audio player
  • wget Web crawler
  • Audacity GUI audio editor for slowpokes
  • some tweezers for replacing microSD cards (esp. from microGranny)

WARNINGS

Per-synthesizer requirements

Some samplers require very specific audio formats, such as different bitrate settings. Refer to your particular synthesizer's documentation for audio format requirements.

Audio Quality

Synthesizers typically expect a less than perfect audio copy than your samples start with. You may want to backup your original files before building patches. The examples here use a 100% migroGranny-focused workflow, where we expect 16-bit or even 8-bit quality for everything (chiptunes!).

Remember, you can build pre-synthesizer patches at an audio standard suitable to your audiophile taste, and then converting that to a separate downsampled file for your synth. So feel free to tune the steps below to your needs.

Note that many file systems, including FAT-32, place restrictions on maximim file size. Typical patches are kept under 4 GB. Anyway, any patch that big is going to take a long ass time to scrobble through for the right sound.

Note that patch files can be larger or smaller in bytes than the original input files, depending on which settings you use to build your patches. Regardless, grouping your sounds in patches will definitely free up more sampler slots compared with individual sound files. You'll soon be rocking out with so many different instruments and sound boards!

Unstable kit ordering

Some of these steps operate nondeterministically, in parallel , and/or with varying ordering logic. The resulting concatenated sound kit sample order may not match the original input filename order. Repeated runs of these steps may result in different sound kit sample orderings compared to previous runs. Optionally, pass unified filenames through sort before sending to the concatenator. This may not necessarily match the original recursive tree filename order, but this would ensure a consistent sample output ordering.

OVERVIEW

The larger goal is to organize many custom sounds onto your synthesizer. In order to do that, we group (concatenate) sounds into patches. Before we can concatenate the sounds, we need to standardize (unify) the original sounds into a common audio format. Unify, concatenate, jam.

STEPS

  1. Unify audio format, sample rate, channel count, and bitrate.

Start by generating a consistent audio format for each of the samples in your collection. For example, scan for all WAV files recursively, converting each file to a 22050 Hz mono 32 K bps WAV file:

$ cd deep-samples/

$ find . -iname '*.wav' -print0 |
    while IFS= read -r -d '' line; do
        ffmpeg -i "./${line}" -b:a 32k -ac 1 -ar 22050 "./${line}.22050rate.mono.32k.wav";
    done

Input extensions

If you have many different audio formats to input, you can run this command several times with -iname '*.mp3', -iname '*.aif', and so on, taming even more kinds of audio files!

Note that i in the -iname flag is optional, indicating case insensitivity. If for some reason you want to limit a find command to exact case match, then you can drop the i, using the -name flag instead.

  1. Prepare an ffmpeg input script declaring unified input files.

Now we generate an ffmpeg script to input the individual, unified samples. For example, scan for all 32 Kbps WAV files:

$ find . -iname '*.32k.wav' -print0 |
    while IFS= read -r -d '' line; do
        echo "file '$line'" >>list.txt;
    done

$ cat list.txt 
file './ffire13.wav.22050rate.mono.32k.wav'
file './ffire3.wav.22050rate.mono.32k.wav'
file './ffire4.wav.22050rate.mono.32k.wav'
file './ffire8.wav.22050rate.mono.32k.wav'
file './ffire5.wav.22050rate.mono.32k.wav'
file './ffire9.wav.22050rate.mono.32k.wav'
file './ffire12.wav.22050rate.mono.32k.wav'
file './ffire2.wav.22050rate.mono.32k.wav'
file './ffire7.wav.22050rate.mono.32k.wav'
file './ffire10.wav.22050rate.mono.32k.wav'
file './ffire11.wav.22050rate.mono.32k.wav'
file './ffire1.wav.22050rate.mono.32k.wav'
file './ffire6.wav.22050rate.mono.32k.wav'

Read through your list and remove the file lines for any samples that you don't want to include in your sound kit.

  1. Send the unified file list through the concatenator.

Take the ffmpeg script we generated earlier and feed it into ffmpeg to concatenate the files. For example, concatenate inputs to a single WAV file:

$ ffmpeg -f concat -safe 0 -i list.txt -c copy my-kit.wav

$ file my-kit.wav 
my-kit.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 22050 Hz

Name patches to suit any sampler filename requirements:

$ mv my-kit.wav D2.wav
  1. Send patch to synthesizer.

Copy patches to the synthesizer. For example, drag & drop / rsync / cp your fresh new patches onto a FAT-32 formatted microSD card for the Bastl microGranny. Use the sampler interface to activate the desired patch.

  1. We Jammin!

AND I HOPE YOU LIKE JAMMIN, TOO

FURTHER MISADVENTURES

Create a handy Markdown guide for your patches:

$ echo "D2.wav: Digital Paintball 2 sfx" >>README.md

$ cat README.md 
D2.wav: Digital Paintball 2 sfx

For example, microGranny manages patches with a simple FAT-32 file system, where you can copy patches and Markdown files together onto a microSD card. This way, you'll always remember how patches map to filenames.

You can cleanup the generated files (e.g., rm README.md, rm D2.wav, rm my-kit.wav, rm list.txt, rm *.32k.wav). Though be careful that you don't accidentally delete your original sample files!

When in doubt, back up your files on an external system just in case. That way, if ever you lose (or trade) your synth, later, you can reconstruct all your old patches. For example, upload a .TGZ of your patch files, or even a whole dd image of the file system.

SOUND BANKS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment