Rewrite the code comments for consistent tone and accuracy

Comments only: the tokens of every Go file are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 19:08:00 +00:00
co-authored by Claude Sonnet 5.5
parent 41f752e1c1
commit 158661eefe
27 changed files with 716 additions and 437 deletions
+20 -16
View File
@@ -17,7 +17,7 @@ type CurvePoint struct {
Gain float64 `json:"gain" doc:"How much of its level the velocity plays." minimum:"0" maximum:"1"`
}
// The curves of a crossfade.
// The values of [Crossfade.Curve].
const (
CrossfadePower = "power"
CrossfadeGain = "gain"
@@ -36,7 +36,7 @@ type Crossfade struct {
Curve string `json:"curve" doc:"How the level changes through the fade: power, which keeps the loudness steady through a crossfade between regions, or gain, which fades the level in a straight line."`
}
// Where a condition's value comes from.
// The values of [Condition.Source].
const (
SourceController = "cc"
SourceBend = "bend"
@@ -65,7 +65,7 @@ type Keyswitch struct {
Up *int `json:"up,omitempty" doc:"A keyswitch key that must not be held, or nil if the region doesn't depend on it."`
}
// The settings a controller moves, as a modulation names them.
// The values of [Modulation.Target], the settings that a controller moves.
const (
TargetAmplitude = "amplitude"
TargetVolume = "volume"
@@ -74,8 +74,8 @@ const (
TargetTune = "tune"
)
// CurveStop is a point of a custom curve: the controller at one of the values
// 0 to 127, and the result there.
// CurveStop is a point of a custom curve: the result of the curve at one of
// the controller values 0 to 127.
type CurveStop struct {
At int `json:"at" doc:"The controller value the point is at." minimum:"0" maximum:"127"`
Value float64 `json:"value" doc:"The result of the curve at that value."`
@@ -96,8 +96,8 @@ type Modulation struct {
Points []CurveStop `json:"points,omitempty" doc:"The points of a custom curve, which pass through straight lines, or none for a built-in curve."`
}
// Control is a controller an instrument uses, with the name its SFZ gives it,
// and its starting value from 0 to 1.
// Control is a controller that an instrument uses, with the name its SFZ gives
// it and its starting value, from 0 to 1.
type Control struct {
Controller int `json:"controller" doc:"The controller number." minimum:"0" maximum:"127"`
Label string `json:"label,omitempty" doc:"The name the instrument gives the controller."`
@@ -112,7 +112,7 @@ type KeyswitchRange struct {
Default *int `json:"default,omitempty" doc:"The keyswitch that is active before any is pressed, or nil if there is none."`
}
// DefaultEnvelope is the envelope of a region that sets none: it plays at full
// DefaultEnvelope is the envelope of a region that sets none. It plays at full
// level at once, and stops almost at once when its note ends.
var DefaultEnvelope = Envelope{Sustain: 100, Release: defaultRelease}
@@ -209,7 +209,8 @@ type Region struct {
}
// Instrument is an SFZ instrument as typed regions, with its settings taken at
// the starting controller values.
// the starting controller values. One read from a document remembers where each
// region came from, so that [Instrument.Apply] can change the document.
type Instrument struct {
Regions []Region `json:"regions" doc:"The regions that the typed model has, in the order of the file."`
// Unread counts, for each opcode or header the typed model has no field
@@ -222,13 +223,15 @@ type Instrument struct {
// Keyswitches are its keyswitch keys, or nil if it has none.
Keyswitches *KeyswitchRange `json:"keyswitches,omitempty" doc:"The keys that are keyswitches, or nil if the instrument has none."`
// sources are the flattened regions that the typed ones were read from, in
// the same order, and eval reads a region from opcodes as they were.
// sources are the flattened regions that Regions were read from, in the same
// order.
sources []FlatRegion
eval evaluator
// eval reads a region from opcodes, as when the regions were read.
eval evaluator
}
// Reasons a region is skipped: the typed model has no region for it.
// The keys of [Instrument.Skipped], the reasons that a region has no typed
// region.
const (
SkippedNoSample = "no sample file"
SkippedGenerated = "a generated sound"
@@ -236,7 +239,8 @@ const (
SkippedNotKeys = "not played by keys"
)
// Region defaults that SFZ gives.
// The defaults that SFZ gives a region, for the settings that the typed model
// has no zero value for.
const (
defaultRootKey = 60
// defaultLowVelocity is 1, as velocity 0 is a note-off.
@@ -245,8 +249,8 @@ const (
defaultRelease = 0.001
defaultTrigger = "attack"
// defaultOffMode is how a region stops when its group's voice limit or
// another group stops it, and defaultOffTime how long that takes when the
// mode is time, in seconds.
// another group stops it, and defaultOffTime is how long that takes, in
// seconds, when the mode is time.
defaultOffMode = "fast"
defaultOffTime = 0.006
)