Pass a timestamp as the second argument to midiOutput.send(data, timestamp), calculated with performance.now. Something like midiOutput.send(data, performance.now() + offset)
0: https://developer.mozilla.org/en-US/docs/Web/API/MIDIOutput/...
1: https://developer.mozilla.org/en-US/docs/Web/API/Performance...