home/ atoms/ sonicpi-control-needs-handle

To modulate a running Sonic Pi effect or synth you must capture its block-argument handle and call control on it

Sonic Pi cannot change a running fx or synth parameter unless it holds a reference to that node. with_fx and play yield a handle you capture as a block argument, then pass to control to change parameters live: with_fx :lpf do |fx|; control fx, cutoff: 120; end. Without capturing the handle there is nothing to control. Pair control with a *_slide option to glide rather than jump: setting cutoff_slide: 2 before a control call makes the subsequent cutoff change ramp over 2 beats instead of stepping instantly.

Examples

with_fx :lpf, cutoff: 60, cutoff_slide: 4 do |fx|\n control fx, cutoff: 120\n play 60\nend — cutoff glides from 60 to 120 over 4 beats.

Assessment

Write a Sonic Pi with_fx block that captures the effect handle and slides a low-pass cutoff upward over 2 beats, and explain the role of the _slide option.

“**`control` needs the fx/synth handle.** `with_fx :lpf do |fx| … control fx, cutoff: 120 end` — capture the block arg. `*_slide` opts (`cutoff_slide:`) set the glide time for a subsequent `control`.”
context/ · L1-instruments/sonicpi/gotchas.md · chunk 1