Add diatonic chord entry and velocity control

Chords are built by stacking scale thirds rather than from a quality table,
so the chord follows the degree automatically -- in C major, Alt+3 on C gives
C major, on D gives D minor, on B gives B diminished. Toggling delegates to
toggleCell, so chord tones inherit hold-mode joining, splitting and trimming
unchanged.

Velocity keys act on the note under the cursor if there is one, and on the
default for new notes otherwise, announcing which. That avoids a mode switch
between setting a level to draw at and shaping dynamics after the fact.

Also fixes install.ps1 failing to resolve its own directory: $PSScriptRoot is
not reliably populated during parameter binding, so it is resolved in the body.

Tests cover chord quality per scale degree and range clamping.
This commit is contained in:
2026-08-14 18:18:12 +02:00
parent 8fd6f947ed
commit c9e927ca3d
8 changed files with 214 additions and 3 deletions
+17
View File
@@ -67,4 +67,21 @@ eq(G.gridLabel(1), "1/4", "grid quarter")
eq(G.gridLabel(0.25), "1/16", "grid sixteenth")
eq(G.gridLabel(0.5), "1/8", "grid eighth")
-- Diatonic chords: stacking scale thirds must yield the right quality for
-- each degree, without any chord-quality table.
ext.root, ext.scale = "0", "1" -- C major
eq(table.concat(G.chordPitches(60, 3), ","), "60,64,67", "C major triad")
eq(table.concat(G.chordPitches(62, 3), ","), "62,65,69", "D minor triad")
eq(table.concat(G.chordPitches(71, 3), ","), "71,74,77", "B diminished triad")
eq(table.concat(G.chordPitches(60, 4), ","), "60,64,67,71", "C major seventh")
eq(table.concat(G.chordPitches(67, 4), ","), "67,71,74,77", "G dominant seventh")
-- A minor triad from its own root.
ext.root, ext.scale = "9", "2"
eq(table.concat(G.chordPitches(69, 3), ","), "69,72,76", "A minor triad")
-- Running off the top of the MIDI range yields nil rather than a partial chord.
ext.root, ext.scale = "0", "1"
eq(G.chordPitches(127, 3), nil, "chord past top of range")
print(fails == 0 and "ALL PASS" or (fails .. " FAILURES"))