Sonic Pi filters sample packs by substring, regex, or symbol before selecting by index
When sample is passed a directory path, it builds a candidate list of all audio files. Pre-arg filters (strings, regexes, symbols, lambdas) narrow the candidate list; a final integer selects by index (wrapping like a ring). String filters match on substrings of filenames; regexes match on patterns; symbols require exact match; lambdas receive and return the full list. Multiple sources can be combined. Appending ** to a path enables recursive subfolder search.
Examples
samps = “/path/to/samples/” sample samps, “120”, “Bb”, 1, lpf: 70
Assessment
Describe step by step how sample ‘/dir/’, ‘120’, ‘piano’, 0 selects its file. Explain what changes if you pass 1 instead of 0.