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
+15 -14
View File
@@ -8,15 +8,16 @@ import (
"strings"
)
// noteRE reads a note name such as c4, C#0 or eb-1. Middle C is c4, MIDI
// note 60.
// noteRE reads a note name such as c4, C#0 or eb-1, as the letter, the sharp
// or flat if any, and the octave. Middle C is c4, MIDI note 60.
var noteRE = regexp.MustCompile(`^([A-Ga-g])([#b]?)(-?[0-9]+)$`)
// semitones are the notes' places in the octave from C.
// semitones are how many semitones each natural note is above C, by the
// note's lowercase letter.
var semitones = map[byte]int{'c': 0, 'd': 2, 'e': 4, 'f': 5, 'g': 7, 'a': 9, 'b': 11}
// parseNote reads a MIDI note number or a note name. It reports false if the
// value is neither.
// parseNote reads a MIDI note number or a note name, and reports whether v was
// one.
func parseNote(v string) (int, bool) {
v = strings.TrimSpace(v)
if n, err := strconv.Atoi(v); err == nil {
@@ -37,7 +38,7 @@ func parseNote(v string) (int, bool) {
return n, true
}
// parseNumber reads a number, and reports false if the value isn't one.
// parseNumber reads a finite number, and reports whether v was one.
func parseNumber(v string) (float64, bool) {
f, err := strconv.ParseFloat(strings.TrimSpace(v), 64)
if err != nil || math.IsNaN(f) || math.IsInf(f, 0) {
@@ -46,11 +47,11 @@ func parseNumber(v string) (float64, bool) {
return f, true
}
// curve maps a controller's value, from 0 to 1, to how much of a
// modulation's depth applies.
// curve maps a controller's value, from 0 to 1, to how much of a modulation's
// depth applies.
type curve func(x float64) float64
// builtinCurves are the curves SFZ players define, by index.
// builtinCurves are the curves that SFZ players define, by index.
var builtinCurves = map[int]curve{
0: func(x float64) float64 { return x },
1: func(x float64) float64 { return 2*x - 1 },
@@ -61,14 +62,14 @@ var builtinCurves = map[int]curve{
6: func(x float64) float64 { return math.Sqrt(1 - x) },
}
// pointRE reads a <curve> point, such as v064, whose number is the
// pointRE reads the name of a <curve> point, such as v064, whose number is the
// controller value from 0 to 127.
var pointRE = regexp.MustCompile(`^v([0-9]{1,3})$`)
// readCurves returns the instrument's curves: the built-in ones, and those of
// its <curve> headers, which pass through their points in straight lines, and
// the points of the custom ones.
// A curve that doesn't set v000 or v127 starts at 0 or ends at 1.
// readCurves returns the instrument's curves by index, and the points of its
// custom curves. The curves are the built-in ones and those of its <curve>
// headers, which pass through their points in straight lines. A curve that
// doesn't set v000 starts at 0, and one that doesn't set v127 ends at 1.
func readCurves(defs []Opcodes) (map[int]curve, map[int][]CurveStop) {
curves := make(map[int]curve, len(builtinCurves)+len(defs))
stops := map[int][]CurveStop{}