spessasynth_core 4.3.13 → 4.3.15

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/dist/index.js CHANGED
@@ -1800,7 +1800,7 @@ var MIDIUtils = class MIDIUtils {
1800
1800
  case "gs": return [MIDIUtils.gsMessage(ticks, 64, 16 | gsChannel, 20, [value])];
1801
1801
  case "xg": return [MIDIUtils.xgMessage(ticks, 8, channel, 6, [value])];
1802
1802
  }
1803
- case "efxAssign": return [MIDIUtils.gsMessage(ticks, 64, 16 | gsChannel, 34, [value])];
1803
+ case "efxAssign": return [MIDIUtils.gsMessage(ticks, 64, 64 | gsChannel, 34, [value ? 1 : 0])];
1804
1804
  case "cc1": return [MIDIUtils.gsMessage(ticks, 64, 16 | gsChannel, 31, [value])];
1805
1805
  case "cc2": return [MIDIUtils.gsMessage(ticks, 64, 16 | gsChannel, 32, [value])];
1806
1806
  case "drumMap": return [MIDIUtils.gsMessage(ticks, 64, 16 | gsChannel, 21, [value])];
@@ -2438,7 +2438,7 @@ function correctBankOffsetInternal(mid, bankOffset, soundBank) {
2438
2438
  ports[trackNum] = e.data[0];
2439
2439
  return;
2440
2440
  }
2441
- const status = e.statusByte & 240;
2441
+ let status = e.statusByte & 240;
2442
2442
  if (status !== MIDIMessageTypes.controllerChange && status !== MIDIMessageTypes.programChange && status !== MIDIMessageTypes.systemExclusive) return;
2443
2443
  if (status === MIDIMessageTypes.systemExclusive) {
2444
2444
  const syx = MIDIUtils.analyzeSysEx(e.data);
@@ -2479,6 +2479,7 @@ function correctBankOffsetInternal(mid, bankOffset, soundBank) {
2479
2479
  }
2480
2480
  }
2481
2481
  }
2482
+ status = e.statusByte & 240;
2482
2483
  const chNum = (e.statusByte & 15) + portOffset;
2483
2484
  const ch = channels[chNum];
2484
2485
  if (status === MIDIMessageTypes.programChange) {
@@ -3235,7 +3236,7 @@ function modifyMIDIInternal(midi, opts) {
3235
3236
  case MIDIMessageTypes.controllerChange: {
3236
3237
  const ccNum = e.data[0];
3237
3238
  const value = e.data[1];
3238
- if (channelChange?.controllers?.get(ccNum)) {
3239
+ if (channelChange?.controllers?.get(ccNum) !== void 0) {
3239
3240
  deleteThisEvent();
3240
3241
  return;
3241
3242
  }
@@ -3264,7 +3265,7 @@ function modifyMIDIInternal(midi, opts) {
3264
3265
  case "Controller Change": {
3265
3266
  const ccNum = data.controller;
3266
3267
  const channel = data.channel;
3267
- if (channelChange?.controllers?.get(ccNum)) {
3268
+ if (channelChange?.controllers?.get(ccNum) !== void 0) {
3268
3269
  deleteParameter(channel);
3269
3270
  return;
3270
3271
  }
@@ -5366,8 +5367,8 @@ function setTimeToInternal(time, ticks = void 0) {
5366
5367
  if (ch.portamentoNote >= 0) if (this.externalMIDIPlayback) this.sendMIDICC(channel, MIDIControllers.portamentoControl, ch.portamentoNote);
5367
5368
  else this.synth.midiChannels[channel].setLastNote(ch.portamentoNote);
5368
5369
  for (let i = 0; i < 128; i++) {
5369
- const value = ch.controllers[i] >> 7;
5370
- if (value !== DEFAULT_MIDI_CONTROLLERS[i] && !nonSkippableCCs.has(i)) this.sendMIDICC(channel, i, value);
5370
+ const value = ch.controllers[i];
5371
+ if (value !== DEFAULT_MIDI_CONTROLLERS[i] && !nonSkippableCCs.has(i)) this.sendMIDICC(channel, i, value >> 7);
5371
5372
  }
5372
5373
  }
5373
5374
  if (savedTempo) this.callEvent("metaEvent", {
@@ -10483,6 +10484,9 @@ var ConnectionBlock = class ConnectionBlock {
10483
10484
  default:
10484
10485
  SpessaLog.info(`%cFailed converting DLS articulator into SF generator: %c${this.toString()}%c\n(invalid destination)`, ConsoleColors.warn, ConsoleColors.value, ConsoleColors.unrecognized);
10485
10486
  return;
10487
+ case DLSDestinations.keyNum:
10488
+ zone.setGenerator(GeneratorTypes.keyNum, value);
10489
+ break;
10486
10490
  case DLSDestinations.pan:
10487
10491
  zone.setGenerator(GeneratorTypes.pan, value);
10488
10492
  break;
@@ -10632,7 +10636,7 @@ var ConnectionBlock = class ConnectionBlock {
10632
10636
  newAmount: -amount
10633
10637
  };
10634
10638
  case DLSDestinations.pitch: return GeneratorTypes.fineTune;
10635
- case DLSDestinations.keyNum: return GeneratorTypes.overridingRootKey;
10639
+ case DLSDestinations.keyNum: return GeneratorTypes.keyNum;
10636
10640
  case DLSDestinations.volEnvDelay: return GeneratorTypes.delayVolEnv;
10637
10641
  case DLSDestinations.volEnvAttack: return GeneratorTypes.attackVolEnv;
10638
10642
  case DLSDestinations.volEnvHold: return GeneratorTypes.holdVolEnv;
@@ -10743,7 +10747,7 @@ var DownloadableSoundsArticulation = class extends DLSVerifier {
10743
10747
  writeDword(art2Data, this.connectionBlocks.length);
10744
10748
  const out = this.connectionBlocks.map((a) => a.write());
10745
10749
  const art2 = RIFFChunk.getParts(this.mode === "dls2" ? "art2" : "art1", [art2Data, ...out]);
10746
- return RIFFChunk.getParts(this.mode === "dls2" ? "lar2" : "lart", art2, true);
10750
+ return RIFFChunk.getParts(this.mode === "dls2" ? "lar2" : "lart", art2, false, true);
10747
10751
  }
10748
10752
  /**
10749
10753
  * Converts DLS articulation into an SF zone.
@@ -11246,16 +11250,18 @@ var DownloadableSounds = class DownloadableSounds extends DLSVerifier {
11246
11250
  const drumAliases = pgalData.slice(pgalData.currentIndex, pgalData.currentIndex + 128);
11247
11251
  pgalData.currentIndex += 128;
11248
11252
  for (let keyNum = 0; keyNum < 128; keyNum++) {
11249
- const alias = drumAliases[keyNum];
11250
- if (alias === keyNum) continue;
11251
- const region = drumInstrument.regions.find((r) => r.keyRange.max === alias && r.keyRange.min === alias);
11253
+ const source = drumAliases[keyNum];
11254
+ if (source === keyNum) continue;
11255
+ const region = drumInstrument.regions.find((r) => r.keyRange.max === source && r.keyRange.min === source);
11252
11256
  if (!region) {
11253
- SpessaLog.warn(`Invalid drum alias ${keyNum} to ${alias}: region does not exist.`);
11257
+ SpessaLog.warn(`Invalid drum alias ${keyNum} to ${source}: region does not exist.`);
11254
11258
  continue;
11255
11259
  }
11256
11260
  const copied = DownloadableSoundsRegion.copyFrom(region);
11257
11261
  copied.keyRange.max = keyNum;
11258
11262
  copied.keyRange.min = keyNum;
11263
+ const fixedKeyBlock = new ConnectionBlock(new ConnectionSource(DLSSources.none, 0, false, false), new ConnectionSource(DLSSources.none, 0, false, false), DLSDestinations.keyNum, 0, source << 16);
11264
+ copied.articulation.connectionBlocks.push(fixedKeyBlock);
11259
11265
  drumInstrument.regions.push(copied);
11260
11266
  }
11261
11267
  pgalData.currentIndex += 4;
@@ -20292,10 +20298,10 @@ var SynthesizerCore = class {
20292
20298
  this.setReverbMacro(4);
20293
20299
  this.setChorusMacro(2);
20294
20300
  this.setDelayMacro(0);
20295
- if (!this.systemParameters.delayLock) this.delayActive = false;
20296
20301
  this.resetInsertion();
20297
20302
  if (!this.drumPreset || !this.defaultPreset) return;
20298
20303
  for (const ch of this.midiChannels) ch.reset(false);
20304
+ if (!this.systemParameters.delayLock) this.delayActive = this.midiChannels.some((c) => c.midiControllers[MIDIControllers.variationDepth] > 0);
20299
20305
  }
20300
20306
  process(left, right, startIndex = 0, sampleCount = 0) {
20301
20307
  this.processSplit([[left, right]], left, right, startIndex, sampleCount);