diff --git a/CLAUDE.md b/CLAUDE.md index 8e9cff3..ad4c645 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,7 +34,7 @@ request is the start of the interview, not the brief. Details: `brief/INTERVIEW. runs the autonomous build and fresh-eyes visual/audio QA; `.agents/hooks/stage_gate.py` enforces gates across Antigravity, Claude Code, and Codex. The brief's status line carries `Stage:`. - **Design comes before tools.** During design, stay out of the picture, sound and tool folders (`gen/`, `living/`, - `engine/`, `academies-film/`, `players/`, `dist/`, `media/`, `audio/`, `score/`, `jukebox/`, `tools/`), other + `engine/`, `academies-film/`, `players/`, `dist/`, `media/`, `audio/`, `score/`, `jukebox/`, `tools/`, `tapmarks/`), other pieces' `proj/` folders and their `STATUS.md` files (the full list: `notes/context-plan.md`, "The restricted list"). They open with `/toolbox` at the gate: right after the brief is approved in efficient mode (ready-made parts); after the storyboard, stills and sound concept are approved in full creative mode (from scratch). @@ -53,6 +53,7 @@ polished and lost. | A new piece | `/new-piece`; `/toolbox` at its gate | | A change to an existing piece | Its folder: `proj/cdrom/` (CS Lab Screensaver), `academies-film/` (Academies hallway film), `living/` (SSR, CS and Exploration living posters), `proj/pltw/` (PLTW promo). Each folder's `CLAUDE.md` loads by itself when you open a file there; its `STATUS.md` holds the history | | Library or tool work | That folder: `gen/`, `audio/` + `score/`, `engine/`, `jukebox/`, `tools/` (each has a `CLAUDE.md`) | +| Marking moments in a song by tapping keys (Tap Marks), or reading its `.tapmarks.json` | `tapmarks/` (`tapmarks/CLAUDE.md` has the JSON format and how to use the marks) | | The kit (engine parts ProofEr copies in) | `kit/README.md`; built from engine sources by `tools/build_kit.py` (never edit `kit/` by hand); its `KIT.json` format is agreed with ProofEr (`TODO.md` §0) | | How new pieces start | `brief/`: `INTERVIEW.md`, `TEMPLATE.md`, `CRAFT.md`, `STORYBOARD.md`, `example-academies.md`, `taste/house.md` (default taste), `clients/` | | The public face | `README.md` (keep it true when tools or builds change), `CONTRIBUTING.md`, `LICENSE`, `index.html` (the Pages landing page; `.nojekyll` must stay) | diff --git a/README.md b/README.md index 82dcd01..2ba39e3 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,10 @@ Start sound for the music. Move the mouse to see the controls. reaction-diffusion, kinetic type, Dust Type ...), **K** for the knobs. Drag sliders until it looks right, press **COPY JSON**, save it as `gen/carts/.json`: that's a new piece. `gen/README.md` has the full walkthrough (including kinetic-type music videos from a Whisper transcript), `gen/API.md` is the one-page reference for AIs. +- **Mark the moments in a song:** double-click **`tapmarks/tapmarks.html`**, drop an MP3 or WAV, press Enter and + tap keys as it plays (Space for one kind of moment, K for another ...). A timing fix snaps each tap onto the beat it + was meant for (switchable); the marks save as JSON for a music video. Also installable as an app from + [the Pages copy](https://bpmdata.github.io/EOMD/tapmarks/tapmarks.html). `tapmarks/README.md` has the details. - **A finished film:** `academies-film/danbury-academies-player.html`, a 60-second seamless hallway loop with its own synthesized soundtrack, all in one file. @@ -162,6 +166,7 @@ the project: the reusable parts are already here, so a new piece is mostly a sho | `score/` | Music cartridges (`*.json`) and `FORMAT.md`, which explains every field | | `audio/` | The music engine: instruments, the arranger and one file per arranger style | | `tools/` | The Python scripts you run (builds, MP4 export, music tools) | +| `tapmarks/` | Tap Marks: tap keys while a song plays to mark its moments, saved as JSON | | `brief/` | How a new piece starts: the client interview, brief and storyboard templates, craft guide, house taste, client profiles, and the Academies brief as the example | | `.agents/`, `.claude/`, `.codex/` | Skills (`new-piece`, `auto-piece`, `toolbox`), `fresh-eyes-reviewer` subagent, and cross-harness stage-gate hooks | | `proj//` | One piece's brief, copy and sources (`cdrom`, `pltw`, `cs`, `ex`, `ssr`, `academies`) | diff --git a/STATUS.md b/STATUS.md index 543834e..992ccff 100644 --- a/STATUS.md +++ b/STATUS.md @@ -3,7 +3,7 @@ > **Visitors:** this is the project's working log, kept for the people and AI assistants working on it. For what > EOMD is and how to use it, start with [README.md](README.md). -_Last updated: Dec 1, 2026 (kit v0.4.0, ProofEr's review fixes: drone audible on small speakers at −28 LUFS, bigger laptop type, text never over data; kit v0.3.0, ProofEr's addendum: portrait layouts, pause button, per-language text tracks, data-row sequences, drone bed, sources chapter; kit v0.2.0: the motion-essay engine for ProofEr: beat model + fixed-step clock, essay player shell, test hooks + `engine/tools/essay-qa.js`, plain-WebGL2 scene host + compositor with the lens on a GPU texture, 4 scenes, 6 transitions, HTML text with a WCAG check; demo at `players/essay-demo.html`. Nov 28: kit v0.1.0: `kit/` + `tools/build_kit.py` for ProofEr; both repos are AGPLv3, so no licence obstacle; video-essay plan in `TODO.md`; lens upgraded: 6-level glow, halation, AgX/ACES, grade, dither; engine audio fallback renders in slices and works when the worker is blocked. Nov 27: optional WebGL2 lens finish, ideas taken from the Q-Day player; before that Nov 21: CD-ROM link options `?start=`, `?go`, `?airship`; before that Nov 4: fresh-eyes review added to the design stages; Academies film: clock + timer version). Each piece's history, limits and open questions live in its +_Last updated: Dec 2, 2026 (Tap Marks, `tapmarks/tapmarks.html`: play a song, tap keys to mark moments, one row per key with the client's notes, a timing fix that snaps taps onto clear hits and can be switched off, JSON out; first part of Bryan's eventual automatic music video generator. Dec 1: kit v0.4.0, ProofEr's review fixes: drone audible on small speakers at −28 LUFS, bigger laptop type, text never over data; kit v0.3.0, ProofEr's addendum: portrait layouts, pause button, per-language text tracks, data-row sequences, drone bed, sources chapter; kit v0.2.0: the motion-essay engine for ProofEr: beat model + fixed-step clock, essay player shell, test hooks + `engine/tools/essay-qa.js`, plain-WebGL2 scene host + compositor with the lens on a GPU texture, 4 scenes, 6 transitions, HTML text with a WCAG check; demo at `players/essay-demo.html`. Nov 28: kit v0.1.0: `kit/` + `tools/build_kit.py` for ProofEr; both repos are AGPLv3, so no licence obstacle; video-essay plan in `TODO.md`; lens upgraded: 6-level glow, halation, AgX/ACES, grade, dither; engine audio fallback renders in slices and works when the worker is blocked. Nov 27: optional WebGL2 lens finish, ideas taken from the Q-Day player; before that Nov 21: CD-ROM link options `?start=`, `?go`, `?airship`; before that Nov 4: fresh-eyes review added to the design stages; Academies film: clock + timer version). Each piece's history, limits and open questions live in its folder's `STATUS.md`; repo-wide history in `notes/history.md`._ ## Pieces @@ -18,6 +18,7 @@ folder's `STATUS.md`; repo-wide history in `notes/history.md`._ | Video essays (Q-Day / Last Boring Slide level) | Kit v0.4.0 (Dec 1; v0.3.0 + ProofEr's review fixes): the essay engine (`engine/src/essay/`, `engine/src/gl/`, `engine/src/audio/bed.js`) with ProofEr's addendum for holocaust-by-country (portrait, text tracks, data-row sequences, drone bed, sources). Demo `players/essay-demo.html` (placeholder words, made-up numbers, EN + DRAFT ES track). EOMD builds the engine; ProofEr hosts motion essays (TODO §0) | Bryan tries the new bed on phone and laptop speakers; ProofEr syncs 0.4.0; next here (`TODO.md` top): GPU letter type, sound hits, essay MP4. Not yet seen on a real GPU, phone or TV (tested in SwiftShader) | | gen library (incl. Dust Type) | Working; `tools/gen_export.py` | Check Dust Type knobs | `gen/STATUS.md` | | Jukebox | 15 cartridges | Redesign its look | `jukebox/STATUS.md` | +| Tap Marks (`tapmarks/`) | Built Dec 2; QA 22/22 on a click track in headless Chrome | Bryan tries it with real songs, speakers and keyboard | `tapmarks/STATUS.md` | ## Across the repo - **CI** runs the gen build + smoke test and the audio regression CHECK (Node 22) on every push; the stage-read audit diff --git a/index.html b/index.html index f3bdf6e..81b54a0 100644 --- a/index.html +++ b/index.html @@ -135,6 +135,16 @@

Players

> +

Tools

+ Tap MarksOpen a song, press Enter and tap keys at the moments that matter: each key gets its own row and your notes. A + timing fix snaps taps onto the beat (or switch it off). Saves the marks as JSON. Works offline, and installs + as an app from here. +

Make your own

Clone the repo and point your AI coding assistant at it: diff --git a/notes/context-plan.md b/notes/context-plan.md index 6892807..b7ed66a 100644 --- a/notes/context-plan.md +++ b/notes/context-plan.md @@ -59,7 +59,8 @@ creative: storyboard, stills and sound concept approved). Picture and sound are above), `tests/hashes.json`, `notes/audio-ports.md`, every `proj/*/music.js`, `proj/cdrom/track2-r2.js`, `proj/cdrom/intro-motif.md`. (MIDI export is `tools/midi.py`, which logs the arranger's notes through Node; there is no other MIDI code in the repo.) -- **Tools:** `tools/` (builds, renderers, calibrate, midi, porter, regress, MP4 export). +- **Tools:** `tools/` (builds, renderers, calibrate, midi, porter, regress, MP4 export), `tapmarks/` (the song + tap-marking app). - **Other pieces:** every `proj//` except the new piece's own, and the per-piece STATUS files. - **Open during design:** root `CLAUDE.md`, the root STATUS index, `brief/`, `.claude/skills/new-piece/`, the new piece's `proj//`, and files the client supplied (logo, copy, brand guide). diff --git a/tapmarks/CLAUDE.md b/tapmarks/CLAUDE.md new file mode 100644 index 0000000..f09fdad --- /dev/null +++ b/tapmarks/CLAUDE.md @@ -0,0 +1,42 @@ +# tapmarks/: Tap Marks (mark the moments in a song by tapping keys) + +Status, history and known limits: `tapmarks/STATUS.md`. How a person uses it: `tapmarks/README.md`. + +## What's here +- `tapmarks.html`: the whole app, one offline file (no build step, nothing loads from the internet). Edit it in place. +- `manifest.webmanifest`, `sw.js`, `icon-192.png`, `icon-512.png`: only for installing it as an app from GitHub Pages + (`https://bpmdata.github.io/EOMD/tapmarks/tapmarks.html`). The page adds the manifest and registers `sw.js` only + when served over http/https, so a double-clicked copy never tries to load them. +- `tests/qa.js`: headless check on a made-up click track (timing fix, live key presses while playing, holds, undo, + delete, drag, on/off switch, export/import, autosave). Run it after any change to `tapmarks.html`: + `node tapmarks/tests/qa.js ` (needs Playwright; `CHROME_PATH=` points it at a Chrome or headless-shell + binary when Playwright's own browser download is blocked, as it is in cloud sessions). + +## Reading a `.tapmarks.json` (for a music video or any piece) +```json +{ + "format": "eomd-tapmarks", "version": 1, + "audio": {"file":"song.mp3","duration":213.421,"sampleRate":48000}, + "timingFix": {"on":true,"reachMs":100,"lateByMs":0}, + "keys": [ {"key":"Space","label":"snowflake splash","note":"…","color":"#ffd500","count":42} ], + "marks": [ {"key":"Space","t":12.345,"tap":12.381,"fix":"snapped","shiftMs":-36}, {"key":"H","t":40.2,"tap":40.2,"fix":"tapped","hold":1.25} ] +} +``` +- `t` (seconds from the start of the decoded song) is the time to use. `tap` is when the key was pressed, as heard. + `fix`: `snapped` (moved onto a clear hit in the music), `tapped` (as pressed, or moved by the "late by" setting; + `shiftMs` says how far), `moved` (the client dragged or nudged it: their word, never adjust it). +- `hold`: present when the key was held 0.25 s or longer; the moment lasts that long. +- **Each key's `label` and `note` are the client's instructions for that key** (e.g. "reserve the really aggressive + splash and shake effect for this key"). Read them before choosing what a key's marks trigger, and follow them like + any brief text: word for word, never invented. +- Small timing corrections when you use the marks are fine, but say so, keep them obvious from the waveform, and never + touch `moved` marks. If `timingFix.on` is false the client wants their taps exactly as pressed: don't snap them. +- An MP3's decoded start can differ from another decoder's by a few ms (encoder delay). If marks will drive a player + that plays the MP3 through an `

+ + + + + No song yet + + 0:00.000 / 0:00.000 + + + + + + + + +
+ +
+ +
+ Drop an MP3 or WAV here, or press Open song + Then press Enter to play, and tap any letter, number or Space at the moments you want marked. + Each key gets its own row. Nothing leaves this computer. +
+
+
+ + + + + + + +
+
+
+ +
+ + + + diff --git a/tapmarks/tests/qa.js b/tapmarks/tests/qa.js new file mode 100644 index 0000000..7610727 --- /dev/null +++ b/tapmarks/tests/qa.js @@ -0,0 +1,285 @@ +// TAP MARKS QA: loads tapmarks.html in headless Chromium with a made-up click track (clicks at known times over a +// quiet hum) and checks the timing fix, real key presses while playing, holds, undo, delete, dragging, the on/off +// switch, export/import and the per-song autosave. Writes a screenshot and report.json to outDir. +// node tapmarks/tests/qa.js [outDir] +// Needs Playwright (npm i playwright). CHROME_PATH=/path/to/chrome uses that browser instead of Playwright's own. +// Exit code 1 if any check fails. Real speakers, real keyboards and real songs are still a person's job. +const { chromium } = require('playwright'); +const path = require('path'); +const fs = require('fs'); + +const SR = 48000; +const DUR = 12; +const CLICKS = [1.0, 1.5, 2.0, 2.5, 3.25, 4.0, 4.5, 5.0, 6.0, 7.0, 7.5, 8.0, 9.0, 10.0]; +const QUIET = [10.4, 11.4]; // a stretch with no clear hit: taps here must stay where they were pressed + +function clickTrack() { + const n = SR * DUR; + const x = new Float32Array(n); + let seed = 7; + const rnd = () => ((seed = (seed * 1103515245 + 12345) & 0x7fffffff) / 0x7fffffff) * 2 - 1; + for (let i = 0; i < n; i++) { + const t = i / SR; + x[i] = 0.05 * Math.sin(2 * Math.PI * 110 * t) + 0.03 * Math.sin(2 * Math.PI * 165 * t) + 0.004 * rnd(); + } + for (const c of CLICKS) { + const s0 = Math.round(c * SR); + for (let i = 0; i < SR * 0.08; i++) { + const e = Math.exp(-i / (SR * 0.012)); + x[s0 + i] += 0.7 * e * (0.6 * rnd() + 0.4 * Math.sin((2 * Math.PI * 1800 * i) / SR)); + } + } + // 16-bit mono WAV + const buf = Buffer.alloc(44 + n * 2); + buf.write('RIFF', 0); + buf.writeUInt32LE(36 + n * 2, 4); + buf.write('WAVEfmt ', 8); + buf.writeUInt32LE(16, 16); + buf.writeUInt16LE(1, 20); + buf.writeUInt16LE(1, 22); + buf.writeUInt32LE(SR, 24); + buf.writeUInt32LE(SR * 2, 28); + buf.writeUInt16LE(2, 32); + buf.writeUInt16LE(16, 34); + buf.write('data', 36); + buf.writeUInt32LE(n * 2, 40); + for (let i = 0; i < n; i++) buf.writeInt16LE(Math.round(Math.max(-1, Math.min(1, x[i])) * 32767), 44 + i * 2); + return buf; +} + +(async () => { + const outDir = process.argv[2] || 'tapmarks-qa'; + fs.mkdirSync(outDir, { recursive: true }); + const wav = clickTrack(); + fs.writeFileSync(path.join(outDir, 'clicks.wav'), wav); + const b64 = wav.toString('base64'); + const results = []; + const check = (name, ok, detail = '') => { + results.push({ name, ok: !!ok, detail }); + console.log((ok ? 'PASS ' : 'FAIL ') + name + (detail ? ': ' + detail : '')); + }; + const b = await chromium.launch({ + executablePath: process.env.CHROME_PATH || undefined, + args: ['--autoplay-policy=no-user-gesture-required'], + }); + const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } }); + const page = await ctx.newPage(); + const errors = []; + page.on('pageerror', (e) => errors.push(e.message)); + page.on('console', (m) => m.type() === 'error' && errors.push(m.text())); + const file = 'file://' + path.resolve(__dirname, '..', 'tapmarks.html'); + const load = async () => { + await page.goto(file); + await page.waitForFunction('window.TAPMARKS'); + await page.evaluate(async (b64) => { + const bin = atob(b64); + const u = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; i++) u[i] = bin.charCodeAt(i); + await window.TAPMARKS.load(u.buffer, 'clicks.wav'); + }, b64); + await page.waitForFunction('window.TAPMARKS.ready()', null, { timeout: 60000 }); + }; + const T = (fn, arg) => page.evaluate(fn, arg); + + await load(); + + // 1. clear hits found where the clicks are, and nowhere else + const onsets = await T(() => window.TAPMARKS.clearOnsets().map((o) => o.t)); + const errs = CLICKS.map((c) => Math.min(...onsets.map((o) => Math.abs(o - c))) * 1000); + check( + 'every click found as a clear hit, within 2 ms', + Math.max(...errs) <= 2, + 'worst ' + Math.max(...errs).toFixed(1) + ' ms' + ); + const extra = onsets.filter((o) => Math.min(...CLICKS.map((c) => Math.abs(o - c))) > 0.02); + check('no clear hits where there are no clicks', extra.length === 0, extra.length + ' extra'); + + // 2. taps a bit off snap to the click; taps with nothing near stay put + const offs = [0.06, -0.03, 0.045, 0.09, -0.07]; + const taps = offs.map((o, i) => ({ key: 'Space', tap: CLICKS[i] + o, want: CLICKS[i] })); + taps.push({ key: 'K', tap: QUIET[0], want: QUIET[0] }, { key: 'K', tap: QUIET[1], want: QUIET[1] }); + await T((taps) => taps.forEach((t) => window.TAPMARKS.tapAt(t.key, t.tap)), taps); + let marks = await T(() => window.TAPMARKS.state.marks.map((m) => ({ ...m }))); + const snapErr = taps.map((t, i) => Math.abs(marks[i].t - t.want) * 1000); + check( + 'late and early taps snap onto the click (within 2 ms)', + snapErr.slice(0, 5).every((e) => e <= 2), + snapErr.map((e) => e.toFixed(1)).join(', ') + ); + check( + 'taps with no clear hit nearby stay where pressed', + marks[5].fix === 'tapped' && snapErr[5] < 1 && snapErr[6] < 1 + ); + check( + 'the press time is kept', + marks.every((m, i) => Math.abs(m.tap - taps[i].tap) < 0.0011) + ); + + // 3. timing fix off: exactly as pressed; back on: snapped again + await T(() => window.TAPMARKS.setFix(false)); + marks = await T(() => window.TAPMARKS.state.marks.map((m) => ({ ...m }))); + check( + 'timing fix off uses every tap as pressed', + marks.every((m) => m.t === m.tap && m.fix === 'tapped') + ); + await T(() => window.TAPMARKS.setFix(true)); + marks = await T(() => window.TAPMARKS.state.marks.map((m) => ({ ...m }))); + check( + 'timing fix back on snaps them again', + marks.slice(0, 5).every((m) => m.fix === 'snapped') + ); + // a tap beyond the reach doesn't snap + await T(() => window.TAPMARKS.setFix(true, 40)); + marks = await T(() => window.TAPMARKS.state.marks.map((m) => ({ ...m }))); + check( + 'a 60 ms-off tap does not snap when the reach is 40 ms', + marks[0].fix === 'tapped' && marks[1].fix === 'snapped' + ); + await T(() => window.TAPMARKS.setFix(true, 100)); + + // 4. undo, redo, take back the last mark + const n0 = marks.length; + await T(() => window.TAPMARKS.deleteLast()); + let n = await T(() => window.TAPMARKS.state.marks.length); + check('Backspace takes back the last mark', n === n0 - 1); + await T(() => window.TAPMARKS.undo()); + n = await T(() => window.TAPMARKS.state.marks.length); + check('undo brings it back', n === n0); + + // 5. real key presses while the song plays (headless timing, so loose limits) + await T(() => window.TAPMARKS.state.marks.splice(0)); + await page.keyboard.press('Home'); + await page.keyboard.press('Enter'); + await page.waitForFunction('window.TAPMARKS.playing() && window.TAPMARKS.pos() > 0.05'); + const pressed = []; + for (const c of CLICKS.slice(0, 8)) { + // aim 40 ms after each click, like a person reacting a little late + for (;;) { + const p = await T(() => window.TAPMARKS.pos()); + if (p >= c + 0.04) break; + await page.waitForTimeout(Math.max(0, Math.min(40, (c + 0.04 - p) * 1000 - 8))); + } + if (c === 4.0) { + await page.keyboard.down('h'); + await page.waitForTimeout(400); + await page.keyboard.up('h'); + } else await page.keyboard.press('Space'); + pressed.push(c); + } + await page.keyboard.press('Enter'); + const playedMarks = await T(() => window.TAPMARKS.state.marks.map((m) => ({ ...m }))); + check( + 'a mark for every key press while playing', + playedMarks.length === pressed.length, + playedMarks.length + ' of ' + pressed.length + ); + const live = playedMarks.map((m) => ({ + key: m.key, + raw: ((m.tap - nearest(m.tap)) * 1000).toFixed(0), + err: ((m.t - nearest(m.t)) * 1000).toFixed(1), + hold: m.hold, + })); + check( + 'live taps snapped onto the clicks (within 2 ms)', + playedMarks.every((m) => Math.abs(m.t - nearest(m.t)) <= 0.002), + JSON.stringify(live) + ); + const held = playedMarks.find((m) => m.key === 'H'); + check( + 'holding a key records how long', + held && held.hold > 0.3 && held.hold < 0.6, + held ? 'held ' + held.hold + ' s' : 'no H mark' + ); + const lanes = await T(() => window.TAPMARKS.state.lanes.map((l) => l.key)); + check('each key gets its own row', lanes.includes('Space') && lanes.includes('H'), lanes.join(',')); + + // 6. drag a mark with the mouse, then double-click hands it back to the timing fix + await page.keyboard.press('Home'); + const box = await page.locator('#view').boundingBox(); + const geo = await T(() => ({ li: window.TAPMARKS.state.lanes.findIndex((l) => l.key === 'Space') })); + await page.screenshot({ path: path.join(outDir, 'tapmarks.png') }); + // find the mark's pixel by scanning: the lane row y and x from the hit test + const y = box.y + 20 + 150 + geo.li * 30 + 15; + let found = null; + for (let x = box.x + 72; x < box.x + box.width; x += 2) { + const id = await page.evaluate( + ([x, y]) => { + const ev = new PointerEvent('pointermove', { clientX: x, clientY: y, bubbles: true }); + document.getElementById('view').dispatchEvent(ev); + return document.getElementById('view').style.cursor; + }, + [x, y] + ); + if (id === 'ew-resize') { + found = x; + break; + } + } + check('a mark can be found under the mouse', found != null); + if (found != null) { + await page.mouse.move(found + 1, y); + await page.mouse.down(); + const picked = await T(() => window.TAPMARKS.state.sel); + const before = await T((id) => window.TAPMARKS.state.marks.find((x) => x.id === id).t, picked); + await page.mouse.move(found + 21, y, { steps: 4 }); + await page.mouse.up(); + const after = await T((id) => { + const m = window.TAPMARKS.state.marks.find((x) => x.id === id); + return { t: m.t, moved: m.moved }; + }, picked); + check('dragging moves the mark later', after.moved && after.t > before + 0.05, before + ' -> ' + after.t); + await page.mouse.dblclick(found + 21, y); + const back = await T((id) => window.TAPMARKS.state.marks.find((x) => x.id === id), picked); + check('double-click hands it back to the timing fix', !back.moved && Math.abs(back.t - before) < 0.002, back.t); + } + + // 7. notes per key, export, import + await page.locator('.lane[data-key="H"] input[type=text]').fill('big splash and shake'); + await page + .locator('.lane[data-key="H"] textarea') + .fill('reserve the really aggressive splash and shake effect for this key'); + await page.keyboard.press('Escape'); + const text = await T(() => window.TAPMARKS.exportText()); + fs.writeFileSync(path.join(outDir, 'clicks.tapmarks.json'), text); + const j = JSON.parse(text); + check( + 'export is a Tap Marks file with the song, keys, notes and marks', + j.format === 'eomd-tapmarks' && + j.audio.file === 'clicks.wav' && + j.keys.find((k) => k.key === 'H').note.startsWith('reserve') && + j.marks.length === playedMarks.length + ); + check( + 'exported marks are in time order with t, tap and fix', + j.marks.every((m, i) => (i === 0 || m.t >= j.marks[i - 1].t) && 't' in m && 'tap' in m && m.fix) + ); + await T(() => window.TAPMARKS.state.marks.splice(0)); + await T((txt) => window.TAPMARKS.importText(txt), text); + const re = await T(() => window.TAPMARKS.state.marks.length); + check('import brings the marks back', re === j.marks.length); + + // 8. closing and reopening the page brings the marks back for the same song + await page.waitForTimeout(700); + await load(); + const kept = await T(() => ({ + n: window.TAPMARKS.state.marks.length, + note: (window.TAPMARKS.state.lanes.find((l) => l.key === 'H') || {}).note, + })); + check( + 'marks and notes survive closing the page', + kept.n === j.marks.length && kept.note && kept.note.startsWith('reserve'), + JSON.stringify(kept) + ); + + check('no page errors', errors.length === 0, errors.join(' | ')); + await page.screenshot({ path: path.join(outDir, 'tapmarks-reopened.png') }); + await b.close(); + fs.writeFileSync(path.join(outDir, 'report.json'), JSON.stringify(results, null, 2)); + const bad = results.filter((r) => !r.ok); + console.log(bad.length ? bad.length + ' check(s) failed' : 'all ' + results.length + ' checks passed'); + process.exit(bad.length ? 1 : 0); +})(); + +function nearest(t) { + return CLICKS.reduce((a, c) => (Math.abs(c - t) < Math.abs(a - t) ? c : a), CLICKS[0]); +} diff --git a/tools/check_stage_reads.py b/tools/check_stage_reads.py index 138ac88..475705e 100644 --- a/tools/check_stage_reads.py +++ b/tools/check_stage_reads.py @@ -20,7 +20,7 @@ 'audio/', 'score/', 'jukebox/', 'tests/hashes.json', 'notes/audio-ports.md', 'proj/*/music.js', 'proj/cdrom/track2-r2.js', 'proj/cdrom/intro-motif.md', # tools - 'tools/', + 'tools/', 'tapmarks/', ] # every proj// is restricted too (handled in code), and so are the per-piece STATUS.md files BEFORE_GATE = {'efficient': {'interview', 'brief'},