TidalCycles inhabit maps string names to patterns, allowing a pattern of strings to select and play named sub-patterns
inhabit [(name1, pat1), (name2, pat2), ...] stringPattern replaces each string event in stringPattern with the corresponding named pattern. This inverts the usual Tidal flow: instead of building one pattern, you define a library of named sub-patterns and write a high-level sequence of names that calls them. The example builds a custom drum kit — bd, hh, sd — from modular synthesis patches, then addresses them by name in a standard drum notation string. Particularly useful with MIDI-controlled drum machines where notes trigger specific sounds: inhabit lets you write "[bd*8?, [~hh]*4, sd(6,16)]" using meaningful names rather than MIDI note numbers.
Examples
do let drum = inhabit [("bd",s "sine" |- accelerate 1.5),("hh",s "alphabet:7" # begin 0.7 # hpf 7000),("sd",s "invaders:3" # speed 12)] d1 $ drum "[bd*8?, [~hh]*4, sd(6,16)]"
Assessment
What is the advantage of inhabit over using different sample names directly? Design an inhabit expression that maps ‘kick’, ‘snare’, and ‘open’ to three different synthesis patches. How does inhabit relate to the concept of abstraction in programming?