tidalcycles / strudel

Web-based environment for live coding algorithmic patterns, incorporating a faithful port of TidalCycles to JavaScript
https://strudel.cc/
GNU Affero General Public License v3.0
579 stars 105 forks source link

"wet" / "applyBy" function #1100

Open felixroos opened 1 month ago

felixroos commented 1 month ago

mixes in a modified version of the pattern in dry/wet fashion

let wetfade = (d) => (d < 0.5 ? 1 : 1 - (d - 0.5) / 0.5);

let wet = register('wet', (wetAmount, fn, pat) => pat.layer(
  x=>x.gain(wetfade(wetAmount)),
  x=>x.gain(wetfade(1-wetAmount)).apply(fn),
))

s("hh*8").wet("<0 .25 .5 .75 1>", set(speed(.5)))

https://strudel.cc/?jxkluxieHw21

could be further optimized by returning silence in one branch for wetAmount 0 and 1

edit: maybe applyBy would also be a good name