diff --git a/app/static/js/services/nativeBridgeService.js b/app/static/js/services/nativeBridgeService.js index b7189b6..092887e 100644 --- a/app/static/js/services/nativeBridgeService.js +++ b/app/static/js/services/nativeBridgeService.js @@ -124,8 +124,8 @@ * data2/data3 (A12): CC value / program / PB LSB|MSB. */ dispatchMidiEvent: function (cmd, channel, pitch, velocity, sampleOffset, data2, data3, live) { - _pushEnter = (_pushEnter || 0) + 1; - if (_pushEnter % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_ENTER cmd=' + cmd + ' ch=' + channel + ' tauri=' + !!this._tauri()); + this._pushEnter = (this._pushEnter || 0) + 1; + if (this._pushEnter % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_ENTER cmd=' + cmd + ' ch=' + channel + ' tauri=' + !!this._tauri()); if (!this._tauri()) return false; var safeVelocity = Math.floor(Math.min(1.0, Math.max(0.0, velocity)) * 127); var byteCmd; @@ -135,8 +135,8 @@ case 'PITCH_BEND': byteCmd = 0xE; break; default: byteCmd = cmd === 'NOTE_ON' ? 0x9 : 0x8; break; } - _pushSent = (_pushSent || 0) + 1; - if (_pushSent % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_SENT ' + _pushSent); + this._pushSent = (this._pushSent || 0) + 1; + if (this.pushSent % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_SENT ' + _pushSent); // DIAG: Promise.race 800ms — invoke gửi đi nhưng không settle -> timeout // (phan biet main-thread block vs Rust hang). Promise.race([ @@ -152,10 +152,10 @@ }), new Promise(function (_, rej) { setTimeout(function () { rej(new Error('timeout-800ms')); }, 800); }) ]).then(function () { - _pushOk = (_pushOk || 0) + 1; + this._pushOk = (this._pushOk || 0) + 1; if ((_pushOk + (_pushFail || 0)) % 100 === 0 && window.__sfDiag) window.__sfDiag('PUSH_MIDI ok=' + _pushOk + ' fail=' + (_pushFail || 0)); }).catch(function (e) { - _pushFail = (_pushFail || 0) + 1; + this._pushFail = (this._pushFail || 0) + 1; if (_lastPushFail !== String(e)) { _lastPushFail = String(e); if (window.__sfDiag) window.__sfDiag('PUSH_MIDI_FAIL ' + e); } console.warn('[BridgeService] push_midi_event:', e); }); diff --git a/app/templates/index.html b/app/templates/index.html index c9628be..4487c07 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -39,7 +39,7 @@ - +