@vessel-dsp/runtime 0.6.3 → 0.7.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
@@ -1360,6 +1360,41 @@ function reverbCombGain(delaySeconds, decaySeconds) {
1360
1360
  return Math.min(0.999, 10 ** (-3 * delaySeconds / decaySeconds));
1361
1361
  }
1362
1362
  var DEFAULT_NEWTON_MAX_ITERATIONS = 1024;
1363
+ function ldrTableResistanceOhms(currentsAmps, ohms, currentAmps, minOhms, maxOhms) {
1364
+ if (!(currentAmps > 0)) {
1365
+ return maxOhms;
1366
+ }
1367
+ const n = currentsAmps.length;
1368
+ let lo = 0;
1369
+ let hi = 1;
1370
+ if (currentAmps <= currentsAmps[0]) {
1371
+ lo = 0;
1372
+ hi = 1;
1373
+ } else if (currentAmps >= currentsAmps[n - 1]) {
1374
+ lo = n - 2;
1375
+ hi = n - 1;
1376
+ } else {
1377
+ for (let i = 0; i < n - 1; i++) {
1378
+ if (currentAmps >= currentsAmps[i] && currentAmps <= currentsAmps[i + 1]) {
1379
+ lo = i;
1380
+ hi = i + 1;
1381
+ break;
1382
+ }
1383
+ }
1384
+ }
1385
+ const iA = currentsAmps[lo];
1386
+ const iB = currentsAmps[hi];
1387
+ const rA = ohms[lo];
1388
+ const rB = ohms[hi];
1389
+ const lnI = Math.log(currentAmps);
1390
+ const lnI0 = Math.log(iA);
1391
+ const lnI1 = Math.log(iB);
1392
+ const lnR0 = Math.log(rA);
1393
+ const lnR1 = Math.log(rB);
1394
+ const slope = (lnR1 - lnR0) / (lnI1 - lnI0);
1395
+ const raw = Math.exp(lnR0 + (lnI - lnI0) * slope);
1396
+ return Math.min(Math.max(raw, minOhms), maxOhms);
1397
+ }
1363
1398
  var NEWTON_UNPRODUCTIVE_ITERATIONS = 64;
1364
1399
  var NEWTON_UNPRODUCTIVE_PROBATION_SAMPLES = 1024;
1365
1400
  var NEWTON_RELATIVE_TOLERANCE = 1e-3;
@@ -5376,7 +5411,15 @@ var ReferenceRuntime = class {
5376
5411
  rhs[stamp.ledCathode] = (rhs[stamp.ledCathode] ?? 0) + ledEquivalent;
5377
5412
  const alpha = 1e3;
5378
5413
  let rLdr;
5379
- if (stamp.ldrPowerLawCoefficientOhms !== void 0 && stamp.ldrPowerLawExponent !== void 0) {
5414
+ if (stamp.ldrTableCurrentAmps !== void 0 && stamp.ldrTableOhms !== void 0 && stamp.ldrTableCurrentAmps.length === stamp.ldrTableOhms.length && stamp.ldrTableCurrentAmps.length >= 2) {
5415
+ rLdr = ldrTableResistanceOhms(
5416
+ stamp.ldrTableCurrentAmps,
5417
+ stamp.ldrTableOhms,
5418
+ ledCurrent,
5419
+ stamp.ldrMinOhms,
5420
+ stamp.ldrMaxOhms
5421
+ );
5422
+ } else if (stamp.ldrPowerLawCoefficientOhms !== void 0 && stamp.ldrPowerLawExponent !== void 0) {
5380
5423
  const powerLawCurrent = Math.max(ledCurrent, 0);
5381
5424
  const raw = stamp.ldrPowerLawCoefficientOhms * Math.pow(powerLawCurrent, stamp.ldrPowerLawExponent);
5382
5425
  rLdr = Math.min(Math.max(raw, stamp.ldrMinOhms), stamp.ldrMaxOhms);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vessel-dsp/runtime",
3
- "version": "0.6.3",
3
+ "version": "0.7.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.8.1"
61
+ "@vessel-dsp/compiler": "0.9.0"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"