add cleanup to sound tab
This commit is contained in:
parent
be6b011204
commit
41d82eaadf
1 changed files with 4 additions and 1 deletions
|
|
@ -258,7 +258,10 @@ function SoundsTab() {
|
|||
className="cursor-pointer hover:opacity-50"
|
||||
onMouseDown={async () => {
|
||||
const ctx = getAudioContext();
|
||||
trigRef.current = Promise.resolve(onTrigger(ctx.currentTime + 0.05, { freq: 220, s: name, clip: 1 }));
|
||||
const params = { freq: 220, s: name, clip: 1, release: 0.5 };
|
||||
const time = ctx.currentTime + 0.05;
|
||||
const onended = () => trigRef.current?.node?.disconnect();
|
||||
trigRef.current = Promise.resolve(onTrigger(time, params, onended));
|
||||
trigRef.current.then((ref) => {
|
||||
ref?.node.connect(ctx.destination);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue