Give the audio quality rules a single home - #6
Merged
Conversation
Kentarohakase
force-pushed
the
build/shared-properties-and-coverage
branch
from
August 12, 2026 00:56
876c30f to
ad373ef
Compare
Kentarohakase
force-pushed
the
refactor/shared-audio-thresholds
branch
from
August 12, 2026 00:56
eab2d29 to
57aef9c
Compare
Kentarohakase
force-pushed
the
build/shared-properties-and-coverage
branch
from
August 12, 2026 01:06
ad373ef to
ffc4ba1
Compare
The numbers that decide when audio counts as weak were written out four times: in the analysis scoring, in the profile advice, in the result validation and in the view model warnings. Each copy carried the same bitrate bounds, the same sample rate bound, the same headroom limit and the same loudness band. Changing one of them would have made the interface contradict itself - the warning strip saying one thing, the analysis report another - with nothing to catch it. They move into AudioQualityThresholds as named constants with the checks built on them, and the four call sites now ask that type instead of repeating the comparison. The rules themselves are unchanged, which the existing analysis, advice and validation tests confirm; the new tests pin the boundaries so a later change to a number is a deliberate one. Two details the copies had already agreed on are now stated once: low headroom excludes actual clipping, because clipping is reported on its own and would otherwise appear twice, and the two loudness bands cannot overlap.
Kentarohakase
changed the base branch from
build/shared-properties-and-coverage
to
main
August 12, 2026 01:08
Kentarohakase
force-pushed
the
refactor/shared-audio-thresholds
branch
from
August 12, 2026 01:08
57aef9c to
153c588
Compare
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.
Stacked on #5. The last open item from the improvement plan.
The problem
The numbers that decide when audio counts as weak were written out four times:
AudioAnalysisInsightService.cs:22-84AudioProfileAdvisorService.cs:22-30AudioValidationService.cs:315-323MainViewModel.Insights.cs:55-88Each copy carried the same bitrate bounds (96 000 mono / 128 000 otherwise), the same sample-rate bound (32 000), the same headroom limit (−1.0 dB) and the same loudness band (−28 / −9 LUFS). Changing one of them would have made the application contradict itself — the warning strip saying one thing and the analysis report another — with no test to catch it, because each site was tested against its own copy of the number.
They happened to agree today. That is the point at which to merge them, not after they have drifted.
The change
Services/AudioQualityThresholds.csholds the constants and the checks built on them. The four call sites ask that type instead of repeating the comparison, andAudioProfileAdvisorService.HasLowBitrateis gone since it was that check verbatim.Two invariants the copies already agreed on are now stated once instead of being re-derived at each site:
else iffor this; now the predicate carries it.Net: 24 lines added, 45 removed across the four call sites.
Why this is behaviour preserving
The rules are unchanged, and the existing suite already covers them from every side —
AudioAnalysisInsightServiceTests(12 scoring cases),AudioProfileAdvisorServiceTests(7 advice cases) andAudioValidationServiceTests(18 report cases). All of them pass untouched.The 26 new tests in
AudioQualityThresholdsTestspin the boundaries themselves — 95 999 vs 96 000, 31 999 vs 32 000, −1.1 vs −1.0 — so a later change to one of those numbers has to be deliberate rather than accidental.Verification
No changelog entry
Nothing changes for a user of the application: the same audio produces the same findings, the same advice and the same warnings as before.