onceEnded mechanism to clean audioNode.onended callbacks
This commit is contained in:
parent
af7855402f
commit
0ec9826de5
4 changed files with 45 additions and 26 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
getADSRValues,
|
||||
getPitchEnvelope,
|
||||
getVibratoOscillator,
|
||||
onceEnded,
|
||||
} from '@strudel/webaudio';
|
||||
import gm from './gm.mjs';
|
||||
|
||||
|
|
@ -170,12 +171,12 @@ export function registerSoundfonts() {
|
|||
|
||||
bufferSource.stop(envEnd);
|
||||
const stop = (releaseTime) => {};
|
||||
bufferSource.onended = () => {
|
||||
onceEnded(bufferSource, () => {
|
||||
bufferSource.disconnect();
|
||||
vibratoOscillator?.stop();
|
||||
node.disconnect();
|
||||
onended();
|
||||
};
|
||||
});
|
||||
return { node, stop };
|
||||
},
|
||||
{ type: 'soundfont', prebake: true, fonts },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue