spessasynth_core 3.26.27 → 3.26.28

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.27",
3
+ "version": "3.26.28",
4
4
  "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -69,8 +69,12 @@ export class BasicInstrument
69
69
  this.linkedPresets.splice(index, 1);
70
70
  }
71
71
 
72
- deleteAllZones()
72
+ deleteInstrument()
73
73
  {
74
+ if (this.useCount > 0)
75
+ {
76
+ throw new Error(`Cannot delete an instrument that has ${this.useCount} usages.`);
77
+ }
74
78
  this.instrumentZones.forEach(z => z.deleteZone());
75
79
  this.instrumentZones.length = 0;
76
80
  }
@@ -246,6 +246,15 @@ export class BasicSample
246
246
 
247
247
  }
248
248
 
249
+ deleteSample()
250
+ {
251
+ if (this.useCount > 0)
252
+ {
253
+ throw new Error(`Cannot delete sample that has ${this.useCount} usages.`);
254
+ }
255
+ this.unlinkSample();
256
+ }
257
+
249
258
  // noinspection JSUnusedGlobalSymbols
250
259
  /**
251
260
  * Unlinks a sample link
@@ -442,15 +442,24 @@ class BasicSoundBank
442
442
 
443
443
  removeUnusedElements()
444
444
  {
445
- this.instruments.forEach(i =>
445
+ this.instruments = this.instruments.filter(i =>
446
446
  {
447
- if (i.useCount < 1)
447
+ const deletable = i.useCount < 1;
448
+ if (deletable)
448
449
  {
449
- i.deleteAllZones();
450
+ i.deleteInstrument();
450
451
  }
452
+ return deletable;
453
+ });
454
+ this.samples = this.samples.filter(s =>
455
+ {
456
+ const deletable = s.useCount < 1;
457
+ if (deletable)
458
+ {
459
+ s.deleteSample();
460
+ }
461
+ return deletable;
451
462
  });
452
- this.instruments = this.instruments.filter(i => i.useCount > 0);
453
- this.samples = this.samples.filter(s => s.useCount > 0);
454
463
  }
455
464
 
456
465
  /**
@@ -458,12 +467,8 @@ class BasicSoundBank
458
467
  */
459
468
  deleteInstrument(instrument)
460
469
  {
461
- if (instrument.useCount > 0)
462
- {
463
- throw new Error(`Cannot delete an instrument that has ${instrument.useCount} usages.`);
464
- }
470
+ instrument.deleteInstrument();
465
471
  this.instruments.splice(this.instruments.indexOf(instrument), 1);
466
- instrument.deleteAllZones();
467
472
  }
468
473
 
469
474
  /**
@@ -480,10 +485,7 @@ class BasicSoundBank
480
485
  */
481
486
  deleteSample(sample)
482
487
  {
483
- if (sample.useCount > 0)
484
- {
485
- throw new Error(`Cannot delete sample that has ${sample.useCount} usages.`);
486
- }
488
+ sample.deleteSample();
487
489
  this.samples.splice(this.samples.indexOf(sample), 1);
488
490
  }
489
491
 
@@ -615,6 +617,7 @@ class BasicSoundBank
615
617
  delete this.presets;
616
618
  delete this.instruments;
617
619
  delete this.samples;
620
+ delete this.soundFontInfo;
618
621
  }
619
622
  }
620
623