@vessel-dsp/runtime 0.16.2 → 0.18.0

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.
Binary file
@@ -1483,7 +1483,6 @@ var GMIN_STEPPING_START_SIEMENS = 0.01;
1483
1483
  var GMIN_STEPPING_RATIO = 10;
1484
1484
  var DC_INDUCTOR_SHORT_OHMS = 0.01;
1485
1485
  var OPAMP_MAX_DIFFERENTIAL_STEP = 4;
1486
- var OPAMP_SATURATION_BAND = 8;
1487
1486
  var OPAMP_DIFFERENTIAL_BAND = 12;
1488
1487
  var OPAMP_FOLD_STREAK = 6;
1489
1488
  function opAmpHalfSwing(railHigh, railLow) {
@@ -1498,6 +1497,12 @@ function boundOpAmpRaw(raw, halfSwing) {
1498
1497
  const limit = OPAMP_POLE_BAND * halfSwing;
1499
1498
  return Math.min(limit, Math.max(-limit, raw));
1500
1499
  }
1500
+ function tanhOneExp(x) {
1501
+ if (x > 354) return 1;
1502
+ if (x < -354) return -1;
1503
+ const e = Math.exp(2 * x);
1504
+ return 1 - 2 / (1 + e);
1505
+ }
1501
1506
  var MODULATION_SCALE_MIN = 0.5;
1502
1507
  var MODULATION_SCALE_MAX = 2;
1503
1508
  var MODULATION_DC_SECONDS = 10;
@@ -6082,12 +6087,9 @@ var ReferenceRuntime = class {
6082
6087
  halfSwing
6083
6088
  );
6084
6089
  const scaled = raw / halfSwing;
6085
- const shape = Math.tanh(scaled);
6090
+ const shape = tanhOneExp(scaled);
6086
6091
  const output = centre + halfSwing * shape;
6087
- const derivativeShape = Math.tanh(
6088
- clamp(scaled, -OPAMP_SATURATION_BAND, OPAMP_SATURATION_BAND)
6089
- );
6090
- const slope = effectiveGain * (1 - derivativeShape * derivativeShape);
6092
+ const slope = effectiveGain * (1 - shape * shape);
6091
6093
  const linearisedAt = limited ? differential : rawDifferential;
6092
6094
  matrix[row][stamp.output] += 1;
6093
6095
  matrix[row][stamp.plus] -= slope;
@@ -6140,9 +6142,8 @@ var ReferenceRuntime = class {
6140
6142
  rhs[stamp.vee] = (rhs[stamp.vee] ?? 0) + iAbcResidual;
6141
6143
  }
6142
6144
  if (iAbc > 0) {
6143
- const tanhVal = Math.tanh(vDiff / (2 * vt));
6144
- const sechVal = 1 / Math.cosh(vDiff / (2 * vt));
6145
- const sech2 = sechVal * sechVal;
6145
+ const tanhVal = tanhOneExp(vDiff / (2 * vt));
6146
+ const sech2 = 1 - tanhVal * tanhVal;
6146
6147
  const iOut = 2 * iAbc * tanhVal;
6147
6148
  const gDiff = iAbc / vt * sech2;
6148
6149
  const gBiasCtrl = 2 * gBias * tanhVal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vessel-dsp/runtime",
3
- "version": "0.16.2",
3
+ "version": "0.18.0",
4
4
  "description": "Real-time MNA simulation runtime and solver console for VesselDSP Program ROMs.",
5
5
  "keywords": [
6
6
  "guitar-pedal",
@@ -58,7 +58,7 @@
58
58
  "generate-kernels": "bun scripts/generate-kernels.ts"
59
59
  },
60
60
  "dependencies": {
61
- "@vessel-dsp/compiler": "0.21.1"
61
+ "@vessel-dsp/compiler": "0.22.0"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"