From acf339ad1364e206d43c81c7643bd42e1ba0c732 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 17 Sep 2022 15:18:16 +0200 Subject: [PATCH] load worklets on startup --- packages/webaudio/webaudio.mjs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/webaudio/webaudio.mjs b/packages/webaudio/webaudio.mjs index 40d0f73f..bcba7ef0 100644 --- a/packages/webaudio/webaudio.mjs +++ b/packages/webaudio/webaudio.mjs @@ -147,12 +147,13 @@ function getWorklet(ac, processor, params) { return node; } +try { + loadWorklets(); +} catch (err) { + console.warn('could not load AudioWorklet effects coarse, crush and shape', err); +} + Pattern.prototype.out = function () { - try { - loadWorklets(); - } catch (err) { - console.warn('could not load AudioWorklet effects coarse, crush and shape', err); - } return this.onTrigger(async (t, hap, ct, cps) => { const hapDuration = hap.duration / cps; try { @@ -305,7 +306,7 @@ Pattern.prototype.out = function () { // connect chain elements together chain.slice(1).reduce((last, current) => last.connect(current), chain[0]); // disconnect all nodes when hap is over to make sure they are garbage collected -/* setTimeout(() => { + /* setTimeout(() => { chain.forEach((n) => n.disconnect()); }, (hapDuration + release + 0.1) * 1000); */ } catch (e) {