diff --git a/tools/e2e/65-song.mjs b/tools/e2e/65-song.mjs index 62e8c331..346c7c9d 100644 --- a/tools/e2e/65-song.mjs +++ b/tools/e2e/65-song.mjs @@ -905,8 +905,21 @@ export async function song(t) { p = await json('__gm.song.rulerAt(0)'); await click(p.x, p.y); await press('Space'); + // The clip ends where the note starts, and the note is planned only the lookahead and a frame + // before: by then the clip's voice may be gone, and with it its start (#415). So the start of the + // clip is kept from the first reading that has it, each reading in one go with the clock. + let clipStart = null; const throughFx = await waitFor( - () => json('{ planned: __gm.song.planned(), clips: __gm.song.clips() }'), + async () => { + const seen = await json(`(() => { + const planned = __gm.song.planned(); + const clips = __gm.song.clips(); + const startOf = (list) => (list[0] ? __gm.sound.startedAt(list[0].voice) : null); + return { planned, clips, noteStart: startOf(planned), clipStart: startOf(clips), clock: __gm.sound.clock() }; + })()`); + clipStart ??= seen.clipStart; + return seen; + }, (s) => s.planned.length >= 1 && s.clips.length >= 1, 60, ); @@ -915,8 +928,7 @@ export async function song(t) { const fxBus = (await json('__gm.song.buses()')).find((b) => b.name === busOf(tracks[1])); const [fxNote] = throughFx.planned; const [plainClip] = throughFx.clips; - const noteStart = await json(`__gm.sound.startedAt(${fxNote?.voice ?? 0})`); - const clipStart = await json(`__gm.sound.startedAt(${plainClip?.voice ?? 0})`); + const { noteStart, clock } = throughFx; check( 'the track plays through one shifter on its bus: its notes start a frame early, the clip of the other on time', fxBus?.fx === true && @@ -926,7 +938,7 @@ export async function song(t) { Math.abs(fxNote.at - plainClip.at - 2) < 1e-6 && Math.abs(noteStart - (fxNote.at - frame)) < 1e-6 && Math.abs(clipStart - plainClip.at) < 1e-6, - JSON.stringify({ rate, fxBus, fxNote, plainClip, noteStart, clipStart }), + JSON.stringify({ rate, fxBus, fxNote, plainClip, noteStart, clipStart, clock }), ); await press('Space'); const released = await waitFor(