spessasynth_core 4.0.22 → 4.0.23

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.d.ts CHANGED
@@ -4020,7 +4020,7 @@ declare class SpessaSynthSequencer {
4020
4020
  */
4021
4021
  protected stop(): void;
4022
4022
  /**
4023
- * @returns the index of the first to the current played time
4023
+ * @returns The track number of the next closest event, based on eventIndexes.
4024
4024
  */
4025
4025
  protected findFirstEventIndex(): number;
4026
4026
  /**
@@ -4044,10 +4044,10 @@ declare class SpessaSynthSequencer {
4044
4044
  protected recalculateStartTime(time: number): void;
4045
4045
  /**
4046
4046
  * Jumps to a MIDI tick without any further processing.
4047
- * @param tick The MIDI tick to jump to.
4047
+ * @param targetTicks The MIDI tick to jump to.
4048
4048
  * @protected
4049
4049
  */
4050
- protected jumpToTick(tick: number): void;
4050
+ protected jumpToTick(targetTicks: number): void;
4051
4051
  protected sendMIDINoteOn(channel: number, midiNote: number, velocity: number): void;
4052
4052
  protected sendMIDINoteOff(channel: number, midiNote: number): void;
4053
4053
  protected sendMIDICC(channel: number, type: MIDIController, value: number): void;
package/dist/index.js CHANGED
@@ -5202,7 +5202,7 @@ var SpessaSynthSequencer = class {
5202
5202
  this.sendMIDIAllOff();
5203
5203
  }
5204
5204
  /**
5205
- * @returns the index of the first to the current played time
5205
+ * @returns The track number of the next closest event, based on eventIndexes.
5206
5206
  */
5207
5207
  findFirstEventIndex() {
5208
5208
  let index = 0;
@@ -5302,26 +5302,27 @@ var SpessaSynthSequencer = class {
5302
5302
  }
5303
5303
  /**
5304
5304
  * Jumps to a MIDI tick without any further processing.
5305
- * @param tick The MIDI tick to jump to.
5305
+ * @param targetTicks The MIDI tick to jump to.
5306
5306
  * @protected
5307
5307
  */
5308
- jumpToTick(tick) {
5308
+ jumpToTick(targetTicks) {
5309
5309
  if (!this._midiData) {
5310
5310
  return;
5311
5311
  }
5312
- const seconds = this._midiData.midiTicksToSeconds(tick);
5312
+ this.sendMIDIAllOff();
5313
+ const seconds = this._midiData.midiTicksToSeconds(targetTicks);
5313
5314
  this.callEvent("timeChange", { newTime: seconds });
5314
5315
  this.recalculateStartTime(seconds);
5315
5316
  this.playedTime = seconds;
5316
5317
  this.eventIndexes.length = 0;
5317
5318
  for (const track of this._midiData.tracks) {
5318
- this.eventIndexes.push(
5319
- Math.max(
5320
- 0,
5321
- track.events.findIndex((e) => e.ticks >= tick)
5322
- )
5323
- );
5319
+ const idx = track.events.findIndex((e) => e.ticks >= targetTicks);
5320
+ this.eventIndexes.push(idx < 0 ? track.events.length : idx);
5324
5321
  }
5322
+ const targetTempo = this._midiData.tempoChanges.find(
5323
+ (t) => t.ticks <= targetTicks
5324
+ );
5325
+ this.oneTickToSeconds = 60 / (targetTempo.tempo * this._midiData.timeDivision);
5325
5326
  }
5326
5327
  /*
5327
5328
  SEND MIDI METHOD ABSTRACTIONS