Fix the differences from the spec and sfizz that a conformance review found
Read opcodes under their other names. The registry lists the other names an opcode has, and the typed model now reads each under its own name: amp_release for ampeg_release, offby, bendup, tune_keytrack and the rest. Apply treats an old name as belonging to the same field, so it doesn't leave one behind. Cut a #define's value at the first space, as ARIA and sfizz do, so that two defines can share a line. Before, the first define took the rest of the line, and a kit that writes "#define $lo 1 #define $hi 25" lost its velocity layers. Ignore opcodes before any header when flattening, as sfizz does, and report them as a warning. Included files that hold only opcodes are not affected. Read the limits of a controller the same way each time. A region that sets lohdccN and inherits loccN took whichever the map gave first, so Apply's change could read back as the old limits. The hdcc opcodes now win. Accept -1 for lokey, hikey and key, which SFZ v2 allows, and don't report a region with a hikey of -1 as an inverted range. Cut numbers that don't fit to what a setting can hold, so offset=1e30 doesn't turn negative, and ignore a controller number or octave that overflows. Read polyphony=legato_high, legato_last and legato_low as a limit of 1. Put a new #define after a byte order mark. Mark in the tests where each expected value comes from, correct the tags that the spec doesn't support, and add tests for each of these. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+49
-32
@@ -28,7 +28,10 @@ func (e evaluator) controls(control Opcodes, regions []Region) []Control {
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
n, _ := strconv.Atoi(m[2])
|
||||
n, err := strconv.Atoi(m[2])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
switch m[1] {
|
||||
case "label_cc":
|
||||
labels[n] = strings.TrimSpace(v)
|
||||
@@ -118,7 +121,10 @@ func controllerValues(control Opcodes) map[int]float64 {
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
n, _ := strconv.Atoi(m[2])
|
||||
n, err := strconv.Atoi(m[2])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
f, ok := parseNumber(v)
|
||||
if !ok {
|
||||
continue
|
||||
@@ -157,10 +163,10 @@ func defaultKeyswitch(regions []Opcodes) int {
|
||||
func keyShift(ops Opcodes) int {
|
||||
shift := 0
|
||||
if n, ok := parseNumber(ops["note_offset"]); ok {
|
||||
shift += int(n)
|
||||
shift += toInt(n)
|
||||
}
|
||||
if n, ok := parseNumber(ops["octave_offset"]); ok {
|
||||
shift += 12 * int(n)
|
||||
shift += 12 * toInt(n)
|
||||
}
|
||||
return shift
|
||||
}
|
||||
@@ -191,37 +197,48 @@ var controllerBounds = []struct {
|
||||
// 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 {
|
||||
m := ccRE.FindStringSubmatch(name)
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
n, _ := strconv.Atoi(m[2])
|
||||
limit, ok := parseNumber(v)
|
||||
if !ok || n >= extendedVelocityCC {
|
||||
continue
|
||||
}
|
||||
c := ranges[n]
|
||||
if c == nil {
|
||||
c = &Condition{Source: SourceController, Controller: n, Low: 0, High: 1}
|
||||
}
|
||||
switch m[1] {
|
||||
case "locc":
|
||||
c.Low = clamp(limit/127, 0, 1)
|
||||
case "hicc":
|
||||
c.High = 1
|
||||
if limit < 127 {
|
||||
c.High = clamp((limit+1)/127-topEpsilon, 0, 1)
|
||||
// A limit set as both lo/hicc and lo/hihdcc, as when a region sets one and
|
||||
// inherits the other, takes the value of the hdcc one. The opcodes have no
|
||||
// order of their own, so reading the hdcc ones last is what makes the result
|
||||
// the same each time.
|
||||
read := func(hd bool) {
|
||||
for name, v := range ops {
|
||||
m := ccRE.FindStringSubmatch(name)
|
||||
if m == nil || strings.Contains(m[1], "hd") != hd {
|
||||
continue
|
||||
}
|
||||
case "lohdcc":
|
||||
c.Low = clamp(limit, 0, 1)
|
||||
case "hihdcc":
|
||||
c.High = clamp(limit, 0, 1)
|
||||
default:
|
||||
continue
|
||||
n, err := strconv.Atoi(m[2])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
limit, ok := parseNumber(v)
|
||||
if !ok || n >= extendedVelocityCC {
|
||||
continue
|
||||
}
|
||||
c := ranges[n]
|
||||
if c == nil {
|
||||
c = &Condition{Source: SourceController, Controller: n, Low: 0, High: 1}
|
||||
}
|
||||
switch m[1] {
|
||||
case "locc":
|
||||
c.Low = clamp(limit/127, 0, 1)
|
||||
case "hicc":
|
||||
c.High = 1
|
||||
if limit < 127 {
|
||||
c.High = clamp((limit+1)/127-topEpsilon, 0, 1)
|
||||
}
|
||||
case "lohdcc":
|
||||
c.Low = clamp(limit, 0, 1)
|
||||
case "hihdcc":
|
||||
c.High = clamp(limit, 0, 1)
|
||||
default:
|
||||
continue
|
||||
}
|
||||
ranges[n] = c
|
||||
}
|
||||
ranges[n] = c
|
||||
}
|
||||
read(false)
|
||||
read(true)
|
||||
var out []Condition
|
||||
for _, b := range controllerBounds {
|
||||
lo, loOK := parseNumber(ops[b.low])
|
||||
|
||||
Reference in New Issue
Block a user