From ab001a9110c95d40b9199674d55b06b7607d3069 Mon Sep 17 00:00:00 2001 From: Sema Date: Thu, 30 Nov 2023 00:22:09 -0500 Subject: [PATCH] Minor improvements --- javascript/JZZ.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/javascript/JZZ.js b/javascript/JZZ.js index 30d8aa6..a91fac6 100644 --- a/javascript/JZZ.js +++ b/javascript/JZZ.js @@ -3424,8 +3424,14 @@ JZZ.MIDI2 = UMP; _J.prototype.MIDI2 = UMP; - function _16_7(n) { return n ? (n >> 9) || 1 : 0; } - function _32_7(n) { return n ? ((n >> 25) & 127) || 1 : 0; } + function _16_7(a, b) { + var n = a * 0x100 + b; + return n ? (n >> 9) || 1 : 0; + } + function _32_7(a, b, c, d) { + var n = a * 0x1000000 + b * 0x10000 + c * 0x100 + d; + return n ? ((n >> 25) & 127) || 1 : 0; + } function _grp(m, g) { m.gr = g; return m; } function _m2m1(msg) { if (msg.isMidi2) { @@ -3457,17 +3463,17 @@ n = msg[1] >> 4; c = msg[1] & 15; if (n == 8 || n == 9) { - this._emit(_grp(new MIDI([msg[1], msg[2], _16_7(msg[4] * 256 + msg[5])]), g)); + this._emit(_grp(new MIDI([msg[1], msg[2], _16_7(msg[4], msg[5])]), g)); } if (n == 10) { - this._emit(_grp(new MIDI([msg[1], msg[2], _32_7(msg[4] * 0x1000000 + msg[5] * 0x10000 + msg[6] * 0x100 + msg[7])]), g)); + this._emit(_grp(new MIDI([msg[1], msg[2], _32_7(msg[4], msg[5], msg[6], msg[7])]), g)); } if (n == 11) { if (_noctrl.includes(msg[2])) return; - this._emit(_grp(new MIDI([msg[1], msg[2], _32_7(msg[4] * 0x1000000 + msg[5] * 0x10000 + msg[6] * 0x100 + msg[7])]), g)); + this._emit(_grp(new MIDI([msg[1], msg[2], _32_7(msg[4], msg[5], msg[6], msg[7])]), g)); } if (n == 13) { - this._emit(_grp(new MIDI([msg[1], _32_7(msg[4] * 0x1000000 + msg[5] * 0x10000 + msg[6] * 0x100 + msg[7])]), g)); + this._emit(_grp(new MIDI([msg[1], _32_7(msg[4], msg[5], msg[6], msg[7])]), g)); } else if (n == 12) { if (msg[3]) {