Metadata-generate the logarithmic scales; fold Percent/Gain into the linear metadata#95
Merged
Merged
Conversation
…hmic.json
Logarithmic quantities (decibel levels, pitch intervals, pH) now have a
metadata source of truth. Each logarithmic.json entry generates a
standalone readonly partial record struct built around
scale = multiplier · log_base(linear / reference): the raw-scalar
factory, From{Linear}/To{Linear} conversions against the linear
generated counterpart (with optional name overrides and a
PhysicalConstants- or literal-backed reference), optional log-space
+/- arithmetic, comparisons, and culture-invariant ToString.
Bespoke members that don't fit the schema (named constants,
cross-scale conversions, raw-T conveniences) live in hand-written
partials — QuantitiesGenerator now emits partial records throughout so
generated quantities can carry such companions too.
SEM005 flags missing/duplicate scale names and conversions with no
linear type.
https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
- SoundPressureLevel, SoundIntensityLevel, SoundPowerLevel: fully generated from logarithmic.json; hand-written files deleted. - Decibels, Cents, Semitones, DirectionalityIndex, PH: cores generated; the hand-written files shrink to bespoke partials (Unity, Unison, Octave, Omnidirectional, Neutral/ToPOH/IsAcidic/IsBasic, raw-T FromAmplitude/FromPower, Cents<->Semitones). - Percent: was a standalone struct; now a unit of the Dimensionless dimension — Ratio.FromPercent(50) == 0.5, ratio.In(Units.Percent). - Gain: was a standalone struct; now a generated semantic overload of Ratio (non-negative V0, widens implicitly), with Unity/Silence, the Decibels conversions, and cascading * kept in a partial. - Decibels gains FromPowerRatio(Ratio<T>) alongside the raw-T conveniences; FromGain/ToAmplitude/ToPower are now generated. Generated snapshots refreshed (all quantity records are now partial). https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
Updates resolved decision #5 in CLAUDE.md (logarithmic.json + partials, SEM005), adds the 'adding a logarithmic scale' walk-through to physics-generator.md, and refreshes the migration guide rows for Percent (now a Dimensionless unit) and Gain (now a Ratio overload). https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
|
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
Converges the remaining hand-written quantity surface onto metadata, per the "metadata is the source of truth" direction.
1.
PercentandGainfold into the linear metadataPercentwas a standalone struct; it's now a unit of the Dimensionless dimension (PercentToRatio= 0.01):Ratio<double>.FromPercent(50)→ 0.5,ratio.In(Units.Percent)→ 50. The struct is deleted.Gainwas a standalone struct; it's now a generated semantic overload ofRatioindimensions.json— non-negative V0, widens implicitly toRatio.Unity,Silence, theDecibelsconversions, and cascading*live in a hand-written partial.2.
LogarithmicScalesGenerator— log scales fromlogarithmic.jsonA new generator + metadata file gives the logarithmic family a single source of truth. Each entry generates a
readonly partial record structaroundscale = multiplier · log_base(linear / reference): scalar factory,From{Linear}/To{Linear}conversions (name-overridable, withPhysicalConstants- or literal-backed references), optional log-space+/−, comparisons, and invariantToString. SEM005 validates the schema.SoundPressureLevel,SoundIntensityLevel,SoundPowerLevelDecibels,Cents,Semitones,DirectionalityIndex,PHUnity,Unison,Octave,Omnidirectional,Neutral/ToPOH/acidity checks, raw-Tconveniences,Cents↔Semitones) remain in small partialsTo support the partial-companion pattern,
QuantitiesGeneratornow emitspartialrecords throughout.Scorecard
Before this PR the audio/log family was ~10 hand-written types (~1100 lines). After: 2 genuinely bespoke types (
NormalizedParameter,QFactor— not quantities, no metadata shape) plus 5 thin partials; everything else comes fromdimensions.json/logarithmic.json. Resolved decision #5 in CLAUDE.md is amended accordingly,physics-generator.mdgains an "adding a logarithmic scale" walk-through, and the migration guide covers thePercent/Gainchanges.Behavioral notes
Gainis now a record class (like all generated quantities) and non-negative via the guardedFrom{Unit}factories — polarity inversion was never representable in its dB interop anyway.Decibelsadditionally gainsFromPowerRatio(Ratio<T>).Testing
*,FromPowerRatio);RatioPercent_RoundTriprewired to the unit-based API.https://claude.ai/code/session_01AUgbNJjDBDCwcbUfPK3pGW
Generated by Claude Code