Skip to content

Conversation

@flexiondotorg
Copy link
Contributor

Summary

Consolidate and extract spectral metric accumulation from the analyzer into shared helpers to reduce duplication and simplify future changes.

Changes

  • Extract spectral accumulation logic into a helper method in internal/processor/analyzer.go
  • Remove legacy numeric and helper functions and unify numeric helpers
  • Extract astats metadata handling into a processor helper
  • Extract shared subregion refinement logic into helper
  • Extract logging table helpers for three-column metric tables in internal/logging/report.go

Testing

  • Ran existing unit tests with just test

Related Issues

- 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>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@flexiondotorg flexiondotorg merged commit 5f940c7 into main Feb 6, 2026
5 checks passed
@flexiondotorg flexiondotorg deleted the cleanup branch February 6, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant