Difuse the onceEnded mechanism

This commit is contained in:
jeromew 2025-12-04 13:17:20 +00:00
parent e01621d0cc
commit 46291bf85c
3 changed files with 11 additions and 10 deletions

View file

@ -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),