fix desktop midi

This commit is contained in:
Jade (Rose) Rowland 2024-04-06 17:28:30 -04:00
parent 8e4549d6d3
commit 183d3ea4a1
2 changed files with 5 additions and 3 deletions

View File

@ -6,9 +6,11 @@ const OFF_MESSAGE = 0x80;
const CC_MESSAGE = 0xb0;
Pattern.prototype.midi = function (output) {
return this.onTrigger((time, hap, currentTime, cps) => {
return this.onTrigger((time, hap, currentTime, cps, targetTime) => {
let { note, nrpnn, nrpv, ccn, ccv, velocity = 0.9, gain = 1 } = hap.value;
const offset = (time - currentTime) * 1000;
//magic number to get audio engine to line up, can probably be calculated somehow
const latency = 0.03;
const offset = (targetTime - currentTime + latency) * 1000;
velocity = Math.floor(gain * velocity * 100);
const duration = Math.floor((hap.duration.valueOf() / cps) * 1000 - 10);
const roundedOffset = Math.round(offset);

View File

@ -112,7 +112,7 @@ Pattern.prototype.midi = function (output) {
logger(`Midi device disconnected! Available: ${getMidiDeviceNamesString(outputs)}`),
});
return this.onTrigger((time, hap, currentTime, cps, targetTime) => {
return this.onTrigger((time_deprecate, hap, currentTime, cps, targetTime) => {
if (!WebMidi.enabled) {
console.log('not enabled');
return;