spessasynth_core 4.1.0 → 4.1.2

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
@@ -6857,12 +6857,13 @@ var VolumeEnvelope = class {
6857
6857
  const smooth = currentGain !== gainTarget;
6858
6858
  if (sampleTime < attackEnd) {
6859
6859
  this.attenuationCb = 0;
6860
+ const gainOffset = cbAttenuationToGain(centibelOffset);
6860
6861
  while (sampleTime < attackEnd) {
6861
6862
  if (smooth) {
6862
6863
  currentGain += (gainTarget - currentGain) * gainSmoothing;
6863
6864
  }
6864
6865
  const linearGain = 1 - (attackEnd - sampleTime) / attackDuration;
6865
- buffer[filledBuffer] *= linearGain * currentGain;
6866
+ buffer[filledBuffer] *= linearGain * currentGain * gainOffset;
6866
6867
  sampleTime++;
6867
6868
  if (++filledBuffer >= sampleCount) {
6868
6869
  this.sampleTime = sampleTime;
@@ -11352,6 +11353,9 @@ function setMasterParameterInternal(parameter, value) {
11352
11353
  case "voiceCap": {
11353
11354
  const cap = Math.min(value, 1e6);
11354
11355
  this.masterParameters.voiceCap = cap;
11356
+ for (let i = cap; i < this.voices.length; i++) {
11357
+ this.voices[i].isActive = false;
11358
+ }
11355
11359
  if (cap > this.voices.length) {
11356
11360
  SpessaSynthWarn(
11357
11361
  `Allocating ${cap - this.voices.length} new voices!`
@@ -12811,7 +12815,9 @@ var SynthesizerCore = class {
12811
12815
  c.clearVoiceCount();
12812
12816
  }
12813
12817
  this.voiceCount = 0;
12814
- for (const v of this.voices) {
12818
+ const cap = this.masterParameters.voiceCap;
12819
+ for (let i = 0; i < cap; i++) {
12820
+ const v = this.voices[i];
12815
12821
  if (!v.isActive) {
12816
12822
  continue;
12817
12823
  }
@@ -12863,7 +12869,9 @@ var SynthesizerCore = class {
12863
12869
  c.clearVoiceCount();
12864
12870
  }
12865
12871
  this.voiceCount = 0;
12866
- for (const v of this.voices) {
12872
+ const cap = this.masterParameters.voiceCap;
12873
+ for (let i = 0; i < cap; i++) {
12874
+ const v = this.voices[i];
12867
12875
  if (!v.isActive) {
12868
12876
  continue;
12869
12877
  }
@@ -12968,7 +12976,9 @@ var SynthesizerCore = class {
12968
12976
  assignVoicePriorities() {
12969
12977
  if (this.lastPriorityAssignmentTime === this.currentTime) return;
12970
12978
  this.lastPriorityAssignmentTime = this.currentTime;
12971
- for (const voice of this.voices) {
12979
+ const cap = this.masterParameters.voiceCap;
12980
+ for (let i = 0; i < cap; i++) {
12981
+ const voice = this.voices[i];
12972
12982
  voice.priority = 0;
12973
12983
  if (this.midiChannels[voice.channel].drumChannel) {
12974
12984
  voice.priority += 5;