Let AddRegion clear inherited opcodes with an empty global header
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>
This commit is contained in:
@@ -45,9 +45,9 @@ The model is read with each setting that a controller moves taken at the control
|
||||
- `Instrument.Apply(i, region)` writes a change to a typed region back to the document that the instrument was read from, as changes to the region's own opcodes. It touches only the settings that changed, leaves unknown opcodes, comments and the other regions as they were, and puts every change in the region's own header, over what the region inherits. `Instrument.Patches` returns the changes without making them.
|
||||
- It returns `ErrNoSource` if the region has no header to edit: a variable made the header, or an include or a variable brings in opcodes after it.
|
||||
- It returns `ErrUnpatchable`, and changes nothing, for a change the header can't hold: removing an opcode the region inherits, or a sample outside `default_path`.
|
||||
- `Instrument.AddRegion(region)`, `RemoveRegion(i)` and `MoveRegion(from, to)` change the document's structure and read the instrument again, so it is as the document reads. A removed or moved region takes the comments and spacing that follow its header, so a comment on the lines above a `<region>` stays with the header before it. They read the document again, so they refuse an instrument whose regions were changed other than by `Apply`, or whose document was edited since it was read. A new region goes at the end of the main file. Each changes nothing, and returns an error, if the result wouldn't read as intended.
|
||||
- `Instrument.AddRegion(region)`, `RemoveRegion(i)` and `MoveRegion(from, to)` change the document's structure and read the instrument again, so it is as the document reads. A removed or moved region takes the comments and spacing that follow its header, so a comment on the lines above a `<region>` stays with the header before it. They read the document again, so they refuse an instrument whose regions were changed other than by `Apply`, or whose document was edited since it was read. A new region goes at the end of the main file. If the headers above it set what a region can't cancel, such as modulations, `AddRegion` writes an empty `<global>` before it, which clears what the `<global>`, `<master>` and `<group>` above set. Each changes nothing, and returns an error, if the result wouldn't read as intended.
|
||||
- `ErrNoSource` is for a region that has no header to move or remove, or an instrument that wasn't read from a document.
|
||||
- `ErrUnpatchable` is for a region that would read differently where it ends up: a new region that a `default_path` changes, or a region moved under another `<group>` or over a `#define` that changes it, or text that wouldn't read back as the edited nodes, such as a comment that never ends.
|
||||
- `ErrUnpatchable` is for a region that would read differently where it ends up: a new region whose sample a `default_path` changes, or a region moved under another `<group>` or over a `#define` that changes it, or text that wouldn't read back as the edited nodes, such as a comment that never ends.
|
||||
- `Node` positions are worked out when asked for, with `File.Position`, so edits stay cheap.
|
||||
|
||||
## Writing and building
|
||||
|
||||
Reference in New Issue
Block a user