Merge pull request #521 from tidalcycles/fix-envelope

fix: envelopes in chrome
This commit is contained in:
Felix Roos 2023-03-17 09:03:10 +01:00 committed by GitHub
commit e02be7dd9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View File

@ -27,12 +27,13 @@ export const getEnvelope = (attack, decay, sustain, release, velocity, begin) =>
return {
node: gainNode,
stop: (t) => {
if (typeof gainNode.gain.cancelAndHoldAtTime === 'function') {
gainNode.gain.cancelAndHoldAtTime(t);
} else {
// firefox: this will glitch when the sustain has not been reached yet at the time of release
gainNode.gain.setValueAtTime(sustain * velocity, t);
}
//if (typeof gainNode.gain.cancelAndHoldAtTime === 'function') {
// gainNode.gain.cancelAndHoldAtTime(t); // this seems to release instantly....
// see https://discord.com/channels/779427371270275082/937365093082079272/1086053607360712735
//} else {
// firefox: this will glitch when the sustain has not been reached yet at the time of release
gainNode.gain.setValueAtTime(sustain * velocity, t);
//}
gainNode.gain.linearRampToValueAtTime(0, t + release);
},
};

View File

@ -32,9 +32,9 @@ export function registerSynthSounds() {
};
return {
node: o.connect(g).connect(envelope),
stop: (t) => {
releaseEnvelope(t);
stop(t + release);
stop: (releaseTime) => {
releaseEnvelope(releaseTime);
stop(releaseTime + release);
},
};
},