Recording on one machine, playing on another
By the end of this chapter, one machine records and another plays what it records, the two sharing a folder, and each new sound is ready to play moments after it lands.
The project so far
The project from Many audio channels: your keyboard and two kits played together, the keyboard on outputs of its own, recording from a pair of inputs, with the maps and kits as the chapters before left them. Only the configuration matters here:
mkdir kitchen-kit
cd kitchen-kit
subsample --init
recorder:
enabled: true
audio:
input: [3, 4]
audio_format: flac
bit_depth: 24
player:
midi_map: midi-map.yaml
watch_midi_map: true
enabled: true
virtual_midi_port: Subsample Virtual MIDI
audio:
channels: 4
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
source: midi
osc:
enabled: true
receive_enabled: true
Two machines, one folder
Recording and playing can happen in different places: a recorder left by a window while you play in another room, a machine backstage feeding the one on stage, or the measuring of every sound kept off the machine you play on. Subsample splits that way with two projects, one on each machine, and a folder they share: the one that records writes each sound there, and the one that plays watches it, and loads each sound as it arrives.
Share the folder with a folder sync tool, such as Syncthing or Dropbox, which keeps a copy of it on each machine, or put it on a network drive. With a sync tool, the machine that plays holds every sound itself, and hears of each new file through its own system's notice that one has arrived. A file another machine writes onto a network drive gives no such notice, so the player checks a watched folder there every two seconds, and if the drive drops, the library stays as it was until it is back.
The machine that records
On the machine that records, make a project as in A project folder, with its own configuration. Give it the shared folder's path, and turn its player off:
recorder:
enabled: true
directory: /home/keanu/Sync/captures
player:
enabled: false
recorder.directory is where each recording goes, and Subsample makes the folder if it is missing. A path in the configuration may start with ~ for your home folder, as ~/Sync/captures. Choose this machine's microphone as in Recording well.
The machine that plays
Your project so far becomes the one that plays. Move your library into the shared folder, so everything it plays from is in one place, sounds such as note_1 that your maps name among them, and then point the library at it:
Example not checked: it is not run when this site is built.
mv samples/captures/* /home/keanu/Sync/captures/
recorder:
enabled: false
player:
enabled: true
library:
directory: /home/keanu/Sync/captures
watch: true
When it starts, the player loads the shared folder, and with library.watch it watches it for what the other machine records. Your kits are untouched, since their sounds are in their own folders, found from their maps.
When a new sound is ready
The machine that records writes each sound's audio first and its analysis second, so the analysis arriving means both are there, and whole. The player waits for it, then loads the pair without measuring the sound again, a moment after the analysis lands, a little later where a sync tool takes a moment to copy, and up to two seconds later on a network drive. If the audio has not arrived yet, or is still arriving, the player tries again.
Sounds from other programs
Anything that writes audio into the folder can feed the player: a digital audio workstation, a recorder of radio, a script. A file that arrives without an analysis, as those do, the player measures once the file stops growing, and loads, and writes its analysis beside it for next time, so it takes a few seconds longer. It reads WAV, FLAC, AIFF, OGG and MP3, and watches the folder itself but not the folders inside it, so new files belong at its top.
With the recording in one place and the playing in another, the last chapter makes the playing as quick as your machine allows: the least delay between a key and its sound, and no clicks.