spessasynth_core 3.26.26 → 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.26",
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",
@@ -350,7 +350,7 @@ class XMFNode
350
350
  }
351
351
 
352
352
  /**
353
- * @param midi {MIDI}
353
+ * @param midi {BasicMIDI}
354
354
  * @param binaryData {IndexedByteArray}
355
355
  * @returns {IndexedByteArray} the file byte array
356
356
  */
@@ -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
@@ -149,7 +149,6 @@ class BasicSoundBank
149
149
  20,
150
150
  0,
151
151
  0,
152
- 0,
153
152
  127
154
153
  );
155
154
  sample.sampleData = new Float32Array(128);
@@ -443,15 +442,24 @@ class BasicSoundBank
443
442
 
444
443
  removeUnusedElements()
445
444
  {
446
- this.instruments.forEach(i =>
445
+ this.instruments = this.instruments.filter(i =>
446
+ {
447
+ const deletable = i.useCount < 1;
448
+ if (deletable)
449
+ {
450
+ i.deleteInstrument();
451
+ }
452
+ return deletable;
453
+ });
454
+ this.samples = this.samples.filter(s =>
447
455
  {
448
- if (i.useCount < 1)
456
+ const deletable = s.useCount < 1;
457
+ if (deletable)
449
458
  {
450
- i.deleteAllZones();
459
+ s.deleteSample();
451
460
  }
461
+ return deletable;
452
462
  });
453
- this.instruments = this.instruments.filter(i => i.useCount > 0);
454
- this.samples = this.samples.filter(s => s.useCount > 0);
455
463
  }
456
464
 
457
465
  /**
@@ -459,12 +467,8 @@ class BasicSoundBank
459
467
  */
460
468
  deleteInstrument(instrument)
461
469
  {
462
- if (instrument.useCount > 0)
463
- {
464
- throw new Error(`Cannot delete an instrument that has ${instrument.useCount} usages.`);
465
- }
470
+ instrument.deleteInstrument();
466
471
  this.instruments.splice(this.instruments.indexOf(instrument), 1);
467
- instrument.deleteAllZones();
468
472
  }
469
473
 
470
474
  /**
@@ -481,10 +485,7 @@ class BasicSoundBank
481
485
  */
482
486
  deleteSample(sample)
483
487
  {
484
- if (sample.useCount > 0)
485
- {
486
- throw new Error(`Cannot delete sample that has ${sample.useCount} usages.`);
487
- }
488
+ sample.deleteSample();
488
489
  this.samples.splice(this.samples.indexOf(sample), 1);
489
490
  }
490
491
 
@@ -616,6 +617,7 @@ class BasicSoundBank
616
617
  delete this.presets;
617
618
  delete this.instruments;
618
619
  delete this.samples;
620
+ delete this.soundFontInfo;
619
621
  }
620
622
  }
621
623
 
@@ -1,4 +1,4 @@
1
- import { BasicSample } from "../basic_soundfont/basic_sample.js";
1
+ import { BasicSample, sampleTypes } from "../basic_soundfont/basic_sample.js";
2
2
 
3
3
  export class DLSSample extends BasicSample
4
4
  {
@@ -38,12 +38,11 @@ export class DLSSample extends BasicSample
38
38
  rate,
39
39
  pitch,
40
40
  pitchCorrection,
41
- 0,
42
- 1,
41
+ sampleTypes.monoSample,
43
42
  loopStart,
44
43
  loopEnd
45
44
  );
46
- this.sampleData = data;
45
+ this.setAudioData(data);
47
46
  this.sampleDbAttenuation = sampleDbAttenuation;
48
47
  }
49
48
 
@@ -27,7 +27,7 @@ export class IndexedByteArray extends Uint8Array
27
27
  */
28
28
  slice(start, end)
29
29
  {
30
- const a = super.slice(start, end);
30
+ const a = /** @type {IndexedByteArray} */ super.slice(start, end);
31
31
  a.currentIndex = 0;
32
32
  return a;
33
33
  }