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:
2026-12-01 20:38:57 +00:00
co-authored by Claude Sonnet 5.5
parent 04419062f3
commit 8134660721
15 changed files with 384 additions and 85 deletions
+7 -3
View File
@@ -106,7 +106,8 @@ func (v *validator) endHeader() {
continue
}
hi, ok := v.numbers["hi"+rest]
if lo := v.numbers[name]; ok && lo.value > hi.value {
// A hikey of -1 keeps the region from playing, whatever its lokey.
if lo := v.numbers[name]; ok && lo.value > hi.value && hi.value != -1 {
v.add(lo.file, lo.at, SeverityWarning, "range.inverted", fmt.Sprintf("%s is above hi%s", name, rest))
}
}
@@ -119,7 +120,7 @@ func (v *validator) endHeader() {
// anything.
func (v *validator) opcode(f *File, n *Node, name, value string, _ bool) {
if !v.inHeader {
v.add(f, n, SeverityInfo, "opcode.no-header", fmt.Sprintf("%s is before any header", name))
v.add(f, n, SeverityWarning, "opcode.no-header", fmt.Sprintf("%s is before any header, so no region has it", name))
v.inHeader = true
v.numbers = map[string]opcodeAt{}
}
@@ -172,7 +173,10 @@ func (v *validator) value(f *File, n *Node, name, value string, info OpcodeInfo)
if info.Type == TypeInteger && !info.Note && x != float64(int64(x)) {
v.add(f, n, SeverityInfo, "value.type", fmt.Sprintf("%s=%s isn't a whole number", name, value))
}
if info.Min != nil && x < *info.Min || info.Max != nil && x > *info.Max {
// SFZ v2 allows -1 for lokey, hikey and key, to keep a region from
// playing on any key, though the table of ranges starts at 0.
disables := x == -1 && (name == "lokey" || name == "hikey" || name == "key")
if !disables && (info.Min != nil && x < *info.Min || info.Max != nil && x > *info.Max) {
v.add(f, n, SeverityWarning, "value.range", fmt.Sprintf("%s=%s is outside %s", name, value, bounds(info)))
}
v.numbers[name] = opcodeAt{value: x, at: n, file: f}