fix: improve metadata frame detection and update version to v0.12.1
This commit is contained in:
+8
-4
@@ -1574,7 +1574,10 @@ function _buildWaveformCharts(data, chartsEl, emptyEl, chartsStore) {
|
||||
return;
|
||||
}
|
||||
|
||||
const times = Array.from({length: decoded}, (_, i) => ((i - pretrig) / sr * 1000).toFixed(2));
|
||||
// Clip to configured record window — device streams extra zero-padded frames
|
||||
// beyond total_samples; showing them just adds a flat tail to every chart.
|
||||
const display = data.total_samples ? Math.min(data.total_samples, decoded) : decoded;
|
||||
const times = Array.from({length: display}, (_, i) => ((i - pretrig) / sr * 1000).toFixed(2));
|
||||
if (emptyEl) emptyEl.style.display = 'none';
|
||||
chartsEl.style.display = 'flex';
|
||||
chartsEl.style.flexDirection = 'column';
|
||||
@@ -1592,7 +1595,7 @@ function _buildWaveformCharts(data, chartsEl, emptyEl, chartsStore) {
|
||||
|
||||
if (isGeo) {
|
||||
const scale = geoRange / 32767;
|
||||
plotData = samples.map(s => s * scale);
|
||||
plotData = samples.slice(0, display).map(s => s * scale);
|
||||
// Use the device-recorded peak from the 0C waveform record — authoritative
|
||||
// and matches Blastware. Computing from raw samples can catch rogue
|
||||
// near-full-scale values from decoding artifacts.
|
||||
@@ -1603,9 +1606,10 @@ function _buildWaveformCharts(data, chartsEl, emptyEl, chartsStore) {
|
||||
ttFmt = v => `${ch}: ${v.toFixed(5)} in/s`;
|
||||
tickFmt = v => v.toFixed(4);
|
||||
} else {
|
||||
const peakCounts = Math.max(...samples.map(Math.abs));
|
||||
const clippedMic = samples.slice(0, display);
|
||||
const peakCounts = Math.max(...clippedMic.map(Math.abs));
|
||||
const micScale = (micPeakPsi !== null && peakCounts > 0) ? Math.abs(micPeakPsi) / peakCounts : 1.0;
|
||||
plotData = samples.map(s => s * micScale);
|
||||
plotData = clippedMic.map(s => s * micScale);
|
||||
const peakPsi = Math.max(...plotData.map(Math.abs));
|
||||
const peakDbl = peakPsi > 0 ? 20 * Math.log10(peakPsi / DBL_REF) : -Infinity;
|
||||
peakLabel = `${peakDbl.toFixed(1)} dBL`;
|
||||
|
||||
Reference in New Issue
Block a user