refactor(processor): consolidate spectral metric accumulation in analyzer#35
Merged
flexiondotorg merged 6 commits intomainfrom Feb 6, 2026
Merged
refactor(processor): consolidate spectral metric accumulation in analyzer#35flexiondotorg merged 6 commits intomainfrom
flexiondotorg merged 6 commits intomainfrom
Conversation
- Remove legacy/unused helpers and diagnostic placeholders: - delete formatNormalisationResult, writeDiagnosticAdaptive, joinWithComma - remove calculateLUFSGap, lerp, clampFloat, and SilenceAnalysis type - drop legacy Entropy fields used only for backwards compatibility - Standardise numeric helper usage in analyzer: - replace ad-hoc 20*log10(...) conversions with linearRatioToDB - replace clampFloat calls with shared clamp(...) helper - Trim obsolete diagnostics from internal/logging/report.go and remove placeholder adaptive diagnostics in adaptive.go Signed-off-by: Martin Wimpress <martin@wimpress.org>
- Add baseMetadataAccumulators.accumulateSpectral to centralise spectral accumulation logic - Replace duplicated accumulation blocks in extractFrameMetadata and extractOutputFrameMetadata with a call to the new helper - Reduce code duplication and improve maintainability; no functional change Signed-off-by: Martin Wimpress <martin@wimpress.org>
- Add baseMetadataAccumulators.extractAstatsMetadata to centralise astats parsing - Move duplicated astats extraction and conversions into the new helper - convert CrestFactor from linear ratio to dB - convert MinLevel/MaxLevel from linear samples to dBFS - Replace inline extraction in extractFrameMetadata and extractOutputFrameMetadata - Reduce duplication and improve maintainability; no behavioural change Signed-off-by: Martin Wimpress <martin@wimpress.org>
- Add refineToSubregion(...) — a generalized sliding-window refinement that accepts window sizes, a scoring function and a comparator to pick the best candidate. - Replace duplicate logic in refineToGoldenSubregion and refineToGoldenSpeechSubregion so both now call the new helper. - Preserve behaviour and early-exit semantics: original region is returned when refinement isn't possible (insufficient intervals or already within target). - Simplify interval/window calculations and reduce duplicated code paths, improving maintainability. Signed-off-by: Martin Wimpress <martin@wimpress.org>
…yzer - Replace many individual spectral-sum variables with a single spectralMetrics struct - Add IntervalSample.spectralFields(), spectralMetrics.add() and spectralMetrics.average() - Update measureSilenceCandidateFromIntervals and measureSpeechCandidateFromIntervals to accumulate and average spectral metrics via the new helpers - Improve readability, reduce duplication and risk of copy/paste errors No behaviour change; refactor only. Signed-off-by: Martin Wimpress <martin@wimpress.org>
- Add threeColMetricSpec, noiseFloorFormatter, and valOr helpers to reduce repetition when rendering Input/Filtered/Final metric columns. - Implement addNoiseFloorMetricRows and addSpeechMetricRows and use concise value selector helpers (v / sv) to build metric slices. - Replace large, repetitive blocks in writeNoiseFloorTable and writeSpeechRegionTable with the new helpers. - Preserve existing behaviour and formatting (no functional change); improves readability and maintainability. Signed-off-by: Martin Wimpress <martin@wimpress.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidate and extract spectral metric accumulation from the analyzer into shared helpers to reduce duplication and simplify future changes.
Changes
Testing
just testRelated Issues