home/ atoms/ sonicpi-with-fx-block-scope

Sonic Pi's with_fx wraps a code block, not a voice; only play/sample calls inside the do…end block are processed through the effect

with_fx in Sonic Pi applies an audio effect to all play and sample calls within its do…end block. Calls outside the block are unaffected (dry). The effect node is rebuilt each time the block executes — re-triggering a with_fx every loop pass is normal and fine for most effects, but for effects with long tails (reverb) it can cause tail truncation; in those cases, wrap the whole live_loop body or use a dedicated fx live_loop that persists. To automate effect parameters, capture the block argument and use control: with_fx :lpf do |fx|; control fx, cutoff: 500; end.

Examples

live_loop :bd do\n with_fx :reverb, room: 0.8 do\n sample :bd_haus\n end\n sleep 1\nend — reverb on kick. A sample played outside the with_fx block receives no reverb.

Assessment

A performer wraps only one sample call inside with_fx :reverb but hears no reverb on their synth voice. Explain why and show how to apply reverb to both the sample and the synth.

“`with_fx` wraps a BLOCK, not a voice.** Only `play`/`sample` calls *inside* the `do…end` are processed.”
context/ · L1-instruments/sonicpi/gotchas.md · chunk 1