spessasynth_lib 3.24.7 → 3.24.9

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # spessasynth_lib
2
2
 
3
- **A powerful soundfont/MIDI JavaScript library for the browsers.**
3
+ **A powerful SF2/DLS/MIDI JavaScript library for the browsers.**
4
4
 
5
5
  ```shell
6
6
  npm install --save spessasynth_lib
@@ -134,5 +134,5 @@ document.getElementById("button").onclick = async () =>
134
134
  - *That's right, saving as WAV is also [just one function!](https://github.com/spessasus/SpessaSynth/wiki/Writing-Wave-Files#audiobuffertowav)*
135
135
 
136
136
  # License
137
-
137
+ Copyright © 2025 Spessasus
138
138
  MIT License, except for the stbvorbis_sync.js in the `externals` folder which is licensed under the Apache-2.0 license.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.24.7",
3
+ "version": "3.24.9",
4
4
  "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "browser": "index.js",
6
6
  "type": "module",
@@ -53,7 +53,10 @@ export function processMessage(messageType, messageData)
53
53
  {
54
54
  this.loopCount = Infinity;
55
55
  }
56
- this.loopCount = count;
56
+ else
57
+ {
58
+ this.loopCount = count;
59
+ }
57
60
  break;
58
61
 
59
62
  case WorkletSequencerMessageType.changeSong:
@@ -2,11 +2,14 @@ import { WorkletSequencerReturnMessageType } from "./sequencer_message.js";
2
2
 
3
3
  /**
4
4
  * Processes a single tick
5
- * @private
6
5
  * @this {WorkletSequencer}
7
6
  */
8
- export function _processTick()
7
+ export function processTick()
9
8
  {
9
+ if (!this.isActive)
10
+ {
11
+ return;
12
+ }
10
13
  let current = this.currentTime;
11
14
  while (this.playedTime < current)
12
15
  {
@@ -38,7 +41,7 @@ export function _processTick()
38
41
  let eventNext = this.tracks[trackIndex][this.eventIndex[trackIndex]];
39
42
  this.playedTime += this.oneTickToSeconds * (eventNext.ticks - event.ticks);
40
43
 
41
- const canLoop = this.loop && this.loopCount > 0;
44
+ const canLoop = this.loop && (this.loopCount > 0 || this.loopCount === -1);
42
45
 
43
46
  // if we reached loop.end
44
47
  if ((this.midiData.loop.end <= event.ticks) && canLoop)
@@ -1,6 +1,6 @@
1
1
  import { WorkletSequencerReturnMessageType } from "./sequencer_message.js";
2
2
  import { _addNewMidiPort, _processEvent } from "./process_event.js";
3
- import { _findFirstEventIndex, _processTick } from "./process_tick.js";
3
+ import { _findFirstEventIndex, processTick } from "./process_tick.js";
4
4
  import { assignMIDIPort, loadNewSequence, loadNewSongList, nextSong, previousSong } from "./song_control.js";
5
5
  import { _playTo, _recalculateStartTime, play, setTimeTicks } from "./play.js";
6
6
  import { messageTypes, midiControllers } from "../../midi_parser/midi_message.js";
@@ -25,6 +25,7 @@ class WorkletSequencer
25
25
  {
26
26
  this.synth = spessasynthProcessor;
27
27
  this.ignoreEvents = false;
28
+ this.isActive = false;
28
29
 
29
30
  /**
30
31
  * If the event should instead be sent back to the main thread instead of synth
@@ -236,12 +237,12 @@ class WorkletSequencer
236
237
 
237
238
  setProcessHandler()
238
239
  {
239
- this.synth.processTickCallback = this._processTick.bind(this);
240
+ this.isActive = true;
240
241
  }
241
242
 
242
243
  clearProcessHandler()
243
244
  {
244
- this.synth.processTickCallback = undefined;
245
+ this.isActive = false;
245
246
  }
246
247
  }
247
248
 
@@ -258,7 +259,7 @@ WorkletSequencer.prototype.processMessage = processMessage;
258
259
 
259
260
  WorkletSequencer.prototype._processEvent = _processEvent;
260
261
  WorkletSequencer.prototype._addNewMidiPort = _addNewMidiPort;
261
- WorkletSequencer.prototype._processTick = _processTick;
262
+ WorkletSequencer.prototype.processTick = processTick;
262
263
  WorkletSequencer.prototype._findFirstEventIndex = _findFirstEventIndex;
263
264
 
264
265
  WorkletSequencer.prototype.loadNewSequence = loadNewSequence;
@@ -141,7 +141,7 @@ export class Synthetizer
141
141
  this.effectsConfig = synthConfig;
142
142
  }
143
143
 
144
- // first two outputs: reverb, chorsu, the others are the channel outputs
144
+ // first two outputs: reverb, chorus, the others are the channel outputs
145
145
  try
146
146
  {
147
147
  let workletConstructor = synthConfig?.audioNodeCreators?.worklet;
@@ -236,7 +236,7 @@ export class Synthetizer
236
236
  }
237
237
  }
238
238
 
239
- // attach newchannel to keep track of channels count
239
+ // attach a new channel to keep track of channels count
240
240
  this.eventHandler.addEvent("newchannel", "synth-new-channel", () =>
241
241
  {
242
242
  this.channelsAmount++;