From bea25a28cbabc4c33de06bf0e095bfd39daab62f Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 5 Apr 2024 12:21:45 +0200 Subject: [PATCH] add superdough warning when scheduling in the past --- packages/superdough/superdough.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index f899052f..e354cb7d 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -273,6 +273,12 @@ export const superdough = async (value, t, hapDuration) => { value.duration = hapDuration; // calculate absolute time t = typeof t === 'string' && t.startsWith('=') ? Number(t.slice(1)) : ac.currentTime + t; + if (t < ac.currentTime) { + console.log( + `[superdough]: cannot schedule sounds in the past (target: ${t.toFixed(2)}, now: ${ac.currentTime.toFixed(2)})`, + ); + return; + } // destructure let { s = 'triangle',