From 63ee218d53aad9ac26f5aaa97f83e111bbbc4084 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 1 Feb 2025 22:54:06 +0100 Subject: [PATCH 1/2] fix: make sure ac is defined --- packages/superdough/superdough.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index b61f4263..f5f485e2 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -314,6 +314,7 @@ export function resetGlobalEffects() { } export const superdough = async (value, t, hapDuration) => { + const ac = getAudioContext(); t = typeof t === 'string' && t.startsWith('=') ? Number(t.slice(1)) : ac.currentTime + t; let { stretch } = value; if (stretch != null) { @@ -321,7 +322,6 @@ export const superdough = async (value, t, hapDuration) => { const latency = 0.04; t = t - latency; } - const ac = getAudioContext(); if (typeof value !== 'object') { throw new Error( `expected hap.value to be an object, but got "${value}". Hint: append .note() or .s() to the end`, From 1bf74024d4e130bc63c34fe6a0464d6e1f3a4029 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 1 Feb 2025 22:54:20 +0100 Subject: [PATCH 2/2] fix: sf2 soundfont timing --- packages/soundfonts/sfumato.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/soundfonts/sfumato.mjs b/packages/soundfonts/sfumato.mjs index 871ee67d..6d60f80d 100644 --- a/packages/soundfonts/sfumato.mjs +++ b/packages/soundfonts/sfumato.mjs @@ -3,11 +3,11 @@ import { getAudioContext, registerSound } from '@strudel/webaudio'; import { loadSoundfont as _loadSoundfont, startPresetNote } from 'sfumato'; Pattern.prototype.soundfont = function (sf, n = 0) { - return this.onTrigger((t, h, ct) => { + return this.onTrigger((time_deprecate, h, ct, cps, targetTime) => { const ctx = getAudioContext(); const note = getPlayableNoteValue(h); const preset = sf.presets[n % sf.presets.length]; - const deadline = ctx.currentTime + t - ct; + const deadline = targetTime; const args = [ctx, preset, noteToMidi(note), deadline]; const stop = startPresetNote(...args); stop(deadline + h.duration);