Fix release behavior; add multi-line example

This commit is contained in:
Aria 2026-01-08 16:39:10 -06:00
parent d4b3a3b972
commit e6e96c8603
3 changed files with 143 additions and 8 deletions

View file

@ -3795,7 +3795,21 @@ const _asArrayPattern = (pats) => {
* .add(x => x.delay(.13).mul(0.7))
* .out()
* )
* ._pianoroll()
*
* @example
* n("<0 1 <2 3 2 4>>*16")
* .scale("G#2:minor").sometimes(x => x.transpose("12 | 24"))
* .K(() => {
* const att = S(rand.range(0, 0.05))
* const dec = S(rand.range(0.05, 0.2))
* let f = n(sFreq);
* const mod = sine(f).mul("0.1 | 0.2 | 0.3")
* .add("[[1.5 1] | 1 | 2 | 4 | [6 4@3]]*2")
* saw(f.mul(mod))
* .mul(sGate.ad(att, dec))
* .add(x => x.delay(0.4).mul(0.3))
* .out()
* }).fxr(1).room(0.3)
*/
/**
* Creates a worklet effect. Typically derived by writing K(...) in the REPL which will parse

View file

@ -1528,16 +1528,11 @@ class GenericProcessor extends AudioWorkletProcessor {
}
process(inputs, outputs) {
const input = inputs[0]?.[0];
if (currentTime > this.end) {
if (currentTime >= this.end) {
return false;
}
else if (this.genSample === undefined || currentTime < this.start) {
} else if (this.genSample === undefined || currentTime < this.start) {
// pending
return true;
} else if (input === undefined) {
// if no input and started, return false and close worklet
// else just keep waiting (true)
return !this.started;
}
this.started = true;
if (!this.gateEnded && currentTime > this.gateEnd) {