spessasynth_core 4.0.11 → 4.0.12

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
@@ -3265,9 +3265,6 @@ var BasicMIDI2 = class _BasicMIDI {
3265
3265
  const e = track.events[i];
3266
3266
  if (e.statusByte >= 128 && e.statusByte < 240) {
3267
3267
  trackHasVoiceMessages = true;
3268
- for (let j = 0; j < e.data.length; j++) {
3269
- e.data[j] = Math.min(127, e.data[j]);
3270
- }
3271
3268
  if (e.ticks > this.lastVoiceEventTick) {
3272
3269
  this.lastVoiceEventTick = e.ticks;
3273
3270
  }
@@ -8009,11 +8006,15 @@ function selectPreset(presets, patch, system) {
8009
8006
  returnReplacement(p);
8010
8007
  return p;
8011
8008
  }
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;
8009
+ if (bankLSB !== 64 || !isXG) {
8010
+ const bank = Math.max(bankMSB, bankLSB);
8011
+ p = matchingPrograms.find(
8012
+ (p2) => p2.bankLSB === bank || p2.bankMSB === bank
8013
+ );
8014
+ if (p) {
8015
+ returnReplacement(p);
8016
+ return p;
8017
+ }
8017
8018
  }
8018
8019
  returnReplacement(matchingPrograms[0]);
8019
8020
  return matchingPrograms[0];
@@ -8820,6 +8821,12 @@ var Voice = class _Voice {
8820
8821
  }
8821
8822
  };
8822
8823
  function getVoicesForPresetInternal(preset, midiNote, velocity, realKey) {
8824
+ const cached = this.getCachedVoice(preset, midiNote, velocity);
8825
+ if (cached !== void 0) {
8826
+ return cached.map(
8827
+ (v) => Voice.copyFrom(v, this.currentSynthTime, realKey)
8828
+ );
8829
+ }
8823
8830
  const voices = preset.getSynthesisData(midiNote, velocity).reduce((voices2, synthesisData) => {
8824
8831
  if (synthesisData.sample.getAudioData() === void 0) {
8825
8832
  SpessaSynthWarn(
@@ -8861,15 +8868,16 @@ function getVoicesForPresetInternal(preset, midiNote, velocity, realKey) {
8861
8868
  Math.floor(sampleData.length) - 1,
8862
8869
  loopingMode
8863
8870
  );
8871
+ let voiceVelocity = velocity;
8864
8872
  if (generators[generatorTypes.velocity] > -1) {
8865
- velocity = generators[generatorTypes.velocity];
8873
+ voiceVelocity = generators[generatorTypes.velocity];
8866
8874
  }
8867
8875
  voices2.push(
8868
8876
  new Voice(
8869
8877
  this.sampleRate,
8870
8878
  audioSample,
8871
8879
  midiNote,
8872
- velocity,
8880
+ voiceVelocity,
8873
8881
  this.currentSynthTime,
8874
8882
  targetKey,
8875
8883
  realKey,
@@ -8895,19 +8903,8 @@ function getVoicesInternal(channel, midiNote, velocity, realKey) {
8895
8903
  SpessaSynthWarn(`No preset for channel ${channel}!`);
8896
8904
  return [];
8897
8905
  }
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
8906
  if (overridePatch) {
8907
+ const patch = this.keyModifierManager.getPatch(channel, midiNote);
8911
8908
  preset = this.soundBankManager.getPreset(
8912
8909
  patch,
8913
8910
  this.privateProps.masterParameters.midiSystem
@@ -11146,7 +11143,7 @@ function getLookup(value) {
11146
11143
  return 0;
11147
11144
  }
11148
11145
  function portamentoTimeToSeconds(time, distance) {
11149
- return getLookup(time) * (distance / 30);
11146
+ return getLookup(time) * (distance / 36);
11150
11147
  }
11151
11148
 
11152
11149
  // src/synthesizer/audio_engine/engine_methods/note_on.ts