From 3265ad6fa34a148405f9bf9cdac1aacb04311421 Mon Sep 17 00:00:00 2001 From: serversdown Date: Wed, 20 May 2026 05:43:52 +0000 Subject: [PATCH] fix: apply psi dbL conversion rule --- sfm/sfm_webapp.html | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/sfm/sfm_webapp.html b/sfm/sfm_webapp.html index 7925c83..019f900 100644 --- a/sfm/sfm_webapp.html +++ b/sfm/sfm_webapp.html @@ -2392,6 +2392,11 @@ async function loadHistory() { ${(() => { const m = ev.mic_ppv == null ? null : Number(ev.mic_ppv); if (m == null || !isFinite(m) || m <= 0) return '—'; + // BW (.AB0*/.N00) stores mic_ppv as psi → convert to dBL. + // Thor IDF (.IDFH/.IDFW) already stores dBL → display directly. + const fn = (ev.blastware_filename || '').toUpperCase(); + const isThor = fn.endsWith('.IDFH') || fn.endsWith('.IDFW'); + if (isThor) return m.toFixed(1) + ' dBL'; return (20 * Math.log10(m / DBL_REF)).toFixed(1) + ' dBL'; })()} ${ev.project ?? '—'} @@ -2454,11 +2459,20 @@ function _renderSidecar(data) { document.getElementById('sc-title').textContent = `Event — ${bw.filename || ev.waveform_key || 'unknown'}`; - const fmtPpv = v => (v == null ? '—' : Number(v).toFixed(5) + ' in/s'); + const fmtPpv = v => { + if (v == null) return '—'; + const n = Number(v); + return isFinite(n) ? n.toFixed(5) + ' in/s' : String(v); + }; const fmtMic = v => { - if (v == null || v <= 0) return '—'; - const dbl = 20 * Math.log10(v / DBL_REF); - return `${dbl.toFixed(1)} dBL (${v.toExponential(2)} psi)`; + if (v == null) return '—'; + const n = Number(v); + if (!isFinite(n) || n <= 0) return '—'; + // Source-aware: Thor IDF imports store mic as dB(L); BW imports store + // it as psi. `src` is in the outer scope from _renderSidecar(). + if ((src.kind || '') === 'idf-import') return `${n.toFixed(1)} dBL`; + const dbl = 20 * Math.log10(n / DBL_REF); + return `${dbl.toFixed(1)} dBL (${n.toExponential(2)} psi)`; }; document.getElementById('sc-f-serial').textContent = ev.serial || '—';