Difuse the onceEnded mechanism
This commit is contained in:
parent
e01621d0cc
commit
46291bf85c
3 changed files with 11 additions and 10 deletions
|
|
@ -324,10 +324,10 @@ export function getVibratoOscillator(param, value, t) {
|
|||
gain.gain.value = vibmod * 100;
|
||||
vibratoOscillator.connect(gain);
|
||||
gain.connect(param);
|
||||
vibratoOscillator.onended = () => {
|
||||
onceEnded(vibratoOscillator, () => {
|
||||
gain.disconnect(param);
|
||||
vibratoOscillator.disconnect(gain);
|
||||
};
|
||||
});
|
||||
vibratoOscillator.start(t);
|
||||
return vibratoOscillator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { drywet } from './helpers.mjs';
|
||||
import { drywet, onceEnded } from './helpers.mjs';
|
||||
import { getAudioContext } from './audioContext.mjs';
|
||||
|
||||
let noiseCache = {};
|
||||
|
|
@ -65,7 +65,7 @@ export function getNoiseOscillator(type = 'white', t, density = 0.02) {
|
|||
export function getNoiseMix(inputNode, wet, t) {
|
||||
const noiseOscillator = getNoiseOscillator('pink', t);
|
||||
const noiseMix = drywet(inputNode, noiseOscillator.node, wet);
|
||||
noiseOscillator.node.onended = () => noiseMix.onended();
|
||||
onceEnded(noiseOscillator.node, () => noiseMix.onended());
|
||||
return {
|
||||
node: noiseMix.node,
|
||||
stop: (time) => noiseOscillator?.stop(time),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { clamp } from './util.mjs';
|
||||
import { registerSound, soundMap } from './superdough.mjs';
|
||||
import { onceEnded } from './helpers.mjs';
|
||||
import { getAudioContext } from './audioContext.mjs';
|
||||
import {
|
||||
applyFM,
|
||||
|
|
@ -110,7 +111,7 @@ export function registerSynthSounds() {
|
|||
|
||||
const mix = gainNode(mixGain);
|
||||
|
||||
o.onended = () => {
|
||||
onceEnded(o, () => {
|
||||
o.disconnect();
|
||||
g.disconnect();
|
||||
sat.disconnect();
|
||||
|
|
@ -118,7 +119,7 @@ export function registerSynthSounds() {
|
|||
noiseGain.disconnect();
|
||||
mix.disconnect();
|
||||
onended();
|
||||
};
|
||||
});
|
||||
|
||||
const node = o.connect(sat).connect(g).connect(mix);
|
||||
noise.node.connect(noiseGain).connect(mix);
|
||||
|
|
@ -384,11 +385,11 @@ export function registerSynthSounds() {
|
|||
|
||||
const { duration } = value;
|
||||
|
||||
o.onended = () => {
|
||||
onceEnded(o, () => {
|
||||
o.disconnect();
|
||||
g.disconnect();
|
||||
onended();
|
||||
};
|
||||
});
|
||||
|
||||
const envGain = gainNode(1);
|
||||
let node = o.connect(g).connect(envGain);
|
||||
|
|
@ -489,11 +490,11 @@ export function getOscillator(s, t, value, onended) {
|
|||
noiseMix = getNoiseMix(o, noise, t);
|
||||
}
|
||||
|
||||
o.onended = () => {
|
||||
onceEnded(o, () => {
|
||||
noiseMix || o.disconnect();
|
||||
noiseMix?.node.disconnect();
|
||||
onended();
|
||||
};
|
||||
});
|
||||
o.start(t);
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue