When the headers above the end of the document set what a region's own
opcodes can't cancel, such as modulations or note_polyphony, AddRegion writes
an empty <global> before the new region, which clears the levels below it.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
AddRegion, RemoveRegion and MoveRegion now refuse an edit whose written text
would read differently from the nodes, as when a comment that never ends
takes in the text after it, and an instrument whose regions were changed
other than by Apply. Build refuses an unknown trigger and an empty random
range. Add tests for edits across files, defines, skipped regions and edge
cases, a random-sequence test and FuzzRegionEdits.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Instrument.Source returns the flattened region and header behind a typed
region. AddRegion, RemoveRegion and MoveRegion edit the document and read
the instrument again, restoring the document if a region would read
differently. NewRegion returns a region with the format's defaults, and
Build refuses a region that can't be read back as it is.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
AllowParentPaths is off by default, so WriteFiles still refuses a path
with .. in it. Absolute paths are refused either way.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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>
- Bring the README up to date with editing, Apply, the model tags, validation
codes, errors, limits, concurrency and development.
- Fix the typed-model link and wording in docs/opcodes.md.
- Add examples to the package documentation.
- Describe the regeneration steps for the registry, and the licence status of
the Splendid Grand Piano fixture.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Header.Get, Set and Delete edit opcodes in place and keep the text around
them. Write and WriteFiles take WriteOptions to inline includes, expand
variables and set line endings. Build makes a document from a typed
Instrument, with options to split regions into included files and to
hoist repeated values into #define directives.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Parse keeps a file exactly as written, with #define and #include
unexpanded and each include as its own file in a tree. Flatten resolves
directives and header inheritance, and Flat.Instrument reads regions into
the typed model ported from Zampler's internal/sfz. The opcode registry
is generated from the SFZ format's syntax data and drives Lookup, GetAs
and Validate.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>