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>