mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
refactor(player): E.3 — extract waveform/normalization/seek pure helpers (#566)
Three small tranches out of playerStore.ts: - src/utils/waveformParse.ts — waveformBlobLenOk + coerceWaveformBins (the parser that handles number[] / Uint8Array / ArrayLike payloads Rust serializes as). - src/utils/normalizationCompare.ts — normalizationAlmostEqual (tolerant null-aware dB comparison). - src/utils/seekErrors.ts — isRecoverableSeekError (retry classifier for the Rust seek pipeline). Each gets focused unit tests. All four were file-private, no external callers — pure code move. playerStore 3556 → 3516 LOC.
This commit is contained in:
committed by
GitHub
parent
1521e4ea8f
commit
d24514d67e
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Tolerant equality for normalization gain values. Both arguments may be null
|
||||
* (meaning "no override / unknown"); two nulls compare equal, mixed null/number
|
||||
* does not. Default epsilon (0.12 dB) is the threshold below which the audible
|
||||
* difference is negligible — used to skip UI updates that would otherwise jitter
|
||||
* on every analysis-cache refresh.
|
||||
*/
|
||||
export function normalizationAlmostEqual(a: number | null, b: number | null, eps = 0.12): boolean {
|
||||
if (a == null && b == null) return true;
|
||||
if (a == null || b == null) return false;
|
||||
return Math.abs(a - b) <= eps;
|
||||
}
|
||||
Reference in New Issue
Block a user