Subsystem Search

Several kits at once, and switching live

By the end of this chapter, two kits play at once, each on a MIDI channel of its own, beside your keyboard, and a MIDI Program Change switches between kits as you play.

The project so far

The project from Keeping a sample library: the keyboard, the held note and the loop in midi-map.yaml, and your kit in kits/kitchen/, with its map, its names and its sounds. Write midi-map.yaml with the configuration naming it, then point the configuration at the kit and write that:

$ mkdir kitchen-kit
$ cd kitchen-kit
$ subsample --init
…
recorder:
  enabled: true
  audio:
    audio_format: flac
    bit_depth: 24
player:
  midi_map: midi-map.yaml
  watch_midi_map: true
  enabled: true
library:
  max_memory_mb: 512
  watch: true
similarity:
  weight_timbre_onset: 2
detection:
  release_threshold_db: 4
  retrigger_threshold_db: 15
  min_peak_db: -45
tempo:
  bpm: 120
assignments:
  - name: Glass keys
    channel: 1
    notes: C3..C6
    select:
      where:
        name: note_1
    process:
      - repitch: true
    mode: gated
  - name: Glass drone
    channel: 1
    notes: C2
    select:
      where:
        name: note_1
    mode: loop
  - name: Table loop
    channel: 1
    notes: G2
    select:
      where:
        name: taps
    process:
      - stretch_quantize: { grid: 16 }
    mode: loop
player:
  midi_map: kits/kitchen/midi-map.yaml
notes:
  kick: 36
  snare: 38
  hat: 42
  open_hat: 46
cc:
  brightness: 74
channels:
  kit: 10
definitions: { my: names.yaml }
channel: my.kit
templates:
  pad:
    process:
      - compress: true
  quiet:
    gain: -6
assignments:
  - name: Kick
    template: pad
    notes: my.kick
    select: { where: { directory: kick }, pick: any }
  - name: Snare
    template: pad
    notes: drum.snare_1
    select: { where: { directory: snare }, pick: any }
    stack: true
  - name: Snare layer
    template: [pad, quiet]
    notes: drum.snare_1
    select: { where: { directory: layer }, pick: any }
    stack: true
  - name: Closed hi-hat
    template: pad
    notes: drum.hi_hat_closed
    select: { where: { directory: hat }, pick: any }
  - name: Open hi-hat
    template: pad
    notes: drum.hi_hat_open
    select: { where: { directory: open-hat }, pick: any }
    silenced_by: drum.hi_hat_closed

A second kit

Your second kit comes from the same take, split in two. Make a folder for it, kits/worktop/, with kick, snare and hat folders inside, and move about half the sounds in each of the kitchen kit's folders into the worktop's, each with its two files:

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

$ mkdir -p kits/worktop/kick kits/worktop/snare kits/worktop/hat
$ mv kits/kitchen/kick/hits_2.wav* kits/worktop/kick/

Point the player at a map for it, to hear it on its own:

player:
  midi_map: kits/worktop/midi-map.yaml

And write the map, as kits/worktop/midi-map.yaml:

channel: 10
assignments:
  - name: Kick
    notes: drum.kick_1
    select: { where: { directory: kick }, pick: any }
  - name: Snare
    notes: drum.snare_1
    select: { where: { directory: snare }, pick: any }
  - name: Closed hi-hat
    notes: drum.hi_hat_closed
    select: { where: { directory: hat }, pick: any }

It is the plainest of kits, the sounds as you recorded them. Start Subsample again, and play it on MIDI channel 10.

Two kits at once

The configuration can play several maps at once, each on a MIDI channel of its own:

player:
  midi_map: null
  midi_maps:
    10: kits/kitchen/midi-map.yaml
    11: kits/worktop/midi-map.yaml

Start Subsample again, and the kitchen kit plays on MIDI channel 10 and the worktop kit on 11. player.midi_maps gives each map its MIDI channel, which replaces the one the map names itself, so the worktop kit plays on 11 without an edit. A pad that names a MIDI channel of its own keeps it, and Subsample says so as it loads. A configuration names its maps one way or the other, so midi_map is set to null to make way for midi_maps.

An ensemble in a map

The configuration is not watched as you play, so a change to it takes a restart, and it cannot use names from a definitions file. A map can play other maps too, beside pads of its own, and a map that does is an ensemble. Point the player back at midi-map.yaml:

player:
  midi_map: midi-map.yaml
  midi_maps: null

And add the kits to it, below the keyboard, the held note and the loop:

maps:
  - kits/kitchen/midi-map.yaml
  - { channel: 11, map: kits/worktop/midi-map.yaml }

Now the keyboard, the held note and the loop play on MIDI channel 1, the kitchen kit on 10, and the worktop kit on 11. A map named alone in maps plays on the MIDI channel it names itself, and one written with a channel plays on that; the ensemble can mount a definitions file and write channel: my.kit. Two rules keep an ensemble simple:

An edit to a kit's map reloads the ensemble, as an edit to its own file does, and a map added to maps is watched from the reload that reads it.

Switching kits

A MIDI Program Change is the message a sequencer or a keyboard sends to choose an instrument, a number from 0 to 127. Subsample can answer one by switching kits. Write a map of programs, programs.yaml, in the project folder, and point the player at it:

player:
  midi_map: programs.yaml
programs:
  - { name: Kitchen, program: 0, map: kits/kitchen/midi-map.yaml }
  - { name: Worktop, program: 1, map: kits/worktop/midi-map.yaml }
program_channel: 10

Start Subsample again, and it plays the kitchen kit, the first program. Send Program Change 1 on MIDI channel 10, from your sequencer or a keyboard's program buttons, and the pads play the worktop kit; Program Change 0 brings the kitchen back.

For everyday playing, point the player back at the ensemble; programs.yaml is there whenever you want to switch kits instead:

player:
  midi_map: midi-map.yaml

A program can name a directory instead of a map. It keeps the map's own pads, and gives them that folder's sounds to choose from, found from where Subsample runs rather than from the map: the same pads, other sounds. A sound the map names itself, with a path or a directory in a pad's where, plays in every such program.

A program and a directory in a pad's where both choose sounds by folder, and do different jobs. A program swaps every sound the player chooses from at once, one program at a time. A directory in a pad chooses within what is there, a folder for each pad, all at once, as your kits' pads do.

With two kits and a switch between them, the next chapter lets other software play Subsample: a sequencer on the same machine, its tempo, and a message to another program each time Subsample captures a sound.