spessasynth_core 3.26.2 → 3.26.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_core",
3
- "version": "3.26.2",
3
+ "version": "3.26.4",
4
4
  "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -264,11 +264,20 @@ export function _playTo(time, ticks = undefined)
264
264
  });
265
265
  }
266
266
  // restore programs
267
- if (programs[channelNumber].program >= 0 && programs[channelNumber].actualBank >= 0)
267
+ if (programs[channelNumber].actualBank >= 0)
268
268
  {
269
- const bank = programs[channelNumber].actualBank;
270
- this.synth.controllerChange(channelNumber, midiControllers.bankSelect, bank);
271
- this.synth.programChange(channelNumber, programs[channelNumber].program);
269
+ const p = programs[channelNumber];
270
+ if (p.program !== -1)
271
+ {
272
+ // a program change has occurred, apply the actual bank when program change was executed
273
+ this.synth.controllerChange(channelNumber, midiControllers.bankSelect, p.actualBank);
274
+ this.synth.programChange(channelNumber, p.program);
275
+ }
276
+ else
277
+ {
278
+ // no program change, apply the current bank select
279
+ this.synth.controllerChange(channelNumber, midiControllers.bankSelect, p.bank);
280
+ }
272
281
  }
273
282
  }
274
283
  }
@@ -79,6 +79,11 @@ export class BasicPreset
79
79
  }
80
80
  }
81
81
 
82
+ clearCache()
83
+ {
84
+ this.foundSamplesAndGenerators = [];
85
+ }
86
+
82
87
  /**
83
88
  * @param allowXG {boolean}
84
89
  * @param allowSFX {boolean}
@@ -557,6 +557,15 @@ class BasicSoundBank
557
557
  delete this.instruments;
558
558
  delete this.samples;
559
559
  }
560
+
561
+ // noinspection JSUnusedGlobalSymbols
562
+ /**
563
+ * Clears the cache for all the presets
564
+ */
565
+ clearCache()
566
+ {
567
+ this.presets.forEach(p => p.clearCache());
568
+ }
560
569
  }
561
570
 
562
571
  BasicSoundBank.prototype.write = write;
@@ -12,7 +12,7 @@ export function clearSoundFont(sendPresets = true, clearOverride = true)
12
12
  this.overrideSoundfont = undefined;
13
13
  }
14
14
  this.getDefaultPresets();
15
- this.cachedVoices = [];
15
+ this.clearCache();
16
16
 
17
17
  if (sendPresets)
18
18
  {
@@ -27,6 +27,7 @@ export function updatePresetList()
27
27
  }
28
28
  });
29
29
  }
30
+ this.clearCache();
30
31
  this.callEvent("presetlistchange", mainFont);
31
32
  this.getDefaultPresets();
32
33
  this.resetAllControllers(false);
@@ -468,10 +468,6 @@ class SpessaSynthProcessor
468
468
  setCachedVoice(bank, program, midiNote, velocity, voices)
469
469
  {
470
470
  // make sure that it exists
471
- if (!this.cachedVoices)
472
- {
473
- this.cachedVoices = [];
474
- }
475
471
  if (!this.cachedVoices[bank])
476
472
  {
477
473
  this.cachedVoices[bank] = [];
@@ -749,6 +745,11 @@ class SpessaSynthProcessor
749
745
  {
750
746
  this?.onEventCall?.(eventName, eventData);
751
747
  }
748
+
749
+ clearCache()
750
+ {
751
+ this.cachedVoices = [];
752
+ }
752
753
  }
753
754
 
754
755
  // include other methods