Commit Graph
13 Commits
Author SHA1 Message Date
aneurinandClaude Sonnet 5.5 158661eefe Rewrite the code comments for consistent tone and accuracy
Comments only: the tokens of every Go file are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 19:08:00 +00:00
aneurinandClaude Sonnet 5.5 41f752e1c1 Read Y as a placeholder in opcode family names
Names such as egN_timeX_onccY have a second number, so eg1_time2_oncc3 was
reported as unknown. Check that a name made from each family is found.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:43:01 +00:00
aneurinandClaude Sonnet 5.5 83c905633c Apply changes to a typed region as patches to its own header
Instrument.Patches works out the opcode changes that make region i read as an
updated Region, checking them against the reader, and Instrument.Apply makes
them in the document. Only the changed settings are touched, always in the
region's own header, so unknown opcodes and what other regions inherit stay as
they are. A change the header can't hold is an error and changes nothing.

FlatRegion gains Own, Inherited and Header to trace a region to its source, and
regionLines lists a region's opcodes with the field each sets.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:42:17 +00:00
aneurinandClaude Sonnet 5.5 359de59033 Tag the typed model with json, doc, minimum and maximum
The bounds are informational: the library reads and writes values outside
them, and the host decides whether to enforce them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:31:40 +00:00
aneurinandClaude Sonnet 5.5 d15c8fd3e6 Refuse to write a document's includes into one file by accident
- Write and WriteTo return an error for a document with includes unless the
  includes are inlined, instead of dropping the files they hold. Only
  WriteFiles collects included files and checks them for conflicts.
- ExpandVariables leaves comments as they are.
- An inlined file no longer leaves a line of its own for the include's line
  break.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:30:19 +00:00
aneurinandClaude Sonnet 5.5 ec4b27c005 Scale test time limits under the race detector
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:28:48 +00:00
aneurinandClaude Sonnet 5.5 d4b44b6ffb Check edited values, keep comments in place and make edits cheap
- Header.Set, Document.SetDefine and Document.AddHeader return an error for
  a value or name that can't be written as one opcode, define or header, and
  Build returns the same error for what it can't write.
- Set puts a new opcode after the last one's trailing comment, and never
  where text on its line would become part of its value. Delete keeps the
  line breaks it doesn't own.
- Node.Line and Node.Col are replaced by File.Position, which works lines and
  columns out when asked, and a node remembers where it was in its file, so an
  edit no longer renumbers the file or searches it from the start.
- Add FuzzEdit checks that an edited file reads back as its nodes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:27:17 +00:00
aneurinandClaude Sonnet 5.5 1bb842589e Share variable scope and the walk over a document's nodes
Flatten and Validate read nodes through one walk, and the parser, flattener,
validator and writer set variables through one type.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:20:35 +00:00
aneurinandClaude Sonnet 5.5 cc484ac3ef Split instrument.go into model, controls and modulation files
No behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:19:11 +00:00
aneurinandClaude Sonnet 5.5 a5376118f9 Keep = signs in opcode values
An opcode's value now ends at whitespace followed by the next opcode, so
sample=A=440.wav is one value.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:18:40 +00:00
aneurinandClaude Sonnet 5.5 cf54471778 Bound parsing work and fix writer, lexer and keyswitch bugs
- Count variable expansions against MaxBytes and stop substituting past it, so
  nested #defines can't grow exponentially. Read at most MaxBytes from a reader.
- Lex in linear time: end an opcode value at the next line break with the same
  regexp, and merge text nodes by slicing. Cap variable names at 128 bytes.
- Read a byte order mark as space so a directive after it is recognised.
- Refuse in WriteFiles an include path that is absolute or leaves the folder, and
  report include.outside and sample.outside from Validate.
- Give a lone sw_lokey or sw_hikey a one-key range.
- Sum controller modulations in a fixed order so Instrument is deterministic.
- Stop samplePrefix looping on a sample at the root.
- Validate without lexing plain opcodes again, and cache registry lookups.
- Add regression tests and FuzzWrite, FuzzEdit and FuzzBuild.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 18:12:16 +00:00
aneurinandClaude Sonnet 5.5 3d2ab78a32 Add editing, writing and building documents
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>
2026-12-01 17:41:34 +00:00
aneurinandClaude Sonnet 5.5 d124690ecf Add lossless SFZ document, flattening, typed model and opcode registry
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>
2026-12-01 17:38:10 +00:00