home/ atoms/ strudel-thunk-vs-signal

Strudel takes patterns/signals as arguments (not thunks like Hydra) — .lpf(sine.range(200,2000)) is correct; .lpf(() => ...) is a cross-DSL mistake

Hydra and Strudel have different conventions for reactive parameter passing. In Hydra, a parameter that depends on audio or time must be wrapped in a thunk (arrow function): () => a.fft[0]. In Strudel, parameters accept pattern objects and signal expressions directly: .lpf(sine.range(200,2000)). Passing a thunk to a Strudel method will not work as expected and may silently produce unexpected behavior. Programmers who work across both DSLs frequently cross this convention. The fix is always to pass a Strudel signal or pattern, not a JavaScript function.

Examples

Correct: .lpf(sine.range(200,2000).slow(4)). Wrong (Hydra style): .lpf(() => 200 + a.fft[0] * 1800).

Assessment

Explain why .gain(() => 0.5 + a.fft[0] * 0.5) may not behave correctly in Strudel, and rewrite it using a Strudel signal expression.

“In *Strudel* you pass **patterns/signals**, not thunks — `.lpf(sine.range(200,2000))`, not `.lpf(() => …)`. Don't cross the two DSLs' conventions.”
context/ · L1-instruments/strudel/gotchas.md · chunk 1