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:
+29
-27
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// modulatedBy are the settings controllers move while a note plays, with the
|
||||
// Opcodes that set each.
|
||||
// modulatedBy are the settings that controllers move while a note plays, each
|
||||
// with the opcodes that set it.
|
||||
var modulatedBy = []struct {
|
||||
target string
|
||||
Opcodes []string
|
||||
@@ -21,14 +21,14 @@ var modulatedBy = []struct {
|
||||
{TargetTune, []string{"tune", "pitch"}},
|
||||
}
|
||||
|
||||
// hasModulation reports whether a controller moves a target.
|
||||
// hasModulation reports whether a numbered controller moves the target.
|
||||
func (e evaluator) hasModulation(ops Opcodes, target string) bool {
|
||||
return len(e.modulations(ops, target)) > 0
|
||||
}
|
||||
|
||||
// modulations returns the controller modulations of a region's settings, which
|
||||
// are the controllers 0 to 127, or only those of the targets named. They are in
|
||||
// the order of the settings, then of the controllers.
|
||||
// modulations returns the modulations of a region's settings by the numbered
|
||||
// controllers, 0 to 127, or only those of the targets named. They are in the
|
||||
// order of the settings, then of the controllers.
|
||||
func (e evaluator) modulations(ops Opcodes, only ...string) []Modulation {
|
||||
var out []Modulation
|
||||
for _, set := range modulatedBy {
|
||||
@@ -64,9 +64,10 @@ func (e evaluator) modulations(ops Opcodes, only ...string) []Modulation {
|
||||
return out
|
||||
}
|
||||
|
||||
// modulation returns how much the controllers from the number given up move an
|
||||
// opcode from its own value: the sum of each target_onccN depth, or its SFZ v1
|
||||
// form targetccN, shaped by target_curveccN at the controller's value.
|
||||
// modulation returns how far the controllers from the number from up move a
|
||||
// target from its own value. It is the sum of the depths of its target_onccN
|
||||
// opcodes, or targetccN in SFZ v1, each shaped by target_curveccN at the
|
||||
// controller's value.
|
||||
func (e evaluator) modulation(ops Opcodes, target string, cc func(int) float64, from int) float64 {
|
||||
total := 0.0
|
||||
for _, m := range modulators(ops, target, from) {
|
||||
@@ -75,18 +76,18 @@ func (e evaluator) modulation(ops Opcodes, target string, cc func(int) float64,
|
||||
return total
|
||||
}
|
||||
|
||||
// modulatorOpcode is a controller modulation of a target in a region's
|
||||
// opcodes.
|
||||
// modulatorOpcode is an opcode of a region that sets the depth of a controller's
|
||||
// modulation of a target.
|
||||
type modulatorOpcode struct {
|
||||
name string
|
||||
controller int
|
||||
depth float64
|
||||
}
|
||||
|
||||
// modulators returns the controller modulations of a target from the
|
||||
// controller given up, whose depths are numbers, ordered by controller and then
|
||||
// by name. The order makes sums of them, which floating-point addition makes
|
||||
// depend on it, the same each time.
|
||||
// modulators returns the opcodes that modulate the target by the controllers
|
||||
// from the number from up, and whose depths are numbers, ordered by controller
|
||||
// and then by name. Floating-point sums depend on the order of their terms, so
|
||||
// summing in this order gives the same result each time.
|
||||
func modulators(ops Opcodes, target string, from int) []modulatorOpcode {
|
||||
var out []modulatorOpcode
|
||||
for name, v := range ops {
|
||||
@@ -104,8 +105,8 @@ func modulators(ops Opcodes, target string, from int) []modulatorOpcode {
|
||||
return out
|
||||
}
|
||||
|
||||
// amplitude returns the region's amplitude as a factor: amplitude and the
|
||||
// global, master and group amplitudes are percentages that multiply, and so
|
||||
// amplitude returns the region's amplitude as a factor. The amplitude, and the
|
||||
// global, master and group amplitudes, are percentages that multiply, and so
|
||||
// does each amplitude_oncc of the controllers above 127.
|
||||
func (e evaluator) amplitude(ops Opcodes, cc func(int) float64) float64 {
|
||||
a := 1.0
|
||||
@@ -122,13 +123,13 @@ func (e evaluator) amplitude(ops Opcodes, cc func(int) float64) float64 {
|
||||
|
||||
// extendedOnly is the lowest of the controllers above 127, which belong to the
|
||||
// note: its velocity, its key and whether it is held. A region takes the
|
||||
// modulation of these at its root note and the middle of its velocities, as it
|
||||
// can't follow them, and leaves the numbered controllers to be applied when a
|
||||
// note plays.
|
||||
// modulation by these at its root note and the middle of its velocities, as it
|
||||
// can't follow them. It leaves the modulation by the numbered controllers to
|
||||
// be applied when a note plays.
|
||||
const extendedOnly = 128
|
||||
|
||||
// shape returns a controller's value through the curve the region gives it
|
||||
// for the target, or straight through if it gives none.
|
||||
// shape returns the value x of controller n through the curve that the region
|
||||
// gives it for the target, or straight through if it gives none.
|
||||
func (e evaluator) shape(ops Opcodes, target string, n int, x float64) float64 {
|
||||
c, ok := e.curves[e.curveIndex(ops, target, n)]
|
||||
if !ok {
|
||||
@@ -137,8 +138,9 @@ func (e evaluator) shape(ops Opcodes, target string, n int, x float64) float64 {
|
||||
return c(x)
|
||||
}
|
||||
|
||||
// curveIndex returns the curve a region gives a controller's modulation of a
|
||||
// target, or 0, the straight one, if it gives none or the curve doesn't exist.
|
||||
// curveIndex returns the curve that a region gives a controller's modulation of
|
||||
// a target, or 0, the straight one, if it gives none or the curve doesn't
|
||||
// exist.
|
||||
func (e evaluator) curveIndex(ops Opcodes, target string, n int) int {
|
||||
if v, ok := parseNumber(ops[fmt.Sprintf("%s_curvecc%d", target, n)]); ok {
|
||||
if _, exists := e.curves[int(v)]; exists {
|
||||
@@ -148,9 +150,9 @@ func (e evaluator) curveIndex(ops Opcodes, target string, n int) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// modulator reports whether an opcode is a controller modulation of the
|
||||
// target, and of which controller: target_onccN, or targetccN or target_ccN
|
||||
// in SFZ v1.
|
||||
// modulator reports whether an opcode sets a controller's modulation of the
|
||||
// target, and the controller's number. The opcode is target_onccN, or targetccN
|
||||
// or target_ccN in SFZ v1.
|
||||
func modulator(name, target string) (int, bool) {
|
||||
rest, ok := strings.CutPrefix(name, target)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user