refactor(processor): consolidate spectral averaging and extract region pair construction#61
Merged
flexiondotorg merged 3 commits intomainfrom Mar 16, 2026
Merged
refactor(processor): consolidate spectral averaging and extract region pair construction#61flexiondotorg merged 3 commits intomainfrom
flexiondotorg merged 3 commits intomainfrom
Conversation
…tral and writeSpectralTo methods - Add finalizeSpectral() method to calculate and return averaged spectral metrics - Add writeSpectralTo() method to map spectral metrics to BaseMeasurements fields - Replace two 16-line spectral averaging blocks with single method calls in AnalyzeAudio and finalizeOutputMeasurements - Add comprehensive test coverage for spectral finalization Signed-off-by: Martin Wimpress <code@wimpress.io>
…unction - Add extractRegionPair function in analyzer_output.go to build optional SilenceRegion and SpeechRegion pointers from AudioMeasurements profiles - Replace duplicate 17-line region construction blocks in processor.go and normalise.go with single-line extractRegionPair calls - Add comprehensive test coverage for region pair extraction logic Signed-off-by: Martin Wimpress <code@wimpress.io>
- Remove post-declaration reset() call from AnalyzeAudio; struct zero values suffice for all fields except truePeakMax and samplePeakMax - Collapse reset() body from 28 lines to 3 lines using struct literal initialization This reduces unnecessary initialization overhead and improves code clarity by relying on Go's zero-value semantics. Signed-off-by: Martin Wimpress <code@wimpress.io>
Contributor
There was a problem hiding this comment.
No issues found across 7 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: This is a code refactor that moves and reorganizes logic across multiple files in the processor package, which is explicitly classified as high-impact and requires human review.
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
Refactors the processor package to improve code reuse and clarity. These changes consolidate spectral-averaging logic into dedicated methods and extract repeated region pair construction into a single reusable function, reducing duplication and making the intent of the code more apparent.
Changes
Testing