Repository navigation
[patch] Keep NormalizedParameter.Normalize in [0, 1] for out-of-domain values and reject empty ranges - #412
Merged
Conversation
…n values and reject empty ranges Normalize relied on Math.Clamp, which passes NaN through, so a value at or below zero on a logarithmic range returned NaN for double and threw OverflowException for decimal. Such a value now maps to the nearer end (the one with the smaller magnitude), and any remaining NaN maps to 0. Linear, Skewed and Logarithmic now reject min == max, which used to reach the same NaN path. Fixes #319 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A5MkmzQ4qxxRmHStdQ8oJA
|
This was referenced Oct 9, 2026
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.



Fixes #319
What changed
NormalizedParameter<T>.Normalizerelied onMath.Clamp, which passes NaN straight through. The result:Logarithmic(20, 20000).Normalize(-5)returned NaN fordoubledecimalversion threwOverflowExceptionLinear(1, 1)produced NaN as wellChanges:
20..20000, and 1 for a falling20000..20range.shapedvalue maps to 0 before clamping, so the host always gets a position in[0, 1].Linear,SkewedandLogarithmicrejectmin == maxwithArgumentOutOfRangeException, as the triage suggested, so the misconfiguration shows up where it is made.WithCenteralready rejected it. No caller in the repository builds a zero-width range.Tests
The four new tests in
AudioEngineeringTestsall failed before the fix and pass after it:decimaloverflow caseFull
Semantics.Teston net10.0: 1484 passed, 8 skipped, 0 failed. The local Sonar build (.sonarlint/sonar-local.props) reports nothing on the changed file.🤖 Generated with Claude Code
https://claude.ai/code/session_01A5MkmzQ4qxxRmHStdQ8oJA
Generated by Claude Code