spessasynth_core 4.0.11 → 4.0.13

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
@@ -3250,8 +3250,16 @@ var BasicMIDI2 = class _BasicMIDI {
3250
3250
  parseInternal() {
3251
3251
  SpessaSynthGroup("%cInterpreting MIDI events...", consoleColors.info);
3252
3252
  let karaokeHasTitle = false;
3253
- this.keyRange = { max: 0, min: 127 };
3253
+ this.tempoChanges = [{ ticks: 0, tempo: 120 }];
3254
3254
  this.extraMetadata = [];
3255
+ this.lyrics = [];
3256
+ this.firstNoteOn = 0;
3257
+ this.keyRange = { max: 0, min: 127 };
3258
+ this.lastVoiceEventTick = 0;
3259
+ this.portChannelOffsetMap = [0];
3260
+ this.loop = { start: 0, end: 0 };
3261
+ this.isKaraokeFile = false;
3262
+ this.isMultiPort = false;
3255
3263
  let nameDetected = false;
3256
3264
  if (typeof this.rmidiInfo.name !== "undefined") {
3257
3265
  nameDetected = true;
@@ -3265,9 +3273,6 @@ var BasicMIDI2 = class _BasicMIDI {
3265
3273
  const e = track.events[i];
3266
3274
  if (e.statusByte >= 128 && e.statusByte < 240) {
3267
3275
  trackHasVoiceMessages = true;
3268
- for (let j = 0; j < e.data.length; j++) {
3269
- e.data[j] = Math.min(127, e.data[j]);
3270
- }
3271
3276
  if (e.ticks > this.lastVoiceEventTick) {
3272
3277
  this.lastVoiceEventTick = e.ticks;
3273
3278
  }
@@ -8009,11 +8014,15 @@ function selectPreset(presets, patch, system) {
8009
8014
  returnReplacement(p);
8010
8015
  return p;
8011
8016
  }
8012
- const bank = Math.max(bankMSB, bankLSB);
8013
- p = matchingPrograms.find((p2) => p2.bankLSB === bank || p2.bankMSB === bank);
8014
- if (p) {
8015
- returnReplacement(p);
8016
- return p;
8017
+ if (bankLSB !== 64 || !isXG) {
8018
+ const bank = Math.max(bankMSB, bankLSB);
8019
+ p = matchingPrograms.find(
8020
+ (p2) => p2.bankLSB === bank || p2.bankMSB === bank
8021
+ );
8022
+ if (p) {
8023
+ returnReplacement(p);
8024
+ return p;
8025
+ }
8017
8026
  }
8018
8027
  returnReplacement(matchingPrograms[0]);
8019
8028
  return matchingPrograms[0];
@@ -8820,6 +8829,12 @@ var Voice = class _Voice {
8820
8829
  }
8821
8830
  };
8822
8831
  function getVoicesForPresetInternal(preset, midiNote, velocity, realKey) {
8832
+ const cached = this.getCachedVoice(preset, midiNote, velocity);
8833
+ if (cached !== void 0) {
8834
+ return cached.map(
8835
+ (v) => Voice.copyFrom(v, this.currentSynthTime, realKey)
8836
+ );
8837
+ }
8823
8838
  const voices = preset.getSynthesisData(midiNote, velocity).reduce((voices2, synthesisData) => {
8824
8839
  if (synthesisData.sample.getAudioData() === void 0) {
8825
8840
  SpessaSynthWarn(
@@ -8861,15 +8876,16 @@ function getVoicesForPresetInternal(preset, midiNote, velocity, realKey) {
8861
8876
  Math.floor(sampleData.length) - 1,
8862
8877
  loopingMode
8863
8878
  );
8879
+ let voiceVelocity = velocity;
8864
8880
  if (generators[generatorTypes.velocity] > -1) {
8865
- velocity = generators[generatorTypes.velocity];
8881
+ voiceVelocity = generators[generatorTypes.velocity];
8866
8882
  }
8867
8883
  voices2.push(
8868
8884
  new Voice(
8869
8885
  this.sampleRate,
8870
8886
  audioSample,
8871
8887
  midiNote,
8872
- velocity,
8888
+ voiceVelocity,
8873
8889
  this.currentSynthTime,
8874
8890
  targetKey,
8875
8891
  realKey,
@@ -8895,19 +8911,8 @@ function getVoicesInternal(channel, midiNote, velocity, realKey) {
8895
8911
  SpessaSynthWarn(`No preset for channel ${channel}!`);
8896
8912
  return [];
8897
8913
  }
8898
- let patch = {
8899
- ...preset
8900
- };
8901
- if (overridePatch) {
8902
- patch = this.keyModifierManager.getPatch(channel, midiNote);
8903
- }
8904
- const cached = this.getCachedVoice(patch, midiNote, velocity);
8905
- if (cached !== void 0) {
8906
- return cached.map(
8907
- (v) => Voice.copyFrom(v, this.currentSynthTime, realKey)
8908
- );
8909
- }
8910
8914
  if (overridePatch) {
8915
+ const patch = this.keyModifierManager.getPatch(channel, midiNote);
8911
8916
  preset = this.soundBankManager.getPreset(
8912
8917
  patch,
8913
8918
  this.privateProps.masterParameters.midiSystem
@@ -11146,7 +11151,7 @@ function getLookup(value) {
11146
11151
  return 0;
11147
11152
  }
11148
11153
  function portamentoTimeToSeconds(time, distance) {
11149
- return getLookup(time) * (distance / 30);
11154
+ return getLookup(time) * (distance / 36);
11150
11155
  }
11151
11156
 
11152
11157
  // src/synthesizer/audio_engine/engine_methods/note_on.ts