Subsystem Search

A drum kit from a recording

By the end of this chapter, ten sounds recorded in one room are a drum kit: play MIDI channel 10, and the kick, the snare and the hi-hats are sounds you made.

The project so far

The folder from A project folder, made by subsample --init, whose configuration differs from Subsample's defaults in one line.

$ mkdir kitchen-kit
$ cd kitchen-kit
$ subsample --init
…
player:
  midi_map: midi-map-gm-drums.yaml

Record ten sounds

Find things in one room that make a short sound when you strike them. A kitchen has plenty, and the sounds of one room sit together as a kit. Between them, cover what a drum kit needs:

Record about ten of them in one take, one after another:

Anything that records a WAV file will do: a portable recorder, a phone app that saves WAV, or a microphone and whichever program you record with. Save the take as hits.wav, in the project folder.

A recording for this step is planned. Until then, use one of your own.

Cut it into samples

Give Subsample the recording:

Example not checked: it is not run when this site is built.

$ subsample hits.wav

Given a recording, Subsample reads it rather than listening to a microphone. It finds each sound that rises out of the quiet of the room, cuts it out, trims the quiet either side of it to a short fade, measures it, and saves it as a sample, then exits.

The samples are in samples/captures/, named after the recording in the order the sounds came: hits_1.wav is the first, hits_2.wav the second, and so on. Beside each one is what Subsample measured in it, hits_1.wav.analysis.json, and a picture of it to browse by, hits_1.wav.preview.png.

The last line it prints says how many samples it cut. Fewer than the sounds you made means two ran together, because the second came before the first had died away, or that one was too quiet to rise out of the room, or came in the first second. More means something else was loud enough to count, such as a creak or a car going by. Either way, record the take again, with more quiet between the sounds.

Turn the player on

Playing the samples is the player's job, and the player is off until the configuration turns it on. In config.yaml, change two values:

recorder:
  enabled: false
player:
  enabled: true

player.enabled turns the player on. recorder.enabled is Subsample listening to a microphone while it runs, which a later chapter sets up, so turn it off for now. Both are in the file already, each under its own section, so change their values rather than adding the lines again: Subsample refuses a section written twice, such as a second player: at the end of the file, and names both its lines.

The player plays through your computer's default audio output, and listens to your MIDI input. With one MIDI device connected, it uses that one; with more than one, it asks which each time it starts. To choose them once, copy names subsample --list-devices printed into the configuration: an output's from under Audio outputs into player.audio.device, and a MIDI input's from under MIDI inputs into player.midi_device. Part of a name will do.

Play it

Start Subsample in the project folder, with no recording named this time:

Example not checked: it is not run when this site is built.

$ subsample

It loads every sample in samples/captures/, opens your MIDI input and audio output, and waits for notes. Among the lines it prints as it starts, one says how many samples it loaded from samples/captures: as many as your recording gave you. On Linux, pw-jack subsample starts it without the lines saying that a JACK server is not running.

Play MIDI channel 10 from your controller or sequencer. Note 36 is the kick, 38 the snare, 42 the closed hi-hat and 46 the open one. Stop Subsample with Ctrl-C.

How the kit chooses

The kit is the map --init wired in, midi-map-gm-drums.yaml. It covers every drum General MIDI names, from note 35 to note 81, and Subsample carries a reference for each of them: what that drum sounds like, measured in the way Subsample measures your samples. When a note arrives, the map plays the sample of yours that sounds most like its drum. With ten samples and a whole kit of drums, one sample is often the closest you have to several drums, and plays for all of them.

Each drum plays through a mix chain made for it, as a mixing desk would treat that drum in a kit:

More sounds, a better kit

The kit improves as samples arrive. Record another take, cut it in the same way, and start Subsample again: it loads every sample in samples/captures/ as it starts, so each drum chooses from more sounds, and the kick is more likely to be something that thuds.

Give each take a name of its own, such as hits-2.wav. A sample takes its name from the recording, so a second take saved over hits.wav and cut again replaces the first take's samples. A take called hits.wav in another folder keeps them, and its own samples take its folder's name too, such as day2_hits_1.wav. One run can cut several takes, subsample hits-2.wav hits-3.wav, or a whole folder of them, subsample takes/*.wav.

With a kit playing, the next chapter looks at what Subsample heard in each of your sounds, and why it chose the ones it did.