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:
+34
-30
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Controllers above 127 that ARIA defines, which depend on the note: its
|
||||
// The controllers above 127 that ARIA defines, which depend on the note: its
|
||||
// velocity, its key, and whether it is held.
|
||||
const (
|
||||
extendedVelocityCC = 131
|
||||
@@ -14,12 +14,12 @@ const (
|
||||
extendedGateCC = 134
|
||||
)
|
||||
|
||||
// maxControls is the most controllers an instrument has, one for each.
|
||||
// maxControls is how many numbered controllers an instrument has, 0 to 127.
|
||||
const maxControls = 128
|
||||
|
||||
// controls returns the controllers the instrument names with label_ccN, sets
|
||||
// with set_ccN or set_hdccN, or has regions that use, by number, each with its
|
||||
// starting value.
|
||||
// controls returns the controllers that the instrument names with label_ccN,
|
||||
// sets with set_ccN or set_hdccN, or has regions that use, in order of number,
|
||||
// each with its starting value.
|
||||
func (e evaluator) controls(control Opcodes, regions []Region) []Control {
|
||||
labels := map[int]string{}
|
||||
used := map[int]bool{}
|
||||
@@ -57,8 +57,8 @@ func (e evaluator) controls(control Opcodes, regions []Region) []Control {
|
||||
}
|
||||
|
||||
// keyswitchRange returns the keys that are keyswitches and the one that is down
|
||||
// at the start, or nil if no region uses a keyswitch. Without sw_lokey and
|
||||
// sw_hikey, they are the keys that the regions name.
|
||||
// at the start, or nil if no region uses a keyswitch. The keys are those that
|
||||
// sw_lokey and sw_hikey give, and the keys that the regions name.
|
||||
func keyswitchRange(regions []Opcodes) *KeyswitchRange {
|
||||
var r *KeyswitchRange
|
||||
for _, ops := range regions {
|
||||
@@ -96,17 +96,18 @@ func keyswitchRange(regions []Opcodes) *KeyswitchRange {
|
||||
return r
|
||||
}
|
||||
|
||||
// ccRE reads a controller number from the end of an opcode, such as the 64 of
|
||||
// locc64.
|
||||
// ccRE reads the name of an opcode that ends in a controller number, such as
|
||||
// locc64, as the name without the number and then the number.
|
||||
var ccRE = regexp.MustCompile(`^(.*?)(\d+)$`)
|
||||
|
||||
// defaultControllers are the controllers that start somewhere other than 0
|
||||
// unless set_cc or set_hdcc say otherwise, as sfizz starts them: volume at
|
||||
// 100, pan in the middle, and expression at full.
|
||||
// defaultControllers are the controllers that start somewhere other than 0,
|
||||
// unless set_cc or set_hdcc say otherwise, as sfizz starts them: volume at 100,
|
||||
// pan in the middle, and expression at full.
|
||||
var defaultControllers = map[int]float64{7: 100.0 / 127, 10: 0.5, 11: 1}
|
||||
|
||||
// controllerValues returns the starting values of the controllers, from 0 to
|
||||
// 1: those that set_cc and set_hdcc give, then defaultControllers, then 0.
|
||||
// controllerValues returns the starting values of the controllers, from 0 to 1.
|
||||
// A controller takes the value that set_cc or set_hdcc gives it, or else its
|
||||
// value in defaultControllers, or else 0.
|
||||
func controllerValues(control Opcodes) map[int]float64 {
|
||||
values := map[int]float64{}
|
||||
for n, v := range defaultControllers {
|
||||
@@ -132,11 +133,11 @@ func controllerValues(control Opcodes) map[int]float64 {
|
||||
return values
|
||||
}
|
||||
|
||||
// defaultKeyswitch returns the keyswitch that is active before any is
|
||||
// pressed: the first sw_default, or failing that the first sw_last, or -1
|
||||
// if the instrument has no keyswitches. Without an sw_default, SFZ players
|
||||
// play no keyswitched region until a keyswitch is pressed; a host that can't
|
||||
// press one can use the first articulation instead.
|
||||
// defaultKeyswitch returns the keyswitch that is active before any is pressed:
|
||||
// the first sw_default, or failing that the first sw_last, or -1 if the
|
||||
// instrument has no keyswitches. Without an sw_default, SFZ players play no
|
||||
// keyswitched region until a keyswitch is pressed. A host that can't press one
|
||||
// can use the first articulation instead.
|
||||
func defaultKeyswitch(regions []Opcodes) int {
|
||||
for _, ops := range regions {
|
||||
if n, ok := parseNote(ops["sw_default"]); ok {
|
||||
@@ -151,7 +152,7 @@ func defaultKeyswitch(regions []Opcodes) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
// keyShift is how far the <control> header's note_offset and octave_offset
|
||||
// keyShift returns how far the <control> header's note_offset and octave_offset
|
||||
// move a region's key numbers.
|
||||
func keyShift(ops Opcodes) int {
|
||||
shift := 0
|
||||
@@ -164,14 +165,16 @@ func keyShift(ops Opcodes) int {
|
||||
return shift
|
||||
}
|
||||
|
||||
// hicc's high end includes the whole of value N, as a controller at 0.5 is
|
||||
// 63.5 out of 127 and so within hicc63, as sfizz compares them. So the range
|
||||
// is made to end just below value N + 1, unless N is the top.
|
||||
// topEpsilon is how far below the next whole value the end of a hiccN range is
|
||||
// put. The range includes the whole of value N, as a controller at 0.5 is 63.5
|
||||
// out of 127 and so is within hicc63, as sfizz compares them. The range ends
|
||||
// just below value N + 1, unless N is the top.
|
||||
const topEpsilon = 1e-9
|
||||
|
||||
// controllerBounds are the Opcodes that limit a source that isn't a numbered
|
||||
// controller to a range: the lowest and highest, the range they run over, and
|
||||
// what they default to.
|
||||
// controllerBounds are the opcodes that limit a source that isn't a numbered
|
||||
// controller to a range. Each has the name of the source, the opcodes for its
|
||||
// lowest and highest limits, the scale that their values are the range's limits
|
||||
// times, and the range of the source, which the limits default to.
|
||||
var controllerBounds = []struct {
|
||||
source, low, high string
|
||||
scale float64
|
||||
@@ -183,9 +186,9 @@ var controllerBounds = []struct {
|
||||
{SourcePolyAftertouch, "lopolyaft", "hipolyaft", 127, 0, 1},
|
||||
}
|
||||
|
||||
// conditions returns the ranges a region's locc, hicc, lohdcc and hihdcc, and
|
||||
// its channel, pitch bend and aftertouch Opcodes limit it to. Controllers
|
||||
// above 127, which belong to the note, are left out.
|
||||
// conditions returns the ranges that a region's locc, hicc, lohdcc and hihdcc
|
||||
// opcodes, and its channel, pitch bend and aftertouch opcodes, limit it to.
|
||||
// Controllers above 127, which belong to the note, are left out.
|
||||
func conditions(ops Opcodes) []Condition {
|
||||
ranges := map[int]*Condition{}
|
||||
for name, v := range ops {
|
||||
@@ -243,7 +246,8 @@ func conditions(ops Opcodes) []Condition {
|
||||
return out
|
||||
}
|
||||
|
||||
// keyswitch returns the keyswitches a region needs, or nil if it has none.
|
||||
// keyswitch returns the keyswitches that a region needs, with shift added to
|
||||
// their keys, or nil if it has none.
|
||||
func keyswitch(ops Opcodes, shift int) *Keyswitch {
|
||||
var k Keyswitch
|
||||
found := false
|
||||
|
||||
Reference in New Issue
Block a user