duckarray
This commit is contained in:
parent
26225e4ea7
commit
51f0bab1f8
2 changed files with 14 additions and 10 deletions
|
|
@ -535,7 +535,7 @@ export const { tremoloshape } = registerControl('tremoloshape', 'tremshape');
|
||||||
* stack( n(run(8)).scale("c:minor").s("sawtooth").delay(.7).orbit(2), s("bd:4!4").beat("0,4,8,11,14",16).duckorbit(2).duckattack(0.2).duckdepth(1))
|
* stack( n(run(8)).scale("c:minor").s("sawtooth").delay(.7).orbit(2), s("bd:4!4").beat("0,4,8,11,14",16).duckorbit(2).duckattack(0.2).duckdepth(1))
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export const { duck } = registerControl(['duckorbit', 'duckattack', 'duckdepth'], 'duck');
|
export const { duck } = registerControl('duckorbit', 'duck');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the amount of ducking applied to target orbit
|
* the amount of ducking applied to target orbit
|
||||||
|
|
|
||||||
|
|
@ -419,16 +419,20 @@ function setOrbit(audioContext, orbit, channels) {
|
||||||
connectToDestination(orbits[orbit].gain, channels);
|
connectToDestination(orbits[orbit].gain, channels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function duckOrbit(target, t, attacktime = 0.1, duckdepth = 1) {
|
function duckOrbit(targetOrbit, t, attacktime = 0.1, duckdepth = 1) {
|
||||||
if (orbits[target] == null) {
|
const targetArr = [targetOrbit].flat();
|
||||||
errorLogger(new Error('duck target orbit does not exist'), 'superdough');
|
|
||||||
}
|
|
||||||
|
|
||||||
orbits[target].gain.gain.cancelAndHoldAtTime(t);
|
targetArr.forEach((target) => {
|
||||||
const currVal = orbits[target].gain.gain.value;
|
if (orbits[target] == null) {
|
||||||
orbits[target].gain.gain.setValueAtTime(currVal, t);
|
errorLogger(new Error(`duck target orbit ${target} does not exist`), 'superdough');
|
||||||
orbits[target].gain.gain.linearRampToValueAtTime(clamp(1 - duckdepth, 0.01, currVal), t + 0.002);
|
return;
|
||||||
orbits[target].gain.gain.exponentialRampToValueAtTime(1, t + Math.max(0.002, attacktime));
|
}
|
||||||
|
orbits[target].gain.gain.cancelAndHoldAtTime(t);
|
||||||
|
const currVal = orbits[target].gain.gain.value;
|
||||||
|
orbits[target].gain.gain.setValueAtTime(currVal, t);
|
||||||
|
orbits[target].gain.gain.linearRampToValueAtTime(clamp(1 - Math.pow(duckdepth, 0.5), 0.01, currVal), t + 0.002);
|
||||||
|
orbits[target].gain.gain.exponentialRampToValueAtTime(1, t + Math.max(0.002, attacktime));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let hasChanged = (now, before) => now !== undefined && now !== before;
|
let hasChanged = (now, before) => now !== undefined && now !== before;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue