Read repeated point spellings in a fixed order and end comments at a carriage return

Two spellings of one curve point, as v064 and v64, now give the same
result each time. A line comment ends at a lone carriage return, as in
sfizz. Header.Set's documentation says an include in the header's range
can override what it sets.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 00:46:19 +00:00
co-authored by Claude Sonnet 5.5
parent 37d2866fe9
commit 535856ba77
5 changed files with 45 additions and 4 deletions
+29
View File
@@ -172,3 +172,32 @@ func TestDefineValueIsOneWord(t *testing.T) {
t.Errorf("SetDefine: %v", err)
}
}
// TestTwoSpellingsOfOnePoint checks that two spellings of one velocity or
// curve point read the same way every time (choice: the one that sorts last
// wins).
func TestTwoSpellingsOfOnePoint(t *testing.T) {
for i := 0; i < 50; i++ {
inst := parseText(t, "<region> sample=a.wav amp_velcurve_064=0.2 amp_velcurve_64=0.9")
for _, p := range inst.Regions[0].VelocityCurve {
if p.Velocity == 64 && p.Gain != 0.9 {
t.Fatalf("velocity point %v", p)
}
}
_, stops := readCurves([]Opcodes{{"curve_index": "20", "v064": "0.2", "v64": "0.9"}})
for _, s := range stops[20] {
if s.At == 64 && s.Value != 0.9 {
t.Fatalf("curve point %v", s)
}
}
}
}
// TestCommentEndsAtCarriageReturn checks that a line comment ends at a lone
// carriage return (sfizz).
func TestCommentEndsAtCarriageReturn(t *testing.T) {
r := parseText(t, "<region> // note\rsample=a.wav").Regions[0]
if r.Sample != "a.wav" {
t.Errorf("sample %q", r.Sample)
}
}