From f98e53d78bf700b398ea4ed2c5f49f890d5b49a1 Mon Sep 17 00:00:00 2001 From: Patrick Dillon Date: Sat, 18 Nov 2023 13:28:48 -0500 Subject: [PATCH] Emit velocity as a raw value for all events --- browser/midiplayer.js | 25 +++++++++++-------------- src/track.js | 4 ++-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/browser/midiplayer.js b/browser/midiplayer.js index b74e26e..9b52fc3 100644 --- a/browser/midiplayer.js +++ b/browser/midiplayer.js @@ -4,17 +4,11 @@ var MidiPlayer = (function () { function _typeof(obj) { "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); } function _classCallCheck(instance, Constructor) { @@ -36,6 +30,9 @@ var MidiPlayer = (function () { function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); return Constructor; } @@ -604,7 +601,7 @@ var MidiPlayer = (function () { eventJson.channel = this.lastStatus - 0x80 + 1; eventJson.noteNumber = this.data[eventStartIndex + 1]; eventJson.noteName = Constants.NOTES[this.data[eventStartIndex + 1]]; - eventJson.velocity = Math.round(this.data[eventStartIndex + 2] / 127 * 100); + eventJson.velocity = this.data[eventStartIndex + 2]; this.pointer += deltaByteCount + 3; } else if (this.data[eventStartIndex] <= 0x9f) { // Note on @@ -612,7 +609,7 @@ var MidiPlayer = (function () { eventJson.channel = this.lastStatus - 0x90 + 1; eventJson.noteNumber = this.data[eventStartIndex + 1]; eventJson.noteName = Constants.NOTES[this.data[eventStartIndex + 1]]; - eventJson.velocity = Math.round(this.data[eventStartIndex + 2] / 127 * 100); + eventJson.velocity = this.data[eventStartIndex + 2]; this.pointer += deltaByteCount + 3; } else if (this.data[eventStartIndex] <= 0xaf) { // Polyphonic Key Pressure @@ -1289,4 +1286,4 @@ var MidiPlayer = (function () { return index; -}()); +})(); diff --git a/src/track.js b/src/track.js index cb49090..92e8cc8 100644 --- a/src/track.js +++ b/src/track.js @@ -351,7 +351,7 @@ class Track { eventJson.channel = this.lastStatus - 0x80 + 1; eventJson.noteNumber = this.data[eventStartIndex + 1]; eventJson.noteName = Constants.NOTES[this.data[eventStartIndex + 1]]; - eventJson.velocity = Math.round(this.data[eventStartIndex + 2] / 127 * 100); + eventJson.velocity = this.data[eventStartIndex + 2]; this.pointer += deltaByteCount + 3; } else if (this.data[eventStartIndex] <= 0x9f) { @@ -360,7 +360,7 @@ class Track { eventJson.channel = this.lastStatus - 0x90 + 1; eventJson.noteNumber = this.data[eventStartIndex + 1]; eventJson.noteName = Constants.NOTES[this.data[eventStartIndex + 1]]; - eventJson.velocity = Math.round(this.data[eventStartIndex + 2] / 127 * 100); + eventJson.velocity = this.data[eventStartIndex + 2]; this.pointer += deltaByteCount + 3; } else if (this.data[eventStartIndex] <= 0xaf) {