From e7f606dd7d5649096a71c995ce4eb82936c150c8 Mon Sep 17 00:00:00 2001 From: Christoph Guttandin Date: Thu, 29 Aug 2024 17:55:07 +0200 Subject: [PATCH] Support sending deferred messages --- residentSynth/residentSynth.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/residentSynth/residentSynth.js b/residentSynth/residentSynth.js index be97e24..92eda53 100644 --- a/residentSynth/residentSynth.js +++ b/residentSynth/residentSynth.js @@ -1734,9 +1734,16 @@ ResSynth.residentSynth = (function(window) }; // WebMIDIAPI ยง6.4 MIDIOutput interface - // This synth does not support timestamps (05.11.2015) - ResidentSynth.prototype.send = function(messageData, ignoredTimestamp) + ResidentSynth.prototype.send = function(messageData, timestamp = 0) { + const timeout = timestamp - performance.now(); + + if (timeout > 0) { + setTimeout(() => this.send(messageData), timeout); + + return; + } + var command = messageData[0] & 0xF0, channel = messageData[0] & 0xF,