fix(decode): Blastware's mic dB offset is 81.9384, a hair above exact 0.25 Pa

The checker caught 280 regressions in the first mic fix: every one a dB
value at count 129, where 20 log10(129 x 0.25 Pa / 20 uPa) = 124.149997
rounds to 124.1 and Blastware prints 124.2.  Blastware's dB offset sits in
[81.9383, 81.9385] -- any value there matches its dB(L) on 1,729,252 /
1,729,253 DL2 intervals (the last printed '0.000'); exact 81.93820 rounds
count 129 down, and the old 81.94 misses counts 119 and 132.  Single
precision does not explain it.  psi keeps 0.25 Pa per count, which
matches every interval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-31 01:55:45 -04:00
1 parent 5644dbd5ad
commit 18951505f0
2 files changed
+14 -7

No files matched your search

+13 -7
View File
@@ -630,20 +630,26 @@ def decoded_to_adc_counts(decoded: dict) -> dict:
# One MicL count is 0.25 Pa (measured 2026-10-31): count x 0.25 Pa matches
# Blastware's "MicL Peak psi(L)" on all 1,729,253 DL2 histogram intervals
# checked, and 20 log10(count x 0.25 Pa / 20 uPa) its dB(L) on all but 17
# exact half-way cases. The dB offset below is that, 81.938 -- not the 81.94
# first fitted to a handful of values, which missed 49 of those intervals.
# checked.
MIC_PA_PER_COUNT = 0.25
_MIC_DB_REF = 20.0 * math.log10(MIC_PA_PER_COUNT / 20e-6)
# Blastware's dB(L) offset sits a hair above the exact 20 log10(0.25 Pa /
# 20 uPa) = 81.93820: any value in [81.9383, 81.9385] matches its dB on
# 1,729,252 / 1,729,253 intervals (the one left printed "0.000"), while
# 81.93820 rounds count 129 (162 intervals) to 124.1 against Blastware's
# 124.2, and the 81.94 first fitted to a handful of values misses counts 119
# and 132. Its display chain presumably carries rounded constants; the
# window, not the physics, is what is measured.
_MIC_DB_REF = 81.9384
def mic_count_to_db(count: int) -> float:
"""Convert a MicL ADC count to dB(L) for BW-display-compatible output.
dB = sign(count) × (20 log10(0.25 Pa / 20 µPa) + 20 × log10(|count|))
= sign(count) × (81.938 + 20 × log10(|count|)) for |count| ≥ 1
dB = 0.0 for count == 0
dB = sign(count) × (81.9384 + 20 × log10(|count|)) for |count| ≥ 1
dB = 0.0 for count == 0
81.9384 ≈ 20 log10(0.25 Pa / 20 µPa); see _MIC_DB_REF.
count=±1 → ±81.94 dB; count=813 → 140.14 dB (the V70 fixture).
"""
if count == 0:
+1
View File
@@ -194,6 +194,7 @@ from minimateplus.waveform_codec import mic_count_to_db # noqa: E402
(1, "81.94"), # XML sample cell
(119, "123.4"), # Blastware interval tables, where 81.94 + 20 log10 gave 123.451
(132, "124.3"), # ... and 124.351
(129, "124.2"), # 162 intervals; exactly 0.25 Pa gives 124.149997, a hair under half-way
(813, "140.14"), # V70 fixture, Blastware display
])
def test_mic_db_matches_blastware(count, printed):