From 816bb985e927201b38c7ed43f504bca8c37869eb Mon Sep 17 00:00:00 2001 From: Garrett Grimm Date: Wed, 7 Dec 2022 23:33:13 -0800 Subject: [PATCH] 2.1.4 --- .github/workflows/release-package.yml | 33 ----------------- browser/midiwriter.js | 27 ++++++++++---- docs/ControllerChangeEvent.html | 2 +- docs/CopyrightEvent.html | 2 +- docs/CuePointEvent.html | 2 +- docs/EndTrackEvent.html | 2 +- docs/HeaderChunk.html | 2 +- docs/InstrumentNameEvent.html | 2 +- docs/KeySignatureEvent.html | 2 +- docs/LyricEvent.html | 2 +- docs/MarkerEvent.html | 2 +- docs/NoteEvent.html | 2 +- docs/NoteOffEvent.html | 2 +- docs/NoteOnEvent.html | 2 +- docs/ProgramChangeEvent.html | 2 +- docs/TempoEvent.html | 2 +- docs/TextEvent.html | 2 +- docs/TimeSignatureEvent.html | 2 +- docs/Track.html | 36 +++++++++---------- docs/TrackNameEvent.html | 2 +- docs/Utils.html | 2 +- docs/Writer.html | 2 +- docs/constants.js.html | 4 +-- docs/global.html | 2 +- docs/header-chunk.js.html | 2 +- docs/index.html | 6 ++-- ...eta-events_controller-change-event.js.html | 2 +- docs/meta-events_copyright-event.js.html | 2 +- docs/meta-events_cue-point-event.js.html | 2 +- docs/meta-events_end-track-event.js.html | 2 +- .../meta-events_instrument-name-event.js.html | 2 +- docs/meta-events_key-signature-event.js.html | 2 +- docs/meta-events_lyric-event.js.html | 2 +- docs/meta-events_marker-event.js.html | 2 +- docs/meta-events_pitch-bend-event.js.html | 2 +- docs/meta-events_program-change-event.js.html | 2 +- docs/meta-events_tempo-event.js.html | 2 +- docs/meta-events_text-event.js.html | 2 +- docs/meta-events_time-signature-event.js.html | 2 +- docs/meta-events_track-name-event.js.html | 2 +- docs/note-events_note-event.js.html | 2 +- docs/note-events_note-off-event.js.html | 2 +- docs/note-events_note-on-event.js.html | 2 +- docs/track.js.html | 23 +++++++++--- docs/utils.js.html | 2 +- docs/vexflow.js.html | 2 +- docs/writer.js.html | 2 +- package.json | 2 +- src/constants.js | 2 +- 49 files changed, 105 insertions(+), 110 deletions(-) delete mode 100644 .github/workflows/release-package.yml diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml deleted file mode 100644 index 7faaccd..0000000 --- a/.github/workflows/release-package.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: midi-writer-js - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm ci - - run: npm test - - publish-gpr: - needs: build - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - registry-url: https://npm.pkg.github.com/ - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/browser/midiwriter.js b/browser/midiwriter.js index 2d1226d..e08dedb 100644 --- a/browser/midiwriter.js +++ b/browser/midiwriter.js @@ -6,7 +6,7 @@ var MidiWriter = (function () { * @return {Constants} */ var Constants = { - VERSION: '2.1.3', + VERSION: '2.1.4', HEADER_CHUNK_TYPE: [0x4d, 0x54, 0x68, 0x64], // Mthd HEADER_CHUNK_LENGTH: [0x00, 0x00, 0x00, 0x06], @@ -1283,6 +1283,12 @@ var MidiWriter = (function () { return _this.events.push(e); }); } + } else if (event instanceof EndTrackEvent) { + // Only one EndTrackEvent is allowed, so remove + // any existing ones before adding. + _this.removeEventsByType('end-track'); + + _this.events.push(event); } else { _this.events.push(event); } @@ -1301,9 +1307,12 @@ var MidiWriter = (function () { var _this2 = this; var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - // Remove existing end track event and add one. - // This makes sure it's at the very end of the event list. - this.removeEventsByType('end-track').addEvent(new EndTrackEvent()); // Reset + + // If the last event isn't EndTrackEvent, then tack it onto the data. + if (!this.events.length || !(this.events[this.events.length - 1] instanceof EndTrackEvent)) { + this.addEvent(new EndTrackEvent()); + } // Reset + this.data = []; this.size = []; @@ -1384,8 +1393,14 @@ var MidiWriter = (function () { }, { key: "mergeSingleEvent", value: function mergeSingleEvent(event) { - // Find index of existing event we need to follow with - var lastEventIndex = 0; + // There are no events yet, so just add it in. + if (!this.events.length) { + this.addEvent(event); + return; + } // Find index of existing event we need to follow with + + + var lastEventIndex; for (var i = 0; i < this.events.length; i++) { if (this.events[i].tick > event.tick) break; diff --git a/docs/ControllerChangeEvent.html b/docs/ControllerChangeEvent.html index 6f4a378..86dbfb0 100644 --- a/docs/ControllerChangeEvent.html +++ b/docs/ControllerChangeEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/CopyrightEvent.html b/docs/CopyrightEvent.html index c5e4156..90fc873 100644 --- a/docs/CopyrightEvent.html +++ b/docs/CopyrightEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/CuePointEvent.html b/docs/CuePointEvent.html index 9650057..792361f 100644 --- a/docs/CuePointEvent.html +++ b/docs/CuePointEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/EndTrackEvent.html b/docs/EndTrackEvent.html index 61d9699..487cb36 100644 --- a/docs/EndTrackEvent.html +++ b/docs/EndTrackEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/HeaderChunk.html b/docs/HeaderChunk.html index 93cc121..1039823 100644 --- a/docs/HeaderChunk.html +++ b/docs/HeaderChunk.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/InstrumentNameEvent.html b/docs/InstrumentNameEvent.html index 48d0fa2..dafe867 100644 --- a/docs/InstrumentNameEvent.html +++ b/docs/InstrumentNameEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/KeySignatureEvent.html b/docs/KeySignatureEvent.html index d353396..6892e82 100644 --- a/docs/KeySignatureEvent.html +++ b/docs/KeySignatureEvent.html @@ -186,7 +186,7 @@
Returns:

diff --git a/docs/LyricEvent.html b/docs/LyricEvent.html index e98a8f3..ddd3af2 100644 --- a/docs/LyricEvent.html +++ b/docs/LyricEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/MarkerEvent.html b/docs/MarkerEvent.html index c88d33e..8f09340 100644 --- a/docs/MarkerEvent.html +++ b/docs/MarkerEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/NoteEvent.html b/docs/NoteEvent.html index a81073f..74d726f 100644 --- a/docs/NoteEvent.html +++ b/docs/NoteEvent.html @@ -346,7 +346,7 @@
Returns:

diff --git a/docs/NoteOffEvent.html b/docs/NoteOffEvent.html index 4b9837b..b5a286b 100644 --- a/docs/NoteOffEvent.html +++ b/docs/NoteOffEvent.html @@ -504,7 +504,7 @@
Returns:

diff --git a/docs/NoteOnEvent.html b/docs/NoteOnEvent.html index 6c1d1f5..2e4e337 100644 --- a/docs/NoteOnEvent.html +++ b/docs/NoteOnEvent.html @@ -504,7 +504,7 @@
Returns:

diff --git a/docs/ProgramChangeEvent.html b/docs/ProgramChangeEvent.html index a2a7a3d..21dfeb5 100644 --- a/docs/ProgramChangeEvent.html +++ b/docs/ProgramChangeEvent.html @@ -348,7 +348,7 @@
Returns:

diff --git a/docs/TempoEvent.html b/docs/TempoEvent.html index 41b9c2f..1dd986d 100644 --- a/docs/TempoEvent.html +++ b/docs/TempoEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/TextEvent.html b/docs/TextEvent.html index c48fcb1..d1c39e9 100644 --- a/docs/TextEvent.html +++ b/docs/TextEvent.html @@ -238,7 +238,7 @@
Returns:

diff --git a/docs/TimeSignatureEvent.html b/docs/TimeSignatureEvent.html index ea354ee..7dce06a 100644 --- a/docs/TimeSignatureEvent.html +++ b/docs/TimeSignatureEvent.html @@ -186,7 +186,7 @@
Returns:

diff --git a/docs/Track.html b/docs/Track.html index 8789a7d..b46e48b 100644 --- a/docs/Track.html +++ b/docs/Track.html @@ -273,7 +273,7 @@

addCopyri
Source:
@@ -429,7 +429,7 @@

addCuePoin
Source:
@@ -772,7 +772,7 @@

addI
Source:
@@ -928,7 +928,7 @@

addLyricSource:
@@ -1084,7 +1084,7 @@

addMarkerSource:
@@ -1240,7 +1240,7 @@

addTextSource:
@@ -1396,7 +1396,7 @@

addTrackN
Source:
@@ -1552,7 +1552,7 @@

buildDataSource:
@@ -1708,7 +1708,7 @@

contr
Source:
@@ -1890,7 +1890,7 @@

merge
Source:
@@ -2049,7 +2049,7 @@

mergeTrack<
Source:
@@ -2205,7 +2205,7 @@

polyModeOn<
Source:
@@ -2309,7 +2309,7 @@

rem
Source:
@@ -2465,7 +2465,7 @@

setKey
Source:
@@ -2647,7 +2647,7 @@

setPitchB
Source:
@@ -2803,7 +2803,7 @@

setTempoSource:
@@ -2997,7 +2997,7 @@

setTi
Source:
@@ -3200,7 +3200,7 @@

Returns:

- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/TrackNameEvent.html b/docs/TrackNameEvent.html index b27e590..f008280 100644 --- a/docs/TrackNameEvent.html +++ b/docs/TrackNameEvent.html @@ -238,7 +238,7 @@
Returns:

- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/Utils.html b/docs/Utils.html index 8ef276a..bd2b706 100644 --- a/docs/Utils.html +++ b/docs/Utils.html @@ -2388,7 +2388,7 @@
Returns:

- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/Writer.html b/docs/Writer.html index d8ce307..cd9aa17 100644 --- a/docs/Writer.html +++ b/docs/Writer.html @@ -973,7 +973,7 @@
Returns:

- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/constants.js.html b/docs/constants.js.html index 1e1a1b0..f4901e2 100644 --- a/docs/constants.js.html +++ b/docs/constants.js.html @@ -45,7 +45,7 @@

constants.js

*/ const Constants = { - VERSION : '2.1.3', + VERSION : '2.1.4', HEADER_CHUNK_TYPE : [0x4d, 0x54, 0x68, 0x64], // Mthd HEADER_CHUNK_LENGTH : [0x00, 0x00, 0x00, 0x06], // Header size for SMF HEADER_CHUNK_FORMAT0 : [0x00, 0x00], // Midi Type 0 id @@ -82,7 +82,7 @@

constants.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/global.html b/docs/global.html index 097aa24..f8f72f0 100644 --- a/docs/global.html +++ b/docs/global.html @@ -354,7 +354,7 @@
Returns:

- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/header-chunk.js.html b/docs/header-chunk.js.html index 7fddbf7..48ee545 100644 --- a/docs/header-chunk.js.html +++ b/docs/header-chunk.js.html @@ -75,7 +75,7 @@

header-chunk.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/index.html b/docs/index.html index 12015ed..4be6726 100644 --- a/docs/index.html +++ b/docs/index.html @@ -59,7 +59,7 @@

Install

npm install midi-writer-js
 

Getting Started

-
const MidiWriter = require('midi-writer-js');
+
import MidiWriter from 'midi-writer-js';
 
 // Start with a new track
 const track = new MidiWriter.Track();
@@ -190,7 +190,7 @@ 

MidiWriter.Writer(tracks)

Hot Cross Buns

Here's an example of how everyone's favorite song "Hot Cross Buns" could be written. Note use of the mapping function passed as the second argument of addEvent(). This can be used to apply specific properties to all events. With some street smarts you could also use it for programmatic crescendos and other property 'animation'.

-
const MidiWriter = require('midi-writer-js');
+
import MidiWriter from 'midi-writer-js';
 
 const track = new MidiWriter.Track();
 
@@ -233,7 +233,7 @@ 

VexFlow Integration


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_controller-change-event.js.html b/docs/meta-events_controller-change-event.js.html index 77b7470..9a9f480 100644 --- a/docs/meta-events_controller-change-event.js.html +++ b/docs/meta-events_controller-change-event.js.html @@ -73,7 +73,7 @@

meta-events/controller-change-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_copyright-event.js.html b/docs/meta-events_copyright-event.js.html index 1f9c239..02c5f05 100644 --- a/docs/meta-events_copyright-event.js.html +++ b/docs/meta-events_copyright-event.js.html @@ -81,7 +81,7 @@

meta-events/copyright-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_cue-point-event.js.html b/docs/meta-events_cue-point-event.js.html index a9a3012..bb493bd 100644 --- a/docs/meta-events_cue-point-event.js.html +++ b/docs/meta-events_cue-point-event.js.html @@ -81,7 +81,7 @@

meta-events/cue-point-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_end-track-event.js.html b/docs/meta-events_end-track-event.js.html index 3a8df6a..447b89d 100644 --- a/docs/meta-events_end-track-event.js.html +++ b/docs/meta-events_end-track-event.js.html @@ -77,7 +77,7 @@

meta-events/end-track-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_instrument-name-event.js.html b/docs/meta-events_instrument-name-event.js.html index aa6f3a1..67b82b9 100644 --- a/docs/meta-events_instrument-name-event.js.html +++ b/docs/meta-events_instrument-name-event.js.html @@ -81,7 +81,7 @@

meta-events/instrument-name-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_key-signature-event.js.html b/docs/meta-events_key-signature-event.js.html index a251f3b..69af62a 100644 --- a/docs/meta-events_key-signature-event.js.html +++ b/docs/meta-events_key-signature-event.js.html @@ -117,7 +117,7 @@

meta-events/key-signature-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_lyric-event.js.html b/docs/meta-events_lyric-event.js.html index 69bf897..a52c51b 100644 --- a/docs/meta-events_lyric-event.js.html +++ b/docs/meta-events_lyric-event.js.html @@ -81,7 +81,7 @@

meta-events/lyric-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_marker-event.js.html b/docs/meta-events_marker-event.js.html index a054d7b..e37fbda 100644 --- a/docs/meta-events_marker-event.js.html +++ b/docs/meta-events_marker-event.js.html @@ -81,7 +81,7 @@

meta-events/marker-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_pitch-bend-event.js.html b/docs/meta-events_pitch-bend-event.js.html index 96fdecf..deb7520 100644 --- a/docs/meta-events_pitch-bend-event.js.html +++ b/docs/meta-events_pitch-bend-event.js.html @@ -87,7 +87,7 @@

meta-events/pitch-bend-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_program-change-event.js.html b/docs/meta-events_program-change-event.js.html index 46c3ca8..a5d2dd6 100644 --- a/docs/meta-events_program-change-event.js.html +++ b/docs/meta-events_program-change-event.js.html @@ -82,7 +82,7 @@

meta-events/program-change-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_tempo-event.js.html b/docs/meta-events_tempo-event.js.html index d200803..45062e8 100644 --- a/docs/meta-events_tempo-event.js.html +++ b/docs/meta-events_tempo-event.js.html @@ -83,7 +83,7 @@

meta-events/tempo-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_text-event.js.html b/docs/meta-events_text-event.js.html index 994a852..a1966dc 100644 --- a/docs/meta-events_text-event.js.html +++ b/docs/meta-events_text-event.js.html @@ -81,7 +81,7 @@

meta-events/text-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_time-signature-event.js.html b/docs/meta-events_time-signature-event.js.html index c1bc65e..7dd49da 100644 --- a/docs/meta-events_time-signature-event.js.html +++ b/docs/meta-events_time-signature-event.js.html @@ -76,7 +76,7 @@

meta-events/time-signature-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/meta-events_track-name-event.js.html b/docs/meta-events_track-name-event.js.html index f48ddf1..bfab2f0 100644 --- a/docs/meta-events_track-name-event.js.html +++ b/docs/meta-events_track-name-event.js.html @@ -81,7 +81,7 @@

meta-events/track-name-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/note-events_note-event.js.html b/docs/note-events_note-event.js.html index de5ecec..9a0cf50 100644 --- a/docs/note-events_note-event.js.html +++ b/docs/note-events_note-event.js.html @@ -204,7 +204,7 @@

note-events/note-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/note-events_note-off-event.js.html b/docs/note-events_note-off-event.js.html index 01c94e4..928a406 100644 --- a/docs/note-events_note-off-event.js.html +++ b/docs/note-events_note-off-event.js.html @@ -110,7 +110,7 @@

note-events/note-off-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/note-events_note-on-event.js.html b/docs/note-events_note-on-event.js.html index 122eeba..114d8e8 100644 --- a/docs/note-events_note-on-event.js.html +++ b/docs/note-events_note-on-event.js.html @@ -124,7 +124,7 @@

note-events/note-on-event.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/track.js.html b/docs/track.js.html index c7494f5..582a743 100644 --- a/docs/track.js.html +++ b/docs/track.js.html @@ -120,6 +120,12 @@

track.js

event.buildData().events.forEach((e) => this.events.push(e)); } + } else if (event instanceof EndTrackEvent) { + // Only one EndTrackEvent is allowed, so remove + // any existing ones before adding. + this.removeEventsByType('end-track'); + this.events.push(event); + } else { this.events.push(event); } @@ -134,9 +140,10 @@

track.js

* @return {Track} */ buildData(options = {}) { - // Remove existing end track event and add one. - // This makes sure it's at the very end of the event list. - this.removeEventsByType('end-track').addEvent(new EndTrackEvent()); + // If the last event isn't EndTrackEvent, then tack it onto the data. + if (!this.events.length || !(this.events[this.events.length - 1] instanceof EndTrackEvent)) { + this.addEvent(new EndTrackEvent()); + } // Reset this.data = []; @@ -211,8 +218,14 @@

track.js

* @return {Track} */ mergeSingleEvent(event) { + // There are no events yet, so just add it in. + if (!this.events.length) { + this.addEvent(event); + return; + } + // Find index of existing event we need to follow with - var lastEventIndex = 0; + let lastEventIndex; for (let i = 0; i < this.events.length; i++) { if (this.events[i].tick > event.tick) break; @@ -390,7 +403,7 @@

track.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/utils.js.html b/docs/utils.js.html index 40284b6..c850220 100644 --- a/docs/utils.js.html +++ b/docs/utils.js.html @@ -311,7 +311,7 @@

utils.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/vexflow.js.html b/docs/vexflow.js.html index d3f0a8e..dbe3da6 100644 --- a/docs/vexflow.js.html +++ b/docs/vexflow.js.html @@ -147,7 +147,7 @@

vexflow.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/docs/writer.js.html b/docs/writer.js.html index 867272a..444ac45 100644 --- a/docs/writer.js.html +++ b/docs/writer.js.html @@ -135,7 +135,7 @@

writer.js


- Generated by JSDoc 3.6.10 on Sat Dec 03 2022 13:51:57 GMT-0800 (Pacific Standard Time) using the Minami theme. + Generated by JSDoc 3.6.10 on Wed Dec 07 2022 23:32:46 GMT-0800 (Pacific Standard Time) using the Minami theme.
diff --git a/package.json b/package.json index 667a81b..783d570 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "midi-writer-js", - "version": "2.1.3", + "version": "2.1.4", "description": "A library providing an API for generating MIDI files.", "main": "build/index.js", "types": "types.d.ts", diff --git a/src/constants.js b/src/constants.js index 80ce49c..46d8e42 100644 --- a/src/constants.js +++ b/src/constants.js @@ -4,7 +4,7 @@ */ const Constants = { - VERSION : '2.1.3', + VERSION : '2.1.4', HEADER_CHUNK_TYPE : [0x4d, 0x54, 0x68, 0x64], // Mthd HEADER_CHUNK_LENGTH : [0x00, 0x00, 0x00, 0x06], // Header size for SMF HEADER_CHUNK_FORMAT0 : [0x00, 0x00], // Midi Type 0 id