spessasynth_core 4.3.0 → 4.3.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.d.ts CHANGED
@@ -2956,6 +2956,7 @@ declare abstract class WavetableOscillator {
2956
2956
  loopStart: number;
2957
2957
  /**
2958
2958
  * End position of the loop.
2959
+ * INCLUSIVE!!
2959
2960
  */
2960
2961
  loopEnd: number;
2961
2962
  /**
package/dist/index.js CHANGED
@@ -1520,6 +1520,24 @@ var MIDIUtils = class MIDIUtils {
1520
1520
  default: return OTHER;
1521
1521
  case NonRegisteredMSB.partParameter: switch (lsb) {
1522
1522
  default: return OTHER;
1523
+ case NonRegisteredLSB.vibratoRate: return {
1524
+ type: "Controller Change",
1525
+ channel,
1526
+ controller: MIDIControllers.vibratoRate,
1527
+ value: value >> 7
1528
+ };
1529
+ case NonRegisteredLSB.vibratoDepth: return {
1530
+ type: "Controller Change",
1531
+ channel,
1532
+ controller: MIDIControllers.vibratoDepth,
1533
+ value: value >> 7
1534
+ };
1535
+ case NonRegisteredLSB.vibratoDelay: return {
1536
+ type: "Controller Change",
1537
+ channel,
1538
+ controller: MIDIControllers.vibratoDelay,
1539
+ value: value >> 7
1540
+ };
1523
1541
  case NonRegisteredLSB.tvfCutoffFrequency: return {
1524
1542
  type: "Controller Change",
1525
1543
  channel,
@@ -7136,6 +7154,7 @@ var WavetableOscillator = class {
7136
7154
  loopStart = 0;
7137
7155
  /**
7138
7156
  * End position of the loop.
7157
+ * INCLUSIVE!!
7139
7158
  */
7140
7159
  loopEnd = 0;
7141
7160
  /**
@@ -7156,13 +7175,13 @@ var LinearOscillator = class extends WavetableOscillator {
7156
7175
  process(sampleCount, tuningRatio, outputBuffer) {
7157
7176
  const step = tuningRatio * this.playbackStep;
7158
7177
  const data = this.sampleData;
7159
- const { loopEnd, loopLength, loopStart, end } = this;
7178
+ const { loopEnd, loopLength, end } = this;
7160
7179
  let cursor = this.cursor;
7161
7180
  if (this.isLooping) for (let i = 0; i < sampleCount; i++) {
7162
- if (cursor > loopStart) cursor = loopStart + (cursor - loopStart) % loopLength;
7181
+ if (cursor > loopEnd) cursor -= loopLength;
7163
7182
  const floor = cursor | 0;
7164
7183
  let ceil = floor + 1;
7165
- if (ceil >= loopEnd) ceil -= loopLength;
7184
+ if (ceil > loopEnd) ceil -= loopLength;
7166
7185
  const fraction = cursor - floor;
7167
7186
  const upper = data[ceil];
7168
7187
  const lower = data[floor];
@@ -7190,10 +7209,10 @@ var NearestOscillator = class extends WavetableOscillator {
7190
7209
  process(sampleCount, tuningRatio, outputBuffer) {
7191
7210
  const step = tuningRatio * this.playbackStep;
7192
7211
  const sampleData = this.sampleData;
7193
- const { loopLength, loopStart, end } = this;
7212
+ const { loopEnd, loopLength, end } = this;
7194
7213
  let cursor = this.cursor;
7195
7214
  if (this.isLooping) for (let i = 0; i < sampleCount; i++) {
7196
- if (cursor > loopStart) cursor = loopStart + (cursor - loopStart) % loopLength;
7215
+ if (cursor > loopEnd) cursor -= loopLength;
7197
7216
  outputBuffer[i] = sampleData[cursor | 0];
7198
7217
  cursor += step;
7199
7218
  }
@@ -7213,18 +7232,18 @@ var HermiteOscillator = class extends WavetableOscillator {
7213
7232
  process(sampleCount, tuningRatio, outputBuffer) {
7214
7233
  const step = tuningRatio * this.playbackStep;
7215
7234
  const sampleData = this.sampleData;
7216
- const { loopEnd, loopLength, loopStart, end } = this;
7235
+ const { loopEnd, loopLength, end } = this;
7217
7236
  let cursor = this.cursor;
7218
7237
  if (this.isLooping) for (let i = 0; i < sampleCount; i++) {
7219
- if (cursor > loopStart) cursor = loopStart + (cursor - loopStart) % loopLength;
7238
+ if (cursor > loopEnd) cursor -= loopLength;
7220
7239
  const y0 = cursor | 0;
7221
7240
  let y1 = y0 + 1;
7222
7241
  let y2 = y0 + 2;
7223
7242
  let y3 = y0 + 3;
7224
7243
  const t = cursor - y0;
7225
- if (y1 >= loopEnd) y1 -= loopLength;
7226
- if (y2 >= loopEnd) y2 -= loopLength;
7227
- if (y3 >= loopEnd) y3 -= loopLength;
7244
+ if (y1 > loopEnd) y1 -= loopLength;
7245
+ if (y2 > loopEnd) y2 -= loopLength;
7246
+ if (y3 > loopEnd) y3 -= loopLength;
7228
7247
  const xm1 = sampleData[y0];
7229
7248
  const x0 = sampleData[y1];
7230
7249
  const x1 = sampleData[y2];
@@ -12670,7 +12689,7 @@ function noteOn(midiNote, velocity) {
12670
12689
  voice.wavetable.loopEnd = temp;
12671
12690
  }
12672
12691
  if (voice.wavetable.loopEnd - voice.wavetable.loopStart < 1 && (voice.loopingMode === 1 || voice.loopingMode === 3)) voice.loopingMode = 0;
12673
- voice.wavetable.loopLength = voice.wavetable.loopEnd - voice.wavetable.loopStart;
12692
+ voice.wavetable.loopLength = voice.wavetable.loopEnd - voice.wavetable.loopStart + 1;
12674
12693
  voice.wavetable.isLooping = voice.loopingMode === 1 || voice.loopingMode === 3;
12675
12694
  voice.portamentoFromKey = portaFromKey;
12676
12695
  voice.portamentoDuration = portaTime;
@@ -13024,6 +13043,8 @@ function applySnapshot(snapshot) {
13024
13043
  this.perNotePitch = snapshot.perNotePitch;
13025
13044
  this.generators.offsets.set(snapshot.generators.offsets);
13026
13045
  this.generators.overrides.set(snapshot.generators.overrides);
13046
+ this.generators.offsetsEnabled = snapshot.generators.offsetsEnabled;
13047
+ this.generators.overridesEnabled = snapshot.generators.overridesEnabled;
13027
13048
  for (let i = 0; i < 128; i++) this.drumParams[i] = DrumParameters.copyFrom(snapshot.drumParams[i]);
13028
13049
  this.setSystemParameter("presetLock", false);
13029
13050
  if (snapshot.patch) this.setPatch(snapshot.patch);
@@ -19301,7 +19322,7 @@ var SynthesizerCore = class {
19301
19322
  /**
19302
19323
  * Voices of this synthesizer, as a fixed voice pool.
19303
19324
  */
19304
- voices;
19325
+ voices = [];
19305
19326
  /**
19306
19327
  * All MIDI channels of the synthesizer.
19307
19328
  */
@@ -19490,7 +19511,6 @@ var SynthesizerCore = class {
19490
19511
  this.delayInput = new Float32Array(bufSize);
19491
19512
  for (const insertion of INSERTION_EFFECT_LIST) this.registerInsertionProcessor(insertion);
19492
19513
  this.resetInsertionParams();
19493
- this.voices = [];
19494
19514
  this.allocateNewVoices(this.systemParameters.voiceCap);
19495
19515
  }
19496
19516
  /**
@@ -19565,11 +19585,11 @@ var SynthesizerCore = class {
19565
19585
  }
19566
19586
  }
19567
19587
  if (this.systemParameters.autoAllocateVoices) {
19588
+ SpessaLog.info(`%cAllocating a new voice, total count %c${this.systemParameters.voiceCap + 1}.`, ConsoleColors.info, ConsoleColors.value);
19568
19589
  this.allocateNewVoices(1);
19569
19590
  const v = this.voices[this.voices.length - 1];
19570
- this.voices.push(v);
19571
19591
  this.systemParameters.voiceCap++;
19572
- SpessaLog.info("%cAllocating a new voice!", ConsoleColors.info);
19592
+ v.priority = Infinity;
19573
19593
  return v;
19574
19594
  }
19575
19595
  this.assignVoicePriorities();
@@ -19794,10 +19814,10 @@ var SynthesizerCore = class {
19794
19814
  this.insertionActive = false;
19795
19815
  this.insertionProcessor = this.insertionFallback;
19796
19816
  this.insertionProcessor.reset();
19817
+ this.resetInsertionParams();
19797
19818
  this.insertionProcessor.sendLevelToReverb = 40 / 127 * EFX_SENDS_GAIN_CORRECTION;
19798
19819
  this.insertionProcessor.sendLevelToChorus = 0;
19799
19820
  this.insertionProcessor.sendLevelToDelay = 0;
19800
- this.resetInsertionParams();
19801
19821
  this.callEvent("effectChange", {
19802
19822
  effect: "insertion",
19803
19823
  parameter: 0,