home/ modules/ sonic-pi-samples-fx-and-generative-texture

Sonic Pi: samples, FX and generative texture

  • learner can load, slice, stretch and re-pitch samples for beat construction
  • learner can wrap sounds in FX efficiently and build layered synth timbres
  • learner can use deterministic randomness and probability to vary a pattern reproducibly

Produce a Sonic Pi track that beat-slices an external break, layers an additive/detuned synth pad through FX, and uses a fixed random seed with one_in probability so the 'random' variation is reproducible on replay.

This module is where Sonic Pi stops being a toy sequencer and becomes a breaks machine: the whole task is a jungle/breakbeat-style track built from an external drum break you supply, re-chopped in code the way an MPC or beat-slicing sampler would do it, with a wide detuned pad floating over the top and variation that sounds random but replays identically — the property that lets you rehearse a “generative” section and still perform it live with confidence.

Start supported: load your break from disk (“Sonic Pi plays external audio files by passing a file path string to sample”) and lock it to the grid with beat_stretch so tempo changes stop breaking your loop. Then chop — first by manual slice math (“Chopping a sample into equal slices and playing them in random order creates beat-slicing effects”), then the idiomatic shortcut (“onset: pick… selects a random transient event”). Re-pitch slices with rpitch: once you understand why rate changes pitch and duration together. In parallel, build the pad from stacked detuned voices and wrap everything in FX the right way — loop inside the block, not the reverse, or your Raspberry Pi will choke. Finally, tame the randomness: one_in gives probabilistic hits, use_random_seed pins them down, and the determinism principle explains why that grip matters for performance.

Every required atom is load-bearing for the capstone: you cannot chop, stretch, layer, or reproduce the variation without them, and the drills (slice math, beat_stretch, with_fx placement, seeding) are the moves you’ll repeat until automatic. Supporting atoms widen the palette — sample-pack filtering, the slicer FX and its probabilistic gate, acid bass via :tb303, parameter slides, Euclidean spreads — plus historical context on why loop-thinking dominates this music. Reach for them after the capstone stands on its own.

Runnable examples

Generated from the context/ instrument corpus by concept (redistributable idioms only). Do not edit — regenerate with gen-module-examples.mjs.

sample-chop

s("breaks125:0").chop(8)

strudel-0020 · CC0

d1 $ chop 8 $ sound "break:0"

tidal-0019 · CC0

resonant-filter

SinOsc s => LPF f => dac; 400 => f.freq;

chuck-0002 · MIT

play :e2, cutoff: 90, res: 0.9, release: 0.3

sonicpi-0022 · CC0

euclidean-rhythm

s("bd(3,8)")

strudel-0004 · CC0

d1 $ sound "bd(3,8)"

tidal-0004 · CC0

detune-thickening

saw [110, 110.2] >> audio

punctual-0009 · CC0-1.0

d1 $ note "c2" # sound "supersaw" # detune 0.3

tidal-0039 · CC0

swing

s("hh*8").swingBy(1/3, 4)

strudel-0008 · CC0

d1 $ swingBy (1/3) 4 $ sound "hh*8"

tidal-0008 · CC0

step-probability

play :e4, release: 0.1 if one_in(3); sleep 0.25

sonicpi-0044 · CC0

SinOsc s => dac; while(true){ if(maybe) 440 => s.gain; else 0 => s.gain; 125::ms => now; }

chuck-0047 · MIT

additive-synthesis

{ Klang.ar(`[[100, 200, 300, 400], [0.4, 0.3, 0.2, 0.1]]) * 0.1 }.play

supercollider-0022 · CC0

reverse-playback

d1 $ sound "bd sn" # speed "-1"

tidal-0056 · CC0

seeded-randomness

use_random_seed 42; 8.times { play (scale :e3, :minor).choose; sleep 0.25 }

sonicpi-0051 · CC0

Atoms in this module

Required — these gate the capstone

Sonic Pi plays external audio files by passing a file path string to sample
Procedure L2 First instrument F
Changing a sample's playback rate simultaneously shifts its pitch and duration
Principle L1 Foundations FB
Sonic Pi's start: and finish: opts play arbitrary sub-sections of a sample
Procedure L2 First instrument F
Sample envelopes auto-set sustain to remaining sample length unless overridden
Concept L2 First instrument F
Sonic Pi's onset: option indexes a sample's drum hits like a list, so you can play individual hits by number
Procedure L2 First instrument FN
rpitch: shifts a sample's pitch by semitones without manually calculating the equivalent rate
Procedure L2 First instrument F
Chopping a sample into equal slices and playing them in random order creates beat-slicing effects
Procedure L3 Craft FC
beat_stretch: maps a sample to a specified beat count at the current BPM
Procedure L2 First instrument F
onset: pick in Sonic Pi selects a random transient event from a sample for instant hit variation
Procedure L3 Craft FC
with_fx wraps code in an audio effect that processes all sounds generated inside the block
Procedure L2 First instrument F
Placing with_fx inside a loop creates one FX instance per iteration, wasting CPU
Principle L3 Craft F
Additive synthesis in Sonic Pi layers multiple synth voices at different pitches and amplitudes to create new timbres
Procedure L3 Craft FB
Slight pitch offset between two identical synth voices creates beating and perceptual thickness
Concept L3 Craft FB
Using one_in(N) in a live_loop creates probabilistic drum patterns with adjustable density
Procedure L2 First instrument F
use_random_seed resets Sonic Pi's random stream so a live_loop produces a repeatable random pattern
Procedure L2 First instrument F
Sonic Pi's randomness is deterministic so a 'random' pattern you like can be reproduced and performed
Principle L3 Craft FN

Supporting — enrichment, not gating

Sonic Pi filters sample packs by substring, regex, or symbol before selecting by index
Procedure L3 Craft F
The :slicer FX modulates amplitude rhythmically using a control wave at a configurable phase duration
Procedure L3 Craft FB
The :slicer FX's probability: opt gates each phase on or off deterministically for random-sounding rhythms
Procedure L3 Craft F
Sonic Pi's :tb303 synth emulates the Roland TB-303 with a dedicated cutoff envelope and resonance
Concept L3 Craft FB
Sonic Pi _slide: opts cause synth parameters to glide smoothly between values over time
Procedure L3 Craft F
spread() generates a Euclidean boolean ring for rhythmic hit placement in Sonic Pi
Procedure L2 First instrument FA
live_audio creates a persistent named audio input stream that can be moved between FX contexts dynamically
Procedure L3 Craft F
set_mixer_control! applies global LPF, HPF, and amplitude adjustments to all Sonic Pi output
Procedure L4 Performance FD
The :sound_out FX routes audio to both its outer FX context and a specific hardware output channel
Procedure L4 Performance FN
Logic/MPC and FL Studio/Cubase use opposite swing scales — 0% in FL Studio equals 50% in Logic
Misconception L2 First instrument FN
The 808's 8-bar pattern constraint pushed producers to think in repeating loops rather than linear song structures
Concept L2 First instrument FA