# Drum machine ## What this builds A drum sequencer you can jam with at once: a grid of steps, a few voices, a tempo, and a play control. The samples are original or permissively licensed, not a ripped commercial machine, and the product does not use a trademarked model number in its id or its name. A fixture pattern is rendered offline to a buffer; onset times and the bar length must match the grid. UI tests cover painting a pattern. No audio hardware is required in the checks. Read `spekkr.inputs.json` first. `title` labels the grid. `bpm` and `steps` size the bar. `kit` chooses the samples. `swing` and `count` change timing. Renders are offline. ## Out of scope - A trademarked drum-machine model, or ripped commercial samples. - A live speaker or MIDI device in the checks. - Network or a sample marketplace in the checks. ## Requirements Each requirement has an id. Checks name the id they cover. ### R1. Onsets and bar length - A bar is `60 / bpm * 4` seconds (4/4). A step is that length divided by `steps`. - `fixtures/pattern-a.json` at 120 bpm, 16 steps, swing off, rendered offline, has onsets (first sample of each hit above a threshold) within 2 ms of the listed step times, and a total length of one bar within 2 ms (or two bars if the fixture says so). - With `swing` on, even steps (1-based steps 2, 4, …) are late by 16% of a step, within 2 ms. Accept when: pattern A's onsets and length match at 120 and at 80 bpm, with swing off and on. ### R2. UI and files - A UI script paints pattern A onto a clear grid and reads it back as the same cells. - Goldens: a clear grid, pattern A, the box kit's pads, and a playing head at step 5, buffer time frozen. - One command renders, checks onsets, paints the grid, and writes the frames. No audio device. Samples are local. Accept when: the read-back matches, both kits' pattern A onsets pass, and the frames match the goldens. ### R3. Inputs - The build reads `spekkr.inputs.json`. Settings label the UI, options turn features on or off, and a swap must be one of its choices. - A value outside a stated range, or a swap that is not one of its choices, is refused before the app starts its checks, with a message that names the key. Accept when: the default inputs render, an illegal swap is refused by name, and changing a visible setting (for example the title) shows up in a later check. ### R4. Checks and report - One command runs every acceptance check at the defaults and at the person's inputs, including golden frames where a requirement asks for them. - Checks do not need a network, a paid API, or physical hardware. Accept when: the command passes at the defaults, and a deliberately broken fixture or a wrong price fails it. ## Verification A fixture pattern renders an offline audio buffer whose onset times and bar length match the grid, within 2 ms, including a swing case. UI tests paint and read back the pattern. Samples are original or permissively licensed. No audio hardware and no trademarked model name. ## Definition of done - Every acceptance check above runs from one command, and all pass at the person's inputs. - A README says how to paint a pattern, how the kits are licensed, and how to run the checks.