spessasynth_lib 3.20.25 → 3.20.27

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,7 +1,7 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.20.25",
4
- "description": "MIDI and SoundFont2 or DLS Synthesizer library with no compromises",
3
+ "version": "3.20.27",
4
+ "description": "MIDI and SoundFont2/DLS library with no compromises",
5
5
  "browser": "index.js",
6
6
  "types": "@types/index.d.ts",
7
7
  "type": "module",
@@ -140,18 +140,25 @@ class BasicSoundFont
140
140
  */
141
141
  getPreset(bankNr, programNr)
142
142
  {
143
+ // check for exact match
143
144
  let preset = this.presets.find(p => p.bank === bankNr && p.program === programNr);
144
145
  if (!preset)
145
146
  {
146
- preset = this.presets.find(p => p.program === programNr && p.bank !== 128);
147
+ // no match...
147
148
  if(bankNr === 128)
148
149
  {
150
+ // drum preset: find any preset with bank 128
149
151
  preset = this.presets.find(p => p.bank === 128 && p.program === programNr);
150
152
  if(!preset)
151
153
  {
152
154
  preset = this.presets.find(p => p.bank === 128);
153
155
  }
154
156
  }
157
+ else
158
+ {
159
+ // non drum preset: find any preset with the given program that is not a drum preset
160
+ preset = this.presets.find(p => p.program === programNr && p.bank !== 128);
161
+ }
155
162
  if(preset)
156
163
  {
157
164
  SpessaSynthWarn(`%cPreset ${bankNr}.${programNr} not found. Replaced with %c${preset.presetName} (${preset.bank}.${preset.program})`,
@@ -159,6 +166,7 @@ class BasicSoundFont
159
166
  consoleColors.recognized);
160
167
  }
161
168
  }
169
+ // no preset, use the first one available
162
170
  if(!preset)
163
171
  {
164
172
  SpessaSynthWarn(`Preset ${programNr} not found. Defaulting to`, this.presets[0].presetName);
@@ -48,6 +48,8 @@ class DLSSoundFont extends BasicSoundFont
48
48
  this.soundFontInfo["isng"] = "EMU8000";
49
49
 
50
50
  // set some defaults
51
+ this.soundFontInfo["INAM"] = "Unnamed DLS";
52
+ this.soundFontInfo["IENG"] = "Unknown";
51
53
  this.soundFontInfo["IPRD"] = "SpessaSynth DLS";
52
54
  this.soundFontInfo["ICRD"] = new Date().toDateString();
53
55
 
@@ -61,7 +63,7 @@ class DLSSoundFont extends BasicSoundFont
61
63
  this.soundFontInfo[infoPart.header] = readBytesAsString(infoPart.chunkData, infoPart.size);
62
64
  }
63
65
  }
64
- this.soundFontInfo["ICMT"] = (this.soundFontInfo["ICMT"] || "") + "\nConverted from DLS to SF2 with SpessaSynth";
66
+ this.soundFontInfo["ICMT"] = (this.soundFontInfo["ICMT"] || "(No description)") + "\nConverted from DLS to SF2 with SpessaSynth";
65
67
  if(this.soundFontInfo["ISBJ"])
66
68
  {
67
69
  // merge it
@@ -101,6 +103,9 @@ class DLSSoundFont extends BasicSoundFont
101
103
  }
102
104
  this.readDLSInstrumentList(instrumentListChunk);
103
105
 
106
+ // sort presets
107
+ this.presets.sort((a, b) => (a.program - b.program) + (a.bank - b.bank));
108
+
104
109
  SpessaSynthInfo(`%cParsing finished! %c"${this.soundFontInfo["INAM"] || "UNNAMED"}"%c has %c${this.presets.length} %cpresets,
105
110
  %c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,
106
111
  consoleColors.info,
@@ -42,6 +42,7 @@ export class DLSZone extends BasicInstrumentZone
42
42
  this.isGlobal = false;
43
43
 
44
44
  // correct tuning if needed
45
+ samplePitchCorrection -= sample.samplePitchCorrection;
45
46
  const coarseTune = Math.trunc(samplePitchCorrection / 100);
46
47
  if(coarseTune !== 0)
47
48
  {