the ultimate vocal synthesizer - sing, speak, beatbox, and more
Rust
Vector display, phase 3: Beatbox
Jameson Hodge10f263851df2
diff --git a/src/ui/App.tsx b/src/ui/App.tsxindex 65aac01..27b0ef8 100644--- a/src/ui/App.tsx+++ b/src/ui/App.tsx@@ -17,7 +17,7 @@ import { Spectrogram } from "./components/Spectrogram.tsx";import { Scope } from "./components/Scope.tsx";import { CreatureTubes } from "./components/CreatureTubes.tsx";import { creatureById } from "../wasm/engine.ts";-import { BeatboxPanel, BeatOverlay } from "./components/BeatboxPanel.tsx";+import { BeatboxRight, BeatOverlay, beatInfo, beatSlots } from "./components/BeatboxPanel.tsx";import { SingRight, singInfo } from "./components/SingPanel.tsx";import { playDemo, DEMO_SONGS } from "./singing.ts";import type { Mode } from "./store.ts";@@ -157,7 +157,7 @@ function LeftScreen() {label={bestiary ? "Live creature airway" : "Live vocal tract"}tools={<ViewToggles />}>- {bestiary ? <CreatureView /> : mode === "speak" ? <AnatomyView slots={speechSlots} info={speechInfo} /> : mode === "sing" ? <AnatomyView info={singInfo} /> : <AnatomyView />}+ {bestiary ? <CreatureView /> : mode === "speak" ? <AnatomyView slots={speechSlots} info={speechInfo} /> : mode === "sing" ? <AnatomyView info={singInfo} /> : mode === "beatbox" ? <AnatomyView slots={beatSlots} info={beatInfo} showFormants={false} /> : <AnatomyView />}{mode === "beatbox" && <BeatOverlay />}<StartPrompt /></Screen>@@ -213,7 +213,6 @@ function LegacyRight() {function Deck() {const mode = useStore((s) => s.mode);if (mode === "bestiary") return <BestiaryPanel />;- if (mode === "beatbox") return <BeatboxPanel />;return null;}@@ -224,7 +223,7 @@ export function App() {<TopBar /><main className={`wall wall-${mode}`}><LeftScreen />- {mode === "play" ? <PlayRight /> : mode === "speak" ? <SpeakRight /> : mode === "sing" ? <SingRight /> : <LegacyRight />}+ {mode === "play" ? <PlayRight /> : mode === "speak" ? <SpeakRight /> : mode === "sing" ? <SingRight /> : mode === "beatbox" ? <BeatboxRight /> : <LegacyRight />}</main><Deck /></div>diff --git a/src/ui/components/AnatomyView.tsx b/src/ui/components/AnatomyView.tsxindex 79eecb2..4a34262 100644--- a/src/ui/components/AnatomyView.tsx+++ b/src/ui/components/AnatomyView.tsx@@ -42,7 +42,9 @@ export const articulatorSlots: SlotsFn = (m, a, f, formants) => [f.velumPort > 0.02 ? { label: "Soft palate", value: f.velumPort.toFixed(2), unit: "cm²", color: V.white } : { label: "Soft palate", value: "Shut", color: V.white },];-export function AnatomyView(props: { slots?: SlotsFn; info?: InfoFn }) {+export function AnatomyView(props: { slots?: SlotsFn; info?: InfoFn; showFormants?: boolean }) {+ const formantsRef = useRef(props.showFormants ?? true);+ formantsRef.current = props.showFormants ?? true;const slotsRef = useRef<SlotsFn>(props.slots ?? articulatorSlots);slotsRef.current = props.slots ?? articulatorSlots;const infoRef = useRef<InfoFn>(props.info ?? tractInfo);@@ -96,7 +98,7 @@ export function AnatomyView(props: { slots?: SlotsFn; info?: InfoFn }) {ctx.fillStyle = "#000";ctx.fillRect(0, 0, canvas.width, canvas.height);ctx.setTransform(dpr, 0, 0, dpr, 0, 0);- r.draw(ctx, m, f, a, tele, st.view, { hover: hoverRef.current, drag: dragRef.current?.id ?? null, dt, formants, slots: slotsRef.current(m, a, f, formants, tele), info: info.map((s) => s.toUpperCase()) });+ r.draw(ctx, m, f, a, tele, st.view, { hover: hoverRef.current, drag: dragRef.current?.id ?? null, dt, formants: formantsRef.current ? formants : [], slots: slotsRef.current(m, a, f, formants, tele), info: info.map((s) => s.toUpperCase()) });glow.apply(canvas, ctx, dpr);}raf = requestAnimationFrame(loop);diff --git a/src/ui/components/BeatboxPanel.tsx b/src/ui/components/BeatboxPanel.tsxindex ad28f04..847a8a8 100644--- a/src/ui/components/BeatboxPanel.tsx+++ b/src/ui/components/BeatboxPanel.tsx@@ -2,8 +2,12 @@ import { useEffect, useRef, useState } from "react";import { useStore } from "../store.ts";import { engine } from "../../audio/AudioEngine.ts";import { BEAT_SOUNDS, BEAT_PRESETS, formatBeat, parseBeat, type Airstream } from "../../wasm/engine.ts";-import { Slider, Toggle } from "./Controls.tsx";import { Keys } from "./Keys.tsx";+import { Chip, Screen } from "./Screen.tsx";+import { EncoderPages } from "./Encoder.tsx";+import { Spectrogram } from "./Spectrogram.tsx";+import type { InfoFn, SlotsFn } from "./AnatomyView.tsx";+import { V } from "../colors.ts";const AIR: Record<Airstream, string> = {pulmonic: "Breath out",@@ -32,6 +36,16 @@ export function useBeatStep(): number {return step;}+/** Beatbox's readouts under the chin: the articulators a mouth drum uses */+export const beatSlots: SlotsFn = (_m, a, f) => [+ { label: "Jaw", value: a.jaw.toFixed(1), unit: "cm", color: V.red },+ { label: "Lips", value: a.lipAp < 0.05 ? "Sealed" : a.lipWidth < 0.55 ? "Round" : "Open", color: V.pink },+ { label: "Larynx", value: `${a.larynx >= 0 ? "+" : ""}${a.larynx.toFixed(1)}`, unit: "cm", color: V.green },+ { label: "Soft palate", value: f.velumPort > 0.02 ? "Open" : "Shut", color: V.white },+];+/** the big symbol owns the top right, so nothing else is written there */+export const beatInfo: InfoFn = () => [];+function Pads() {const beatHit = useStore((s) => s.beatHit);const [lit, setLit] = useState<string | null>(null);@@ -59,21 +73,17 @@ function Pads() {return () => window.removeEventListener("keydown", onKey);}, []);return (- <div className="panel pads-panel">- <h2>Sounds</h2>- <div className="pads">- {BEAT_SOUNDS.map((s, i) => (- <button key={s.id} className={`pad pad-${s.role}${lit === s.id ? " lit" : ""}`} onPointerDown={() => hit(s.id)} title={s.hint} aria-label={`${s.name}: ${s.hint}. Key ${(i + 1) % 10}`}>- <span className="pad-sym">{s.id}</span>- <span className="pad-name">{s.name}</span>- <span className="pad-air">{AIR[s.airstream]}</span>- <span className="pad-key" aria-hidden="true">- {(i + 1) % 10}- </span>- </button>- ))}- </div>- <p className="dim">Pads play a sound as soon as the mouth can shape it, about a tenth of a second. Keys hum a bass note under the beat.</p>+ <div className="pads">+ {BEAT_SOUNDS.map((s, i) => (+ <button key={s.id} className={`pad pad-${s.role}${lit === s.id ? " lit" : ""}`} onPointerDown={() => hit(s.id)} title={s.hint} aria-label={`${s.name}: ${s.hint}. Key ${(i + 1) % 10}`}>+ <span className="pad-sym">{s.id}</span>+ <span className="pad-name">{s.name}</span>+ <span className="pad-air">{AIR[s.airstream]}</span>+ <span className="pad-key" aria-hidden="true">+ {(i + 1) % 10}+ </span>+ </button>+ ))}</div>);}@@ -81,66 +91,86 @@ function Pads() {function Sequencer() {const beat = useStore((s) => s.beat);const toggle = useStore((s) => s.toggleBeatStep);+ const now = useBeatStep();+ return (+ <div className="seq-grid" style={{ "--steps": beat.steps.length } as React.CSSProperties} role="grid" aria-label="Beat pattern: one sound per step">+ {BEAT_SOUNDS.map((s) => (+ <div className="seq-row" role="row" key={s.id}>+ <span className="seq-label" role="rowheader">+ <b>{s.id}</b> {s.name}+ </span>+ {beat.steps.map((st, i) => {+ const on = st?.id === s.id;+ return (+ <button+ key={i}+ role="gridcell"+ className={`cell${on ? " on" : ""}${i === now ? " now" : ""}${i % 4 === 0 ? " downbeat" : ""}`}+ onClick={() => toggle(i, s.id)}+ aria-pressed={on}+ aria-label={`${s.name}, step ${i + 1}`}+ >+ {on && s.id === "m" && st?.note !== undefined ? <span className="cell-note">{noteName(st.note)}</span> : null}+ </button>+ );+ })}+ </div>+ ))}+ </div>+ );+}++function Transport() {+ const beat = useStore((s) => s.beat);const setTempo = useStore((s) => s.setBeatTempo);const setPlaying = useStore((s) => s.setBeatPlaying);const setSteps = useStore((s) => s.setBeatSteps);const loadPreset = useStore((s) => s.loadBeatPreset);const mic = useStore((s) => s.mic);const setMic = useStore((s) => s.setMic);- const now = useBeatStep();const [text, setText] = useState(() => formatBeat(beat.steps));const editing = useRef(false);useEffect(() => {if (!editing.current) setText(formatBeat(beat.steps));}, [beat.steps]);- const n = beat.steps.length;return (- <div className="panel seq-panel">- <div className="transport">+ <div className="transport">+ <div className="transport-top"><button className={`primary play${beat.playing ? " on" : ""}`} onClick={() => setPlaying(!beat.playing)} aria-pressed={beat.playing}>{beat.playing ? "Stop" : "Play beat"}</button>- <div className="transport-sliders">- <Slider label="Tempo" value={beat.bpm} min={60} max={180} onChange={(v) => setTempo({ bpm: Math.round(v) })} format={(v) => `${Math.round(v)} bpm`} />- <Slider label="Swing" value={beat.swing} min={0} max={0.6} onChange={(v) => setTempo({ swing: v })} format={(v) => `${Math.round(v * 100)} %`} />- </div>- <Toggle label="Close mic" checked={mic} onChange={setMic} />+ <Chip on={mic} onClick={() => setMic(!mic)}>+ Close mic+ </Chip>+ </div>+ <div className="transport-encoders">+ <EncoderPages+ label="Transport"+ columns={2}+ pages={[+ {+ name: "Tempo",+ encoders: [+ { label: "Tempo", value: beat.bpm, min: 60, max: 180, onChange: (v) => setTempo({ bpm: Math.round(v) }), format: (v) => ({ value: String(Math.round(v)), unit: "bpm" }) },+ { label: "Swing", value: beat.swing, min: 0, max: 0.6, onChange: (v) => setTempo({ swing: v }), format: (v) => ({ value: String(Math.round(v * 100)), unit: "%" }) },+ ],+ },+ ]}+ /></div><div className="examples presets" role="group" aria-label="Example beats">{BEAT_PRESETS.map((p) => (- <button key={p.name} className={`chip${beat.preset === p.name ? " on" : ""}`} onClick={() => loadPreset(p.name)}>+ <Chip key={p.name} on={beat.preset === p.name} toggle={false} onClick={() => loadPreset(p.name)}>{p.name}- </button>- ))}- </div>- <div className="seq-grid" style={{ "--steps": n } as React.CSSProperties} role="grid" aria-label="Beat pattern: one sound per step">- {BEAT_SOUNDS.map((s) => (- <div className="seq-row" role="row" key={s.id}>- <span className="seq-label" role="rowheader">- <b>{s.id}</b> {s.name}- </span>- {beat.steps.map((st, i) => {- const on = st?.id === s.id;- return (- <button- key={i}- role="gridcell"- className={`cell${on ? " on" : ""}${i === now ? " now" : ""}${i % 4 === 0 ? " downbeat" : ""}`}- onClick={() => toggle(i, s.id)}- aria-pressed={on}- aria-label={`${s.name}, step ${i + 1}`}- >- {on && s.id === "m" && st?.note !== undefined ? <span className="cell-note">{noteName(st.note)}</span> : null}- </button>- );- })}- </div>+ </Chip>))}</div><label className="sbn">- <span className="dim">Beat as text: B kick, t hat, Pf snare, K rimshot, ^K inward, ! click, m hum (m:43 sets its note), . rest</span>+ <span className="dim">Beat as text</span><inputvalue={text}+ title="B kick, t hat, Pf snare, K rimshot, ^K inward, ! click, m hum (m:43 sets its note), . rest"+ placeholder="B . t . | Pf . t ."spellCheck={false}onFocus={() => (editing.current = true)}onBlur={() => {@@ -158,21 +188,31 @@ function Sequencer() {);}-export function BeatboxPanel() {+/** Beatbox mode's right column: the step sequencer, the waterfall, the pads, the transport, the keys (hum bass). */+export function BeatboxRight() {+ const beat = useStore((s) => s.beat);return (- <>- <section className="beatbox">- <Pads />+ <div className="right right-beatbox">+ <Screen className="s-seq" title="Step sequencer" sub={`${beat.preset ?? "Your beat"} / ${beat.bpm} bpm`}><Sequencer />- </section>- <footer className="keys-bar">+ </Screen>+ <Screen className="s-wf" title="Spectrogram" sub="Last two seconds / newest in front">+ <Spectrogram />+ </Screen>+ <Screen className="s-pads" title="Pads" sub="Keys 1 to 0">+ <Pads />+ </Screen>+ <Screen className="s-transport" title="Transport">+ <Transport />+ </Screen>+ <Screen className="s-keys s-keys-compact" title="Keys" sub="Hum a bass note"><Keys />- </footer>- </>+ </Screen>+ </div>);}-/** The symbol of the sound being made, large over the anatomy, fading after each hit. */+/** The sound being made, in big outlined letters over the face, fading after each hit. */export function BeatOverlay() {const steps = useStore((s) => s.beat.steps);const playing = useStore((s) => s.beat.playing);@@ -184,6 +224,10 @@ export function BeatOverlay() {<div className="beat-overlay" aria-hidden="true" key={now}><span className="beat-sym">{cell.id}</span><span className="beat-name">{s?.name}</span>+ {s && <span className="beat-air">{AIR[s.airstream]}</span>}+ <span className="beat-step">+ Step {String(now + 1).padStart(2, "0")} / {steps.length}+ </span></div>);}diff --git a/src/ui/components/Encoder.tsx b/src/ui/components/Encoder.tsxindex 77bc500..552b125 100644--- a/src/ui/components/Encoder.tsx+++ b/src/ui/components/Encoder.tsx@@ -100,8 +100,12 @@ export interface EncoderPage {encoders: EncoderSpec[];}-/** Four encoders at a time, with page tabs. The page shown is presentation only. */-export function EncoderPages(props: { pages: EncoderPage[]; footer?: ReactNode; label: string }) {+/**+ * Four encoders at a time, with page tabs. The page shown is presentation only. Slots keep their+ * positions across pages (so a colour stays put); a single short page can use fewer columns.+ */+export function EncoderPages(props: { pages: EncoderPage[]; footer?: ReactNode; label: string; columns?: number }) {+ const cols = props.columns ?? 4;const [page, setPage] = useState(0);const p = props.pages[Math.min(page, props.pages.length - 1)];return (@@ -115,8 +119,8 @@ export function EncoderPages(props: { pages: EncoderPage[]; footer?: ReactNode;))}</div>)}- <div className="enc-row" role="group" aria-label={p.name}>- {[0, 1, 2, 3].map((i) => (p.encoders[i] ? <Encoder key={`${p.name}-${p.encoders[i].label}`} {...p.encoders[i]} slot={i} /> : <div key={`empty-${i}`} className="encoder empty" aria-hidden="true" />))}+ <div className="enc-row" role="group" aria-label={p.name} style={{ gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))` }}>+ {Array.from({ length: cols }, (_, i) => i).map((i) => (p.encoders[i] ? <Encoder key={`${p.name}-${p.encoders[i].label}`} {...p.encoders[i]} slot={i} /> : <div key={`empty-${i}`} className="encoder empty" aria-hidden="true" />))}</div>{props.footer && <div className="enc-footer">{props.footer}</div>}</div>diff --git a/src/ui/components/Spectrogram.tsx b/src/ui/components/Spectrogram.tsxindex 4ae49a8..f3d63b2 100644--- a/src/ui/components/Spectrogram.tsx+++ b/src/ui/components/Spectrogram.tsx@@ -1,84 +1,83 @@import { useRef } from "react";-import { useCanvasLoop, font } from "../useCanvas.ts";+import { usePhosphor } from "../usePhosphor.ts";import { engine } from "../../audio/AudioEngine.ts";import { useStore } from "../store.ts";-import { C, hot } from "../colors.ts";+import { V, mix } from "../colors.ts";+import { beam, label, seg } from "../render/vector.ts";-const FMIN = 15, FMAX = 16000;-const SPEED = 64; // px per second+const FMIN = 60, FMAX = 12000;const DB_LO = -100, DB_HI = -30;+/** slices kept, and how often one is taken (s): about two seconds of sound */+const SLICES = 28;+const EVERY = 0.07;+/** frequency points per slice (log-spaced) */+const POINTS = 96;-/** Scrolling spectrogram of the output on a log-frequency axis, energy in the hot scale. */+/**+ * Waterfall spectrogram (as on the Fairlight's 3D page): the last couple of seconds as stacked+ * spectral slices, newest in front in white, older ones behind in fading amber, each slice+ * hiding what is behind it.+ */export function Spectrogram() {- const st = useRef<{ off: HTMLCanvasElement | null; bins: Float32Array | null; rows: Int32Array | null; acc: number }>({ off: null, bins: null, rows: null, acc: 0 });- const ref = useCanvasLoop(({ ctx, w, h, dt }) => {+ const st = useRef<{ slices: Float32Array[]; bins: Float32Array | null; acc: number }>({ slices: [], bins: null, acc: EVERY });+ const ref = usePhosphor(({ ctx, w, h, dt }) => {const s = st.current;- const axisW = 30;- const pw = Math.max(1, Math.floor(w - axisW)), ph = Math.max(1, Math.floor(h - 4));- if (!s.off || s.off.width !== pw || s.off.height !== ph) {- s.off = document.createElement("canvas");- s.off.width = pw;- s.off.height = ph;- const oc = s.off.getContext("2d")!;- oc.fillStyle = "#000";- oc.fillRect(0, 0, pw, ph);- s.rows = null;- }- const oc = s.off.getContext("2d")!;const an = engine.analyserFast;- s.acc += dt * SPEED;- const cols = Math.min(pw, Math.floor(s.acc));- s.acc -= cols;- if (cols > 0) {- oc.drawImage(s.off, -cols, 0);- const img = oc.createImageData(cols, ph);- if (an && useStore.getState().started) {+ const started = useStore.getState().started;+ s.acc += dt;+ if (s.acc >= EVERY) {+ s.acc %= EVERY;+ const slice = new Float32Array(POINTS);+ if (an && started) {const n = an.frequencyBinCount;if (!s.bins || s.bins.length !== n) s.bins = new Float32Array(n);an.getFloatFrequencyData(s.bins as Float32Array<ArrayBuffer>);const binHz = engine.sampleRate / an.fftSize;- if (!s.rows || s.rows.length !== ph * 2) {- // bin range covered by each pixel row (top = high frequencies)- s.rows = new Int32Array(ph * 2);- for (let y = 0; y < ph; y++) {- const fHi = FMAX * Math.pow(FMIN / FMAX, y / ph), fLo = FMAX * Math.pow(FMIN / FMAX, (y + 1) / ph);- const k0 = Math.max(1, Math.floor(fLo / binHz)), k1 = Math.min(n - 1, Math.max(k0, Math.ceil(fHi / binHz)));- s.rows[2 * y] = k0;- s.rows[2 * y + 1] = k1;- }- }- const b = s.bins, rows = s.rows;- for (let y = 0; y < ph; y++) {+ for (let i = 0; i < POINTS; i++) {+ const f0 = FMIN * Math.pow(FMAX / FMIN, i / POINTS), f1 = FMIN * Math.pow(FMAX / FMIN, (i + 1) / POINTS);let db = -Infinity;- for (let k = rows[2 * y]; k <= rows[2 * y + 1]; k++) if (b[k] > db) db = b[k];- const u = (db - DB_LO) / (DB_HI - DB_LO);- const [r, g, bl] = hot(u > 0 ? Math.pow(u, 1.5) : 0);- for (let x = 0; x < cols; x++) {- const i = (y * cols + x) * 4;- img.data[i] = r;- img.data[i + 1] = g;- img.data[i + 2] = bl;- img.data[i + 3] = 255;- }+ for (let k = Math.max(1, Math.floor(f0 / binHz)); k <= Math.min(n - 1, Math.ceil(f1 / binHz)); k++) db = Math.max(db, s.bins[k]);+ slice[i] = Math.max(0, Math.min(1, (db - DB_LO) / (DB_HI - DB_LO)));}- } else for (let i = 3; i < img.data.length; i += 4) img.data[i] = 255;- oc.putImageData(img, pw - cols, 0);+ }+ s.slices.push(slice);+ if (s.slices.length > SLICES) s.slices.shift();+ }+ const left = 26, right = w - 70, base = h - 22;+ const depthX = Math.min(90, (right - left) * 0.18), depthY = Math.min(h * 0.42, 70);+ const frontW = right - left - depthX;+ const amp = Math.max(20, h - 22 - depthY - 12);+ const n = s.slices.length;+ // back to front: fill black under each slice, then stroke it, so nearer slices hide farther ones+ for (let k = 0; k < n; k++) {+ const age = n - 1 - k; // 0 = newest+ const ox = left + (age / SLICES) * depthX, oy = base - (age / SLICES) * depthY;+ const sl = s.slices[k];+ const p = new Path2D();+ p.moveTo(ox, oy);+ for (let i = 0; i < POINTS; i++) p.lineTo(ox + (i / (POINTS - 1)) * frontW, oy - Math.pow(sl[i], 1.4) * amp);+ const fill = new Path2D(p);+ fill.lineTo(ox + frontW, oy);+ fill.closePath();+ ctx.save();+ ctx.globalCompositeOperation = "source-over";+ ctx.fillStyle = "#000";+ ctx.fill(fill);+ ctx.restore();+ const fade = 1 - age / SLICES;+ beam(ctx, p, age === 0 ? V.white : mix("#6b4410", V.amber, fade), age === 0 ? 1.4 : 1, { alpha: age === 0 ? 1 : 0.25 + 0.6 * fade, hot: age === 0 });}- ctx.clearRect(0, 0, w, h);- ctx.drawImage(s.off, 0, 2);- // frequency axis- ctx.font = font(10.5);- ctx.fillStyle = C.textDim;- ctx.strokeStyle = "rgba(255,255,255,0.10)";- const fy = (f: number) => 2 + (Math.log(FMAX / f) / Math.log(FMAX / FMIN)) * ph;- for (const [f, label] of [[20, "20"], [100, "100"], [1000, "1k"], [10000, "10k"]] as const) {- const y = fy(f);- ctx.beginPath();- ctx.moveTo(0, y);- ctx.lineTo(pw, y);- ctx.stroke();- ctx.fillText(label, pw + 5, Math.min(h - 2, Math.max(10, y + 4)));+ // axes: frequency along the front, time going back+ seg(ctx, left, base, left + frontW, base, V.blueDim, 1);+ seg(ctx, left + frontW, base, right, base - depthY, V.blueDim, 1, { dash: [2, 4] });+ for (const [f, t] of [[100, "100"], [1000, "1K"], [10000, "10K"]] as const) {+ const x = left + (Math.log(f / FMIN) / Math.log(FMAX / FMIN)) * frontW;+ seg(ctx, x, base, x, base + 4, V.blueDim, 1);+ label(ctx, t, x, base + 15, { size: 9, color: V.blueMid, align: "center", ls: 0.1 });}+ label(ctx, "NOW", left + frontW + 6, base + 3, { size: 9, color: V.blueMid, ls: 0.14 });+ label(ctx, `${(SLICES * EVERY).toFixed(0)} S AGO`, right + 4, base - depthY + 3, { size: 9, color: V.blueDim, ls: 0.14 });+ if (!started) label(ctx, "START AUDIO TO SEE THE SOUND", left, 24, { size: 9, color: V.blueMid, ls: 0.16 });});- return <canvas ref={ref} className="instrument-canvas" aria-label="Spectrogram of the output" role="img" />;+ return <canvas ref={ref} className="instrument-canvas" aria-label="Waterfall spectrogram of the last two seconds of output" role="img" />;}diff --git a/src/ui/styles.css b/src/ui/styles.cssindex 0ca1c78..7f78da0 100644--- a/src/ui/styles.css+++ b/src/ui/styles.css@@ -1963,6 +1963,10 @@ input[type="range"]::-moz-range-thumb {.keys-bar .keys-row .keys {flex: none;}+ .beat-overlay {+ top: 10px;+ bottom: auto;+ }}@media (max-width: 640px) {@@ -2351,3 +2355,332 @@ input[type="range"]::-moz-range-thumb {grid-template-areas: "roll" "lyrics" "spec" "voice" "keys";}}++/* ---------- Beatbox */+.right-beatbox {+ grid-template-columns: minmax(0, 392fr) minmax(0, 292fr);+ grid-template-rows: minmax(0, 236fr) minmax(0, 176fr) minmax(0, 318fr) minmax(0, 102fr);+ grid-template-areas: "seq seq" "wf wf" "pads transport" "keys keys";+}++.s-seq { grid-area: seq; }+.s-wf { grid-area: wf; }+.s-pads { grid-area: pads; }+.s-transport { grid-area: transport; }++/* the sequencer as a glowing grid, hits marked with an X (the film's tic-tac-toe board) */+.s-seq .screen-body {+ overflow-x: auto;+}++.s-seq .seq-grid {+ position: absolute;+ inset: 0;+ padding: 4px 14px 10px;+ display: grid;+ grid-auto-rows: minmax(0, 1fr);+ gap: 0;+ min-width: 560px;+}++.s-seq .seq-row {+ display: grid;+ grid-template-columns: 116px repeat(var(--steps), minmax(0, 1fr));+ gap: 0;+ align-items: stretch;+}++.s-seq .seq-label {+ display: flex;+ align-items: center;+ gap: 8px;+ font-size: 9px;+ letter-spacing: 0.14em;+ text-transform: uppercase;+ color: var(--blue-dim);+ white-space: nowrap;+ overflow: hidden;+}++.s-seq .seq-label b {+ min-width: 26px;+ font-weight: 300;+ font-size: 12px;+ letter-spacing: 0.02em;+ text-transform: none;+ color: var(--blue);+}++.s-seq .cell {+ position: relative;+ height: auto;+ min-height: 12px;+ background: transparent;+ border: 0;+ border-left: 1px solid var(--frame);+ border-top: 1px solid var(--frame);+ border-radius: 0;+ cursor: pointer;+}++.s-seq .seq-row:last-child .cell {+ border-bottom: 1px solid var(--frame);+}++.s-seq .cell:last-child {+ border-right: 1px solid var(--frame);+}++.s-seq .cell.downbeat {+ border-left-color: var(--blue-dim);+}++.s-seq .cell.on {+ background:+ linear-gradient(45deg, transparent calc(50% - 0.8px), var(--amber) calc(50% - 0.8px), var(--amber) calc(50% + 0.8px), transparent calc(50% + 0.8px)) center / min(14px, 60%) min(14px, 60%) no-repeat,+ linear-gradient(-45deg, transparent calc(50% - 0.8px), var(--amber) calc(50% - 0.8px), var(--amber) calc(50% + 0.8px), transparent calc(50% + 0.8px)) center / min(14px, 60%) min(14px, 60%) no-repeat;+ box-shadow: inset 0 0 0 3px #000, inset 0 0 0 4px rgba(255, 179, 64, 0.8);+ filter: drop-shadow(0 0 2px rgba(255, 179, 64, 0.6));+}++.s-seq .cell.now {+ background-color: rgba(238, 246, 248, 0.06);+ box-shadow: inset 0 0 0 1px var(--white);+}++.s-seq .cell.on.now {+ box-shadow: inset 0 0 0 1px var(--white), inset 0 0 0 3px #000, inset 0 0 0 4px var(--amber);+}++.s-seq .cell-note {+ position: absolute;+ inset: auto 0 1px 0;+ font-size: 8px;+ color: var(--amber);+ letter-spacing: 0.04em;+}++/* pads: framed, the symbol large */+.s-pads .pads {+ position: absolute;+ inset: 0;+ padding: 6px 14px 12px;+ display: grid;+ grid-template-columns: repeat(2, minmax(0, 1fr));+ grid-auto-rows: minmax(0, 1fr);+ gap: 6px;+}++.s-pads .pad {+ position: relative;+ display: grid;+ grid-template-columns: auto 1fr;+ grid-template-rows: auto auto;+ column-gap: 10px;+ align-items: center;+ align-content: center;+ min-height: 0;+ padding: 4px 10px;+ background: transparent;+ border: 1px solid var(--frame);+ border-radius: 0;+ color: var(--blue);+ text-align: left;+ cursor: pointer;+}++.s-pads .pad:hover {+ border-color: var(--blue-dim);+}++.s-pads .pad.lit {+ border-color: var(--amber);+ color: var(--amber);+ box-shadow: 0 0 8px rgba(255, 179, 64, 0.5), inset 0 0 6px rgba(255, 179, 64, 0.3);+}++.s-pads .pad-sym {+ grid-row: 1 / 3;+ font-size: 19px;+ letter-spacing: 0.02em;+ text-transform: none;+ text-shadow: var(--glow-blue);+}++.s-pads .pad.lit .pad-sym {+ text-shadow: 0 0 3px rgba(255, 179, 64, 0.8);+}++.s-pads .pad-name {+ font-size: 9px;+ letter-spacing: 0.14em;+ text-transform: uppercase;+}++.s-pads .pad-air {+ font-size: 8px;+ letter-spacing: 0.12em;+ text-transform: uppercase;+ color: var(--blue-dim);+}++.s-pads .pad-key {+ position: absolute;+ top: 3px;+ right: 5px;+ font-size: 8px;+ color: var(--blue-dim);+}++/* transport */+.s-transport .transport {+ position: absolute;+ inset: 0;+ padding: 4px 14px 10px;+ display: grid;+ grid-template-rows: auto minmax(0, 1fr) auto auto;+ gap: 8px;+ margin: 0;+}++.transport-top {+ display: flex;+ gap: 6px;+ align-items: center;+}++.transport-top .play.on {+ background: transparent;+ border-color: var(--amber);+ color: var(--amber);+ box-shadow: 0 0 6px rgba(255, 179, 64, 0.4);+ text-shadow: 0 0 3px rgba(255, 179, 64, 0.6);+}++.transport-encoders {+ position: relative;+ min-height: 132px;+}++.s-transport .enc-dial {+ width: 60px;+ height: 60px;+}++.s-transport .enc-value {+ font-size: 22px;+}++.transport .presets {+ display: flex;+ flex-wrap: wrap;+ gap: 4px;+}++.transport .presets .chip {+ padding: 2px 7px;+ font-size: 9px;+}++.transport .sbn {+ display: flex;+ align-items: center;+ gap: 8px;+}++.transport .sbn input {+ flex: 1;+ min-width: 0;+}++.transport .sbn .dim {+ flex: none;+ font-size: 8px;+ letter-spacing: 0.14em;+ text-transform: uppercase;+ color: var(--blue-dim);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.transport .sbn input {+ padding: 3px 8px;+ font-size: 11px;+}++/* the hit, in big outlined letters over the face */+.beat-overlay {+ top: 14px;+ right: 18px;+ bottom: auto;+ gap: 2px;+}++.beat-sym {+ font-family: var(--font);+ font-weight: 500;+ font-stretch: 100%;+ font-size: clamp(56px, 7vw, 120px);+ line-height: 1;+ color: transparent;+ -webkit-text-stroke: 1.5px var(--amber);+ text-shadow: none;+ filter: drop-shadow(0 0 4px rgba(255, 179, 64, 0.6));+}++.beat-name,+.beat-air,+.beat-step {+ font-size: 11px;+ letter-spacing: 0.18em;+ text-transform: uppercase;+ color: var(--amber);+}++.beat-air,+.beat-step {+ font-size: 9px;+ opacity: 0.8;+}++/* a compact keys strip */+.s-keys-compact {+ grid-area: keys;+}++.s-keys-compact .screen-body {+ min-height: 60px;+ padding: 4px 14px 8px;+}++@media (max-width: 1100px) {+ .right-beatbox {+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);+ grid-template-rows: none;+ grid-template-areas: "seq seq" "wf wf" "pads transport" "keys keys";+ }+ .right-beatbox .screen-body {+ min-height: 200px;+ }+ .s-seq .screen-body {+ min-height: 240px;+ }+ .s-pads .screen-body,+ .s-transport .screen-body {+ min-height: 300px;+ }+ .s-keys-compact .screen-body {+ min-height: 90px;+ }+}++@media (max-width: 640px) {+ .right-beatbox {+ grid-template-columns: minmax(0, 1fr);+ grid-template-areas: "seq" "wf" "pads" "transport" "keys";+ }+ .beat-overlay {+ top: 10px;+ }+}