spessasynth_core 4.0.13 → 4.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3280,11 +3280,17 @@ var BasicMIDI2 = class _BasicMIDI {
|
|
|
3280
3280
|
// Cc change: loop points
|
|
3281
3281
|
case midiMessageTypes.controllerChange:
|
|
3282
3282
|
switch (e.data[0]) {
|
|
3283
|
+
// Touhou
|
|
3283
3284
|
case 2:
|
|
3285
|
+
// RPG Maker
|
|
3286
|
+
case 111:
|
|
3287
|
+
// EMIDI/XMI
|
|
3284
3288
|
case 116:
|
|
3285
3289
|
loopStart = e.ticks;
|
|
3286
3290
|
break;
|
|
3291
|
+
// Touhou
|
|
3287
3292
|
case 4:
|
|
3293
|
+
// EMIDI/XMI
|
|
3288
3294
|
case 117:
|
|
3289
3295
|
if (loopEnd === null) {
|
|
3290
3296
|
loopEnd = e.ticks;
|
|
@@ -3425,14 +3431,9 @@ var BasicMIDI2 = class _BasicMIDI {
|
|
|
3425
3431
|
consoleColors.recognized,
|
|
3426
3432
|
consoleColors.info
|
|
3427
3433
|
);
|
|
3428
|
-
|
|
3429
|
-
|
|
3434
|
+
loopStart ??= this.firstNoteOn;
|
|
3435
|
+
if (loopEnd === null || loopEnd === 0) {
|
|
3430
3436
|
loopEnd = this.lastVoiceEventTick;
|
|
3431
|
-
} else {
|
|
3432
|
-
loopStart ??= this.firstNoteOn;
|
|
3433
|
-
if (loopEnd === null || loopEnd === 0) {
|
|
3434
|
-
loopEnd = this.lastVoiceEventTick;
|
|
3435
|
-
}
|
|
3436
3437
|
}
|
|
3437
3438
|
this.loop = { start: loopStart, end: loopEnd };
|
|
3438
3439
|
SpessaSynthInfo(
|
|
@@ -3532,9 +3533,6 @@ var BasicMIDI2 = class _BasicMIDI {
|
|
|
3532
3533
|
);
|
|
3533
3534
|
}
|
|
3534
3535
|
this.duration = this.midiTicksToSeconds(this.lastVoiceEventTick);
|
|
3535
|
-
if (this.duration === 0) {
|
|
3536
|
-
throw new Error("The MIDI file no duration.");
|
|
3537
|
-
}
|
|
3538
3536
|
if (this.binaryName && this.binaryName.length < 1) {
|
|
3539
3537
|
this.binaryName = void 0;
|
|
3540
3538
|
}
|
|
@@ -3909,7 +3907,8 @@ function processTick() {
|
|
|
3909
3907
|
this.setTimeTicks(this._midiData.loop.start);
|
|
3910
3908
|
return;
|
|
3911
3909
|
}
|
|
3912
|
-
if (nextTrack.events.length <= this.eventIndexes[nextTrackIndex]
|
|
3910
|
+
if (nextTrack.events.length <= this.eventIndexes[nextTrackIndex] || // https://github.com/spessasus/spessasynth_core/issues/21
|
|
3911
|
+
event.ticks >= this._midiData.lastVoiceEventTick) {
|
|
3913
3912
|
this.songIsFinished();
|
|
3914
3913
|
return;
|
|
3915
3914
|
}
|
|
@@ -3940,6 +3939,11 @@ function loadNewSequenceInternal(parsedMidi) {
|
|
|
3940
3939
|
if (!parsedMidi.tracks) {
|
|
3941
3940
|
throw new Error("This MIDI has no tracks!");
|
|
3942
3941
|
}
|
|
3942
|
+
if (parsedMidi.duration === 0) {
|
|
3943
|
+
SpessaSynthWarn("This MIDI file has a duration of exactly 0 seconds.");
|
|
3944
|
+
this.pausedTime = 0;
|
|
3945
|
+
return;
|
|
3946
|
+
}
|
|
3943
3947
|
this.oneTickToSeconds = 60 / (120 * parsedMidi.timeDivision);
|
|
3944
3948
|
this._midiData = parsedMidi;
|
|
3945
3949
|
this.synth.clearEmbeddedBank();
|
|
@@ -5099,9 +5103,9 @@ var SpessaSynthSequencer = class {
|
|
|
5099
5103
|
* @param value the playback rate to set.
|
|
5100
5104
|
*/
|
|
5101
5105
|
set playbackRate(value) {
|
|
5102
|
-
const
|
|
5106
|
+
const t = this.currentTime;
|
|
5103
5107
|
this._playbackRate = value;
|
|
5104
|
-
this.
|
|
5108
|
+
this.recalculateStartTime(t);
|
|
5105
5109
|
}
|
|
5106
5110
|
/**
|
|
5107
5111
|
* The current time of the sequencer.
|
|
@@ -5137,11 +5141,6 @@ var SpessaSynthSequencer = class {
|
|
|
5137
5141
|
} else {
|
|
5138
5142
|
this.playingNotes = [];
|
|
5139
5143
|
this.callEvent("timeChange", { newTime: time });
|
|
5140
|
-
if (this._midiData.duration === 0) {
|
|
5141
|
-
SpessaSynthWarn("No duration!");
|
|
5142
|
-
this.callEvent("pause", { isFinished: true });
|
|
5143
|
-
return;
|
|
5144
|
-
}
|
|
5145
5144
|
this.setTimeTo(time);
|
|
5146
5145
|
this.recalculateStartTime(time);
|
|
5147
5146
|
}
|
|
@@ -5158,7 +5157,10 @@ var SpessaSynthSequencer = class {
|
|
|
5158
5157
|
*/
|
|
5159
5158
|
play() {
|
|
5160
5159
|
if (!this._midiData) {
|
|
5161
|
-
|
|
5160
|
+
SpessaSynthWarn(
|
|
5161
|
+
"No songs loaded in the sequencer. Ignoring the play call."
|
|
5162
|
+
);
|
|
5163
|
+
return;
|
|
5162
5164
|
}
|
|
5163
5165
|
if (this.currentTime >= this._midiData.duration) {
|
|
5164
5166
|
this.currentTime = 0;
|