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:
+18
@@ -102,6 +102,10 @@ var (
|
||||
patterns []matcher
|
||||
// headerByName holds the headers, by lowercase name.
|
||||
headerByName map[string]*HeaderInfo
|
||||
// ownNames holds the own name of each opcode that has other names, by each
|
||||
// other name. Families such as loccN are left out, and so is pitch, which
|
||||
// the typed model adds to tune and doesn't take as another name for it.
|
||||
ownNames map[string]string
|
||||
)
|
||||
|
||||
// patternRE reads a name's placeholders: a run of N, X and Y letters, or a *.
|
||||
@@ -135,6 +139,7 @@ func pattern(name string) *regexp.Regexp {
|
||||
func loadRegistry() {
|
||||
registryOnce.Do(func() {
|
||||
byName = map[string]*OpcodeInfo{}
|
||||
ownNames = map[string]string{}
|
||||
headerByName = map[string]*HeaderInfo{}
|
||||
for i := range headerData {
|
||||
headerByName[headerData[i].Name] = &headerData[i]
|
||||
@@ -147,6 +152,9 @@ func loadRegistry() {
|
||||
switch {
|
||||
case re == nil:
|
||||
byName[name] = info
|
||||
if name != info.Name && pattern(info.Name) == nil && name != "pitch" {
|
||||
ownNames[name] = info.Name
|
||||
}
|
||||
case strings.Contains(name, "*"):
|
||||
wild = append(wild, matcher{re, info})
|
||||
default:
|
||||
@@ -175,6 +183,16 @@ func Lookup(name string) (OpcodeInfo, bool) {
|
||||
return OpcodeInfo{}, false
|
||||
}
|
||||
|
||||
// ownName returns the name that the format gives an opcode, for any other name
|
||||
// it is known by. It returns name for an opcode that has no other name.
|
||||
func ownName(name string) string {
|
||||
loadRegistry()
|
||||
if own, ok := ownNames[name]; ok {
|
||||
return own
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
// KnownOpcodes returns every opcode of the format, in the order the format
|
||||
// lists them.
|
||||
func KnownOpcodes() iter.Seq[OpcodeInfo] {
|
||||
|
||||
Reference in New Issue
Block a user