Zoom with the wheel and set the loop on its own strip in music tabs

The ruler of the Pattern and Song tabs did two things with one drag,
and the wheel did three things with Alt and Shift. Both now do one
thing each, and the Song tab gets a few edits it was missing.

- The ruler has a loop strip along its top. A drag there sets the
  loop, a press or drag below it moves only where playing starts.
- The wheel only zooms: the time over the grid, lanes and ruler, the
  rows over the keys, the tracks over their heads. Alt and Shift no
  longer change it. A middle-drag still pans.
- Tracks can be zoomed from 28 to 160 px. Below 46 px a head shows
  only its name, M and S. An old saved view gets the old height.
- A click on nothing in the lanes picks the song itself.
- A right-click on an item opens a menu with Delete instead of
  deleting it. The inspector has no delete buttons any more.
- A sound item goes up to +12 dB, a track up to +12 dB. A pattern
  item stays at 0 dB, since a note is held to unity.
- An end of an item under the pointer lights up and shows a resize
  cursor. A long item marks every point where it starts over.
- The Pattern tab has an Audition switch in its header, off at first.
  Only with it on does a note sound when drawn, grabbed or moved.
  The keys down the left sound either way.
- A looped sound item draws every round alike. Each round is drawn
  from its own start, and each column shows the loudest part of the
  sound it covers instead of one sampled bucket.
- A song is at least one bar long instead of four. An empty song
  fits that bar across, and Play song ends after the last item.
- The ghost notes held back in #334 got their own issue, #339.

Finding: suite 542 for f97961c failed 5 game checks in e2e 64 and 65
while my runs on the same Windows machine overlapped it. Modules
60-65 alone without load passed, so this push's suite has to show it.

Tests:
- Unit: song-edit 11, piano-roll 17, song 14, sound-library 67.
  Four of them are new, one in song changed.
- e2e 64+65 on melektaus-atx: ALL PASSED - 46 checks (+3).
- e2e 60-65 on melektaus-atx: ALL PASSED - 86 checks.
- Gate on melektaus-atx: 251 files, 3907 tests, CHECK EXIT 0.
- Audition, after the gate: e2e 64 alone ALL PASSED - 25 checks
  (+1), transitions and piano-roll 30 tests, typecheck and ESLint
  clean.
- Waveform and one bar, after the gate: song, song-edit, song-play
  and the node catalog 438 tests. e2e 65 alone ALL PASSED - 25
  checks (+1). A probe shot of a looped pop sound: all six rounds
  pixel for pixel alike.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-06 18:25:49 +02:00
1 parent f97961c8ff
commit aa097bd076
19 files changed
+627 -202

No files matched your search

+1 -1
View File
@@ -251,7 +251,7 @@ describe('Play song', () => {
expect([asked?.name, asked?.owner]).toEqual([`song:${f.songId}`, logic.id]);
expect(asked?.play).toMatchObject({
tempo: 90,
length: 4 * BAR,
length: 2 * BAR,
loop: { start: BAR, end: 2 * BAR },
volume: 0.8,
fadeIn: 2,
+8 -5
View File
@@ -71,9 +71,11 @@ describe('the song asset (#334)', () => {
expect(songGrid(f.song().props)).toBe(160);
});
it('is at least four bars long, else up to the bar line after its last item, and loops all of it', () => {
it('is at least a bar long, else up to the bar line after its last item, and loops all of it', () => {
const f = makeSong();
expect(songLength(f.song())).toBe(4 * BAR);
expect(songLength(f.song())).toBe(BAR);
f.lay(f.item({ tick: 0, length: 100 }));
expect(songLength(f.song())).toBe(BAR);
f.lay(f.item({ tick: 4 * BAR, length: 100 }));
expect(songLength(f.song())).toBe(5 * BAR);
expect(songLoop(f.song())).toEqual({ start: 0, end: 5 * BAR });
@@ -86,7 +88,7 @@ describe('the song asset (#334)', () => {
it('keeps tracks and items to their rules on load, and a song survives the round trip', () => {
const tracks = heldSongTracks([{ id: 'a', name: '', volume: 99, pan: -4, mute: 1 }, 'x', { id: 'a' }]);
expect(tracks.map((t) => [t.name, t.volume, t.pan, t.mute])).toEqual([
['Track 1', 6, -1, false],
['Track 1', 12, -1, false],
['Track 2', 0, 0, false],
]);
expect(tracks[1]!.id).not.toBe('a');
@@ -107,12 +109,13 @@ describe('the song asset (#334)', () => {
{ track: 'gone', kind: 'pattern', tick: 0, length: 10 },
{ track: 'a', kind: 'video', tick: 0, length: 10 },
{ track: 'a', kind: 'sound', tick: -1, length: 10 },
{ track: 'a', kind: 'sound', tick: 0, length: 10, offset: 1.25 },
{ track: 'a', kind: 'sound', tick: 0, length: 10, offset: 1.25, volume: 30 },
],
tracks,
);
// A sound item goes up to +12 dB, a pattern item's notes no louder than they are.
expect(items.map((i) => [i.tick, i.length, i.offset, i.volume, i.transpose])).toEqual([
[0, 10, 1.25, 0, 0],
[0, 10, 1.25, 12, 0],
[10, 1, 4, 0, 48],
]);
+15
View File
@@ -3,7 +3,10 @@ import type { PatternNote } from '../../src/core/music/pattern';
import {
barLabelStep,
clampTimePan,
draggedLoop,
fitTime,
LOOP_STRIP,
rulerPartAt,
timeLines,
xToTick,
zoomTime,
@@ -72,6 +75,18 @@ describe('time view of the piano roll (#333)', () => {
expect(barLabelStep({ panX: 0, pxPerTick: 0.01 }, COMMON)).toBe(2);
expect(barLabelStep({ panX: 0, pxPerTick: 0.004 }, COMMON)).toBe(8);
});
it('sets the loop on the strip along the top of the ruler, and the start below it', () => {
expect(rulerPartAt(0)).toBe('loop');
expect(rulerPartAt(LOOP_STRIP - 1)).toBe('loop');
expect(rulerPartAt(LOOP_STRIP)).toBe('time');
const loop = { start: 1920, end: 3840 };
expect(draggedLoop(loop, null, 960, 480)).toEqual({ start: 480, end: 960 });
expect(draggedLoop(loop, null, 960, 960)).toBeNull();
expect(draggedLoop(loop, 'end', 3840, 5760)).toEqual({ start: 1920, end: 5760 });
expect(draggedLoop(loop, 'end', 3840, 0)).toEqual({ start: 1920, end: 1921 });
expect(draggedLoop(loop, 'start', 1920, 9999)).toEqual({ start: 3839, end: 3840 });
});
});
describe('rows of the piano roll (#333)', () => {
+44 -1
View File
@@ -17,10 +17,18 @@ import {
HEAD_BOXES,
headPartAt,
itemAt,
heldSongView,
itemsWithin,
loopSeams,
MAX_TRACK_HEIGHT,
MIN_TRACK_HEIGHT,
peakOver,
SLIDERS_MIN_HEIGHT,
sliderValue,
type SongView,
TRACK_HEIGHT,
trackAtY,
zoomTracks,
} from '../../src/editor/song/songView';
const BAR = 1920;
@@ -113,7 +121,7 @@ describe('moving and sizing items (#334)', () => {
});
describe('where things are in the Song tab (#334)', () => {
const view: SongView = { panX: 0, pxPerTick: 0.1, panY: 0 };
const view: SongView = { panX: 0, pxPerTick: 0.1, panY: 0, trackHeight: TRACK_HEIGHT };
const items = [item('a', 't1', 0, BAR), item('b', 't2', BAR, BAR)];
it('finds an item and which end of it is under the pointer', () => {
@@ -145,5 +153,40 @@ describe('where things are in the Song tab (#334)', () => {
expect(sliderValue(volume.x, volume, -60, 6, 0.5)).toBe(-60);
expect(sliderValue(volume.x + volume.w, volume, -60, 6, 0.5)).toBe(6);
expect(sliderValue(pan.x + pan.w / 2, pan, -1, 1, 0.05)).toBe(0);
// A head too low for its sliders has none to hit.
expect(headPartAt(volume.x + 10, volume.y + 4, SLIDERS_MIN_HEIGHT - 1)).toBe('name');
expect(headPartAt(mute.x + 4, mute.y + 4, MIN_TRACK_HEIGHT)).toBe('mute');
});
it('zooms the tracks about the pointer, within their bounds, and fills in an old saved view', () => {
const zoomed = zoomTracks({ ...view, panY: -20 }, 2, 150);
expect(zoomed.trackHeight).toBe(2 * TRACK_HEIGHT);
expect(trackAtY(zoomed, 10, 150)).toBe(trackAtY({ ...view, panY: -20 }, 10, 150));
expect(zoomTracks(view, 100, 0).trackHeight).toBe(MAX_TRACK_HEIGHT);
expect(zoomTracks(view, 0.01, 0).trackHeight).toBe(MIN_TRACK_HEIGHT);
expect(clampTracks({ ...zoomed, panY: -9999 }, 10, 400).panY).toBe(400 - 10 * 2 * TRACK_HEIGHT - 28);
expect(heldSongView({ panX: -5, pxPerTick: 0.3, panY: -10 })).toEqual({
panX: -5,
pxPerTick: 0.3,
panY: -10,
trackHeight: TRACK_HEIGHT,
});
});
it('marks where an item starts over inside it, from as far in as it starts', () => {
expect(loopSeams({ tick: BAR, length: 3 * BAR }, BAR, 0)).toEqual([2 * BAR, 3 * BAR]);
expect(loopSeams({ tick: BAR, length: 2 * BAR }, BAR, 480)).toEqual([2 * BAR - 480, 3 * BAR - 480]);
expect(loopSeams({ tick: 0, length: BAR }, BAR, 0)).toEqual([]);
expect(loopSeams({ tick: 0, length: 1000 }, 400.5, 0)).toEqual([400.5, 801]);
expect(loopSeams({ tick: 0, length: BAR }, 0, 0)).toEqual([]);
});
it('draws a waveform column as the loudest of every bucket it covers', () => {
const peaks = [0.1, 0.9, 0.2, 0.3];
expect(peakOver(peaks, 0, 0.25)).toBe(0.1);
expect(peakOver(peaks, 0.2, 0.3)).toBe(0.9);
expect(peakOver(peaks, 0.5, 1)).toBe(0.3);
expect(peakOver(peaks, 0.6, 0.61)).toBe(0.2);
expect(peakOver(peaks, 0.99, 1.2)).toBe(0.3);
});
});
+12
View File
@@ -1340,6 +1340,18 @@ describe('clips and tracks of a song (#334)', () => {
expect(library.stats().last).toMatchObject({ at: 2, volume: 0.5, loop: true });
});
it('plays a clip turned up past unity as loud as +12 dB, and no louder', async () => {
const library = new SoundLibrary();
library.playClip(FILE, { at: 2, offset: 0, duration: 3, volume: 2, bus: '' });
await settle();
await arrive();
expect(library.stats().last?.volume).toBe(2);
library.playClip(FILE, { at: 2, offset: 0, duration: 3, volume: 50, bus: '' });
await settle();
await arrive();
expect(library.stats().last?.volume).toBeCloseTo(10 ** (12 / 20), 6);
});
it('fades a clip out at its end and lets it go, a source only once', async () => {
const library = new SoundLibrary();
library.playClip(FILE, { at: 2, offset: 0, duration: 3, volume: 1, bus: '' });