Fixed volume and panning for ninjam override.

This commit is contained in:
Storm Dragon committed 2026-10-28 03:47:57 -04:00
1 parent b45f800489
commit d3bcbbeacf
11 files changed
+412 -170

No files matched your search

@@ -5,6 +5,7 @@ package ninjam_test
import (
"slices"
"strconv"
"strings"
"testing"
@@ -93,7 +94,7 @@ func TestFocusChatMetersAndValueReflow(t *testing.T) {
t.Fatal(got)
}
got = update(snapshot(1, " ", "-0.5dB center", "<Username> first", "<Username> second"))
if !slices.Equal(got, []string{"Master Volume and pan -0.5dB center"}) {
if !slices.Equal(got, []string{"minus 0.5dB"}) {
t.Fatal("reflow", got)
}
s := snapshot(1, " ", "-0.5dB center", "<Username> first", "<Username> second")
@@ -234,3 +235,70 @@ func TestWrappedChatRecallAndChangedGeometry(t *testing.T) {
t.Fatal("resized interval region", result)
}
}
func TestVolumeAndPanAnnounceOnlyChangedComponent(t *testing.T) {
for _, selected := range []int{1, 3, 8, 12} {
t.Run(strconv.Itoa(selected), func(t *testing.T) {
a, r := &ninjam.Adapter{}, reader.New()
makeSnapshot := func(value string, chat ...string) screen.Snapshot {
s := snapshot(selected, " ", "0.0dB center", chat...)
// Repaint the selected bracket with the same style, including
// changes in width at center and across signed dB values.
for row := range s.Rows {
for col, attribute := range s.Attributes[row*s.Cols : (row+1)*s.Cols] {
if attribute.Background != screen.ColorIndexed|7 {
continue
}
line := string(s.Line(row))
start := col
end := start + strings.Index(line[start:], "]")
line = line[:start] + value + line[end:]
for i := range s.Line(row) {
s.Line(row)[i] = ' '
s.Attributes[row*s.Cols+i] = screen.Attribute{Foreground: screen.ColorIndexed | 7, Background: screen.ColorIndexed}
}
copy(s.Line(row), []rune(line))
for i := start; i < start+len(value); i++ {
s.Attributes[row*s.Cols+i] = attribute
}
return s
}
}
t.Fatal("missing selected field")
return s
}
update := func(value string, chat ...string) []string {
s := makeSnapshot(value, chat...)
return texts(r.Update_application(s, a.Observe(s)))
}
update("0.0dB center", "<Username> old")
for _, trial := range []struct{ value, want string }{
{"0.0dB 1%L", "1 percent left"},
{"0.0dB 2%L", "2 percent left"},
{"0.0dB center", "center"},
{"0.0dB 1%R", "1 percent right"},
{"-0.5dB 1%R", "minus 0.5dB"},
{"0.0dB 1%R", "0.0dB"},
{"+0.5dB 1%R", "plus 0.5dB"},
{"+1.0dB 2%R", "plus 1.0dB 2 percent right"},
} {
if got := update(trial.value, "<Username> old"); !slices.Equal(got, []string{trial.want}) {
t.Fatalf("%s: %v", trial.value, got)
}
}
if got := update("+1.0dB 2%R", "<Username> old"); len(got) != 0 {
t.Fatal("unchanged value repeated", got)
}
if got := update("+1.0dB 3%R", "<Username> old", "<Username> new"); !slices.Equal(got, []string{"3 percent right", "<Username> new"}) {
t.Fatal("chat alongside pan", got)
}
if result, _ := a.Command(command.ReadLiveRegion2); !strings.Contains(result.Text, "Volume and pan plus 1.0dB 3 percent right") {
t.Fatal("full control recall lost", result)
}
r.Command(command.CurrentLine)
if got := update("+1.0dB 4%R", "<Username> new", "<Username> review"); !slices.Equal(got, []string{"<Username> review"}) {
t.Fatal("pan disturbed detached review", got)
}
})
}
}