Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.
TypeScript agent-skillsanimationcanvasclaude-codeclaude-pluginclaude-skillscodex-plugincreative-codecreative-codingcreative-toolsdeterministicgenerative-arthand-drawnillustrationlaunch-videomotion-designmotion-graphicspluginprocedural-generationskill
chore: resync Codex mirror
Alex Greenshpun8ff90a973155
diff --git a/plugins/anidoodle/.codex-plugin/plugin.json b/plugins/anidoodle/.codex-plugin/plugin.jsonindex 57af672..14acacf 100644--- a/plugins/anidoodle/.codex-plugin/plugin.json+++ b/plugins/anidoodle/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "anidoodle",- "version": "0.4.0",+ "version": "0.5.0","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.","skills": "./skills/","interface": {diff --git a/plugins/anidoodle/skills/anidoodle/SKILL.md b/plugins/anidoodle/skills/anidoodle/SKILL.mdindex 5e5c665..9dbb02f 100644--- a/plugins/anidoodle/skills/anidoodle/SKILL.md+++ b/plugins/anidoodle/skills/anidoodle/SKILL.md@@ -42,9 +42,9 @@ say why in one line. Write the answers into a short brief before drawing.| A style matched from their image | `references/workflows/adapt-a-style.md` || A score or soundtrack | `references/music/README.md` |-- Music: pick a style vocabulary and mood, compose your own harmony, motif and form (references/music/compose.md), then node tools/music.mjs check <score.ts#export> must PASS before a human listens. Styles give sound, never notes.+- Music: write your own score for the film (references/music/README.md); node tools/music.mjs check <score.ts#export> must PASS before a human listens.- Sound effects: references/music/sound-design.md. 14 layered, seeded effects cued by film frame (filmSfx); the score ducks, and every cue must be within 6 dB of it. Effects only on real direction changes, one riser + one impact per film.-- Launch films: `launchTemplate.ts` renders a product's launch from data: prompts, plates drawn for it, a score composed for it, words, install lines; habits that save tokens are in `references/working-method.md`.+- Launch films: `launchTemplate.ts` renders a product's launch from data: prompts, plates drawn for it, a score written for it, words, install lines; habits that save tokens are in `references/working-method.md`.## The seven laws@@ -123,7 +123,7 @@ node tools/emit.mjs intro --out out/intro.html # one self-co| `docs-check.mjs` | fails when any doc's style count, length or path disagrees with the code || `verify-export.mjs` | QA on the rendered file: frames, duration, score; opt-in first frame, loop seam, `--delivery` || `test.mjs` (`npm test`) | unit suites in `engine/test/`, no browser |-| `music.mjs` | `vocab` prints a style's vocabulary; `check` gates your composed score; `render`, `meter` |+| `music.mjs` | renders and meters a score; `check` gates it (key, master, guards, stems, novelty) || `sfx.mjs` | the sound-effects kit: `list`, `one`, `kit <dir>`, `test` |Four backends, one art core: `playwright`, `html-player`, `remotion`, `hyperframes`.diff --git a/plugins/anidoodle/skills/anidoodle/engine/package-lock.json b/plugins/anidoodle/skills/anidoodle/engine/package-lock.jsonindex 1ef53d7..7e5fd1b 100644--- a/plugins/anidoodle/skills/anidoodle/engine/package-lock.json+++ b/plugins/anidoodle/skills/anidoodle/engine/package-lock.json@@ -1,12 +1,12 @@{"name": "anidoodle-engine",- "version": "0.4.0",+ "version": "0.5.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "anidoodle-engine",- "version": "0.4.0",+ "version": "0.5.0","dependencies": {"esbuild": "^0.25.0"},diff --git a/plugins/anidoodle/skills/anidoodle/engine/package.json b/plugins/anidoodle/skills/anidoodle/engine/package.jsonindex 3ed9c90..84dca60 100644--- a/plugins/anidoodle/skills/anidoodle/engine/package.json+++ b/plugins/anidoodle/skills/anidoodle/engine/package.json@@ -1,6 +1,6 @@{"name": "anidoodle-engine",- "version": "0.4.0",+ "version": "0.5.0","private": true,"type": "module","description": "Portable art core + backend adapters for illustrations, animations and films drawn entirely in code.",diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchExample.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchExample.tsindex 8921124..bbd27f4 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchExample.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchExample.ts@@ -3,7 +3,7 @@// Copying it: everything here is a PLACEHOLDER. The lighthouse and fox are stock style plates// standing in; your film's plates are drawn fresh for YOUR product's subject, in the style recipe// the brief chose (references/styles.md). The film is silent because a score is composed per-// product (references/music/compose.md); pass that piece as `score`. bpm comes from the brief.+// product (references/music/README.md); pass that piece as `score`. bpm comes from the brief.// node tools/still.mjs launchExample --frame 0 the first frame is the thumbnail: check it// node tools/render.mjs launchExampleimport { C } from "./launchKit";@@ -24,5 +24,5 @@ export const launchExample = makeLaunchFilm({install: ["npm install your-product", "your-product init"],footer: "yourproduct.example",bpm: 90, askBeats: 6, typeBeats: 4, endBeats: 8, claimBar: 4,- score: null, // silent: compose this product's own score and pass it here+ score: null, // silent: write this product's own score and pass it here});diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchTemplate.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchTemplate.tsindex 4b8a77b..f9eb4cf 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchTemplate.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/launchTemplate.ts@@ -24,14 +24,13 @@ import {} from "./launchKit";import { beatGrid, bloomFrame, bloomRadius, makeCut, pic, type, typeFrame, type Seg, type TypeLine } from "./launchCut";import { measure, writeOn } from "./kinetic";-import { fitScore, limiter, renderPiece } from "./music/render";+import { fitToDuration, limiter, renderPiece } from "./music/render";import { loudness, truePeak } from "./music/meter";import * as families from "./music/pieces/families";import * as launchPieces from "./music/pieces/launch";import * as nocturnePieces from "./music/pieces/nocturne";import * as samplers from "./music/pieces/samplers";import type { Piece } from "./music/plan";-import { composePiece, stretchIndex, withStretch, type Material } from "./music/compose";import { perform } from "./music/perform";import { beatsPerBar } from "./music/plan";import { novelty } from "./music/novelty";@@ -57,29 +56,27 @@ export type LaunchSpec = {bpm: number; fps?: number; // the beat grid: bpm comes from the brief (the score composed for it); a beat is 60 * fps / bpm framesaskBeats?: number; typeBeats?: number; endBeats?: number; // default 6, 4, 8claimBar?: number; // land the end card on this bar's downbeat, counting from bar 0 (solves the last ask)- // The score: a piece COMPOSED for this product's brief (references/music/compose.md), or null for+ // The score: a Piece written for this product's brief (references/music/README.md), or null for// a silent film. Required, so no film inherits a score by default. anidoodle's own pieces are// refused: every user's film gets its own music, never ours.- // A Material (what compose.md writes) is composed here; a finished Piece is used as is.- score: (() => Piece | Material) | null;+ score: (() => Piece) | null;audio?: Film["audio"]; // or your own finished mix; wins over scorelimit?: boolean; // let a look-ahead limiter take the score's last peaks so it reaches -14 LUFS (default off: the peak ceiling wins)};const W = 1920, H = 1080;-// anidoodle's own pieces (the demos and our launch score) are examples of the composer, never a+// anidoodle's own pieces (the demos and our launch score) are examples of the engine, never a// user's soundtrack. Refused by identity, by title and by content (the novelty gate), so a thin or// retitled wrapper does not slip through. `audio` is the caller's own finished mix and is not checked.const OURS: (() => Piece)[] = [...Object.values(families), ...Object.values(launchPieces), ...Object.values(nocturnePieces), ...Object.values(samplers)].filter((v): v is () => Piece => typeof v === "function");-const asPiece = (score: () => Piece | Material) => (): Piece => { const x = score(); return "plan" in x ? x : composePiece(x); };-const refuseOurs = (score: () => Piece | Material) => {+const refuseOurs = (score: () => Piece) => {const ours = () => new Set(OURS.map((f) => { try { return f().title; } catch { return null; } }).filter(Boolean));- if ((OURS as unknown[]).includes(score) || ours().has(score().title)) throw new Error(`launchTemplate: "${score().title}" is one of anidoodle's own pieces; compose a score for this product's brief (references/music/compose.md) or pass score: null`);+ if ((OURS as unknown[]).includes(score) || ours().has(score().title)) throw new Error(`launchTemplate: "${score().title}" is one of anidoodle's own pieces; write a score for this product's brief (references/music/README.md) or pass score: null`);// by content too: a retitled copy, a transposition or a quoted line of ours fails the same novelty gate `music.mjs check` runsconst corpus: Record<string, () => Piece> = {};- OURS.forEach((f, i) => { try { const p = asPiece(f)(); corpus[`${p.title} #${i}`] = () => p; } catch { /* not a piece */ } });- const v = novelty(asPiece(score)(), corpus);- if (!v.pass) throw new Error(`launchTemplate: "${score().title}" is too close to anidoodle's own "${v.worst.name.replace(/ #\d+$/, "")}" (similarity ${v.worst.score}, ${v.worst.reusedFragments} reused 6-note fragments); compose a score for this product's brief (references/music/compose.md) or pass score: null`);+ OURS.forEach((f, i) => { try { const p = f(); if (p && "plan" in p) corpus[`${p.title} #${i}`] = () => p; } catch { /* not a piece */ } });+ const v = novelty(score(), corpus);+ if (!v.pass) throw new Error(`launchTemplate: "${score().title}" is too close to anidoodle's own "${v.worst.name.replace(/ #\d+$/, "")}" (similarity ${v.worst.score}, ${v.worst.reusedFragments} reused 6-note fragments); write a score for this product's brief (references/music/README.md) or pass score: null`);};const TYPE_O = { lead: -4, stagger: 18 }; // the word starts as the bloom closes over the frame; lines run on without a gapconst TOP = 170, VIEW_BOTTOM = INPUT.y - 26, BUBBLE = 58, CARD = 460;@@ -97,7 +94,7 @@ const askTiming = (prompt: string, i: number, ASK: number) => {export const makeLaunchFilm = (spec: LaunchSpec): Film & { cut: ReturnType<typeof makeCut> } => {const fps = spec.fps ?? 30, n = spec.asks.length;if (!(spec.bpm > 0)) throw new Error("launchTemplate: set bpm from the brief (the tempo of the score composed for this film)");- if (spec.score === undefined && !spec.audio) throw new Error("launchTemplate: `score` is required: a piece composed for this product (references/music/compose.md), or null for silence");+ if (spec.score === undefined && !spec.audio) throw new Error("launchTemplate: `score` is required: a piece written for this product (references/music/README.md), or null for silence");if (spec.score) refuseOurs(spec.score);const grid = beatGrid(spec.bpm, fps);const ASK = Math.round((spec.askBeats ?? 6) * grid.beat), TYPE = Math.round((spec.typeBeats ?? 4) * grid.beat), END0_HOLD = Math.round((spec.endBeats ?? 8) * grid.beat);@@ -233,31 +230,27 @@ export const makeLaunchFilm = (spec: LaunchSpec): Film & { cut: ReturnType<typeo};};-type Fit = ReturnType<typeof fitScore>;+type Fit = ReturnType<typeof fitToDuration>;const MIN_END = (fps: number) => 3 * fps + 40; // the install lines held 3 s or more, after the card writes on/*** The score for a beat-grid film: played at the film's bpm exactly (the cuts sit on that grid), and- * the film made whole bars of it. A Material's stretch section is repeated 0..n times; each form is- * `bars` long plus whole bars for its tail to ring out, and the form whose length puts the end-card- * hold nearest the one asked for wins (the hold stays between 3 s and the asked hold + 4 bars).- * No tempo is changed; if no form fits, it throws. Bars before the final ritard are checked against- * the grid to half a frame, so a rubato or a breath can never pull a downbeat off a cut.+ * the film made whole bars of it. The score is `bars` long plus whole bars for its tail to ring out;+ * the end-card hold takes up the difference and must stay between 3 s and the asked hold + 4 bars.+ * No tempo is changed; if the score does not fit, it throws and says which lengths would. Bars+ * before the final ritard are checked against the grid to half a frame, so a rubato or a breath can+ * never pull a downbeat off a cut.*/-export const gridScore = (score: () => Piece | Material, bpm: number, fps: number, before: number, hold: number) => {- const x = score(), barF = (4 * 60 * fps) / bpm, lo = MIN_END(fps), hi = hold + 4 * barF;- const forms: (() => Piece)[] = "plan" in x ? [() => x] : stretchIndex(x) < 0 ? [() => composePiece(x)] : Array.from({ length: 33 }, (_, r) => () => composePiece(withStretch(x, r)));- let best: { piece: Piece; end: number; bars: number; ring: number } | null = null, tried: string[] = [];- for (const make of forms) {- const p = make(), bpb = beatsPerBar(p.plan.meter);- if (bpb !== 4) throw new Error(`launchTemplate: the score is in ${p.plan.meter}; a launch film's cuts sit on 4-beat bars, so compose it in 4/4`);- if (p.plan.pickupBeats) throw new Error(`launchTemplate: the score opens with a ${p.plan.pickupBeats}-beat pickup; frame 0 is a downbeat, so start the score on the bar`);- const bars = p.plan.sections.reduce((a, q) => a + q.bars, 0), ring = Math.ceil((p.tail * bpm) / 60 / 4 - 1e-9), end = Math.round((bars + ring) * barF) - before;- tried.push(`${bars}+${ring} bars -> hold ${(end / fps).toFixed(1)} s`);- if (end >= lo && end <= hi && (!best || Math.abs(end - hold) < Math.abs(best.end - hold))) best = { piece: p, end, bars, ring };- if (end > hi) break; // more repeats only make it longer+export const gridScore = (score: () => Piece, bpm: number, fps: number, before: number, hold: number) => {+ const p = score(), barF = (4 * 60 * fps) / bpm, lo = MIN_END(fps), hi = hold + 4 * barF;+ if (beatsPerBar(p.plan.meter) !== 4) throw new Error(`launchTemplate: the score is in ${p.plan.meter}; a launch film's cuts sit on 4-beat bars, so write it in 4/4`);+ if (p.plan.pickupBeats) throw new Error(`launchTemplate: the score opens with a ${p.plan.pickupBeats}-beat pickup; frame 0 is a downbeat, so start the score on the bar`);+ const bars = p.plan.sections.reduce((a, q) => a + q.bars, 0), ring = Math.ceil((p.tail * bpm) / 60 / 4 - 1e-9), end = Math.round((bars + ring) * barF) - before;+ const best = end >= lo && end <= hi ? { piece: p, end, bars, ring } : null;+ if (!best) {+ const minBars = Math.ceil((before + lo) / barF - 1e-9) - ring, maxBars = Math.floor((before + hi) / barF + 1e-9) - ring;+ throw new Error(`launchTemplate: the score cannot end on a bar of this film at ${bpm} bpm without changing its tempo. The cut before the end card is ${(before / fps).toFixed(1)} s and the end-card hold must be ${(lo / fps).toFixed(1)}-${(hi / fps).toFixed(1)} s; the score is ${bars}+${ring} bars (hold ${(end / fps).toFixed(1)} s). Write it ${minBars}-${maxBars} bars long, or change askBeats/endBeats/claimBar.`);}- if (!best) throw new Error(`launchTemplate: the score cannot end on a bar of this film at ${bpm} bpm without changing its tempo. The cut before the end card is ${(before / fps).toFixed(1)} s and the end-card hold must be ${(lo / fps).toFixed(1)}-${(hi / fps).toFixed(1)} s; the score's forms give ${tried.join(", ")}. Compose a 1-bar stretch section (stretch: true), or change askBeats/endBeats/claimBar.`);const piece: Piece = { ...best.piece, plan: { ...best.piece.plan, tempo: bpm, rubato: 0 } }, perf = perform(piece, bpm, { expressive: true }), spb = 60 / bpm;const lastBar = Math.floor((perf.lastOnset / spb - 6) / 4); // the final ritard lives in the last 6 beats, inside the end cardfor (let k = 0; k <= lastBar; k++) { const drift = perf.sec(4 * k) - 4 * k * spb; if (Math.abs(drift) > 0.5 / fps) throw new Error(`launchTemplate: the score's bar ${k} lands ${(drift * 1000).toFixed(0)} ms off the film's grid (a breath or a caesura in the score); a launch film's cuts need every downbeat on the grid: even out the section dynamics there`); }@@ -266,14 +259,14 @@ export const gridScore = (score: () => Piece | Material, bpm: number, fps: numbe// A music bed: the piece FITTED to the film, never cut and faded. With `tempo` (a beat-grid film, as// the launch template passes it) the piece plays at exactly that tempo and the film is already whole-// bars of it (gridScore); without, fitScore fits it as filmAudio does (its stretch section repeated or+// bars of it (gridScore); without, fitToDuration fits it as filmAudio does (sections repeated or// dropped, the tempo trimmed so the tail rings out on the last frame). Then it is set to `lufs` integrated (default -14, the one published// cross-platform target) with the true peak held at or under -1 dBTP. A dynamic piece stops at the// peak ceiling first (render prints how far short); `limit: true` lets a look-ahead limiter take// those few peaks instead so the bed reaches the target. Compose the piece for this film at the-// film's bpm, so the cuts sit on its downbeats. `piece` may return a Piece or a fitScore result.+// film's bpm, so the cuts sit on its downbeats. `piece` may return a Piece or a fitToDuration result.export const musicBed = (piece: () => Piece | Fit, frames: number, fps = 30, lufs = -14, o: { limit?: boolean; tempo?: number } = {}) => (sr: number): [Float32Array, Float32Array] => {- const seconds = frames / fps, x = piece(), fit = "order" in x ? x : o.tempo ? { piece: x, tempo: o.tempo } : fitScore(x, seconds);+ const seconds = frames / fps, x = piece(), fit = "order" in x ? x : o.tempo ? { piece: x, tempo: o.tempo } : fitToDuration(x, seconds);const m = renderPiece(fit.piece, sr, { seconds, tempo: fit.tempo }), n = Math.round(seconds * sr);const L = new Float32Array(n), R = new Float32Array(n); L.set(m.L.subarray(0, n)); R.set(m.R.subarray(0, n));const gain = (dB: number) => { const g = Math.pow(10, dB / 20); for (let i = 0; i < n; i++) { L[i] *= g; R[i] *= g; } };diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/calibration.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/calibration.tsdeleted file mode 100644index 45183e2..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/calibration.ts+++ /dev/null@@ -1,21 +0,0 @@-// A neutral TEST SIGNAL per style: scale-degree triads, a stepwise line, arpeggios. It is not music-// and never a score: `tools/music.mjs calibrate` uses it to set palette levels against stem targets,-// and the unit test uses it to prove every vocabulary composes, renders and meters.-import { beatsPerBar, isCompound } from "./plan";-import { MODES, nameOf, type ModeId } from "./theory";-import type { Material } from "./compose";-import type { StyleVocab } from "./vocab";--export const testMaterial = (v: StyleVocab, o: { loop?: boolean; bars?: number; key?: string; tonic?: number; mode?: ModeId } = {}): Material => {- const mode = o.mode ?? v.harmony.modes.find((x) => MODES[x].intervals.length === 7) ?? "major", iv = MODES[mode].intervals, meter = v.meters[0], bpb = beatsPerBar(meter), comp = isCompound(meter), bars = o.bars ?? 8;- const deg = (d: number, oct: number) => 12 * (oct + 1) + (o.tonic ?? 0) + iv[((d % 7) + 7) % 7] + 12 * Math.floor(d / 7), unit = comp ? "1/3" : ".5", count = Math.round(bpb * (comp ? 3 : 2));- const degs = [0, 3, 4, 5], chords: Material["chords"] = {};- degs.forEach((d, i) => { chords[`c${i}`] = { voicing: `[${[0, 2, 4].map((k) => nameOf(deg(d + k, 4))).join(" ")}]`, bass: `${nameOf(deg(d, 2))}:${bpb}` }; });- const bar = (fn: (d: number, j: number) => number) => Array.from({ length: bars }, (_, b) => Array.from({ length: count }, (_, j) => `${nameOf(fn(degs[b % 4], j))}:${unit}`).join(" "));- const half = bpb / 2;- return { style: v.id, title: `test signal: ${v.id}`, seed: 1, mood: v.moods[0], bpm: Math.round((v.tempo[0] + v.tempo[1]) / 2), key: o.key ?? "C", mode, meter, chords, loop: o.loop,- grooves: v.grooves.length ? { main: { family: v.grooves[0], density: 0.5, variation: 0.35 } } : {},- sections: [{ kind: "hook", bars, harmony: ["c0", "c1", "c2", "c3"], groove: v.grooves.length ? "main" : null,- lead: bar((d, j) => deg(d + (j % 5), 5)), ...(v.palette.arp ? { arp: bar((d, j) => deg(d + [0, 2, 4, 2][j % 4], 4)) } : {}),- ...(v.palette.counter ? { counter: Array.from({ length: bars }, (_, b) => `${nameOf(deg(degs[b % 4] + 4, 6))}:${half} ${nameOf(deg(degs[b % 4] + 2, 6))}:${half}`) } : {}) }] };-};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/compose.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/compose.tsdeleted file mode 100644index dc1b9dd..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/compose.ts+++ /dev/null@@ -1,185 +0,0 @@-// COMPOSE: the composer's material + a style vocabulary -> a Piece. The composer (the model) writes-// every note: the chord voicings and bass lines, the motifs and lines, the form. The style supplies-// only sound (voices, levels, fx), groove grammars, and the arrangement grammar (which layers a-// section kind lets sound). Nothing is filled in: missing material is an error that says what to-// compose. Workflow and craft: references/music/compose.md. Vocabularies: vocab.ts.-import { line, beatsPerBar, type Note, type Piece, type Part, type Role, type Meter } from "./plan";-import type { ModeId } from "./theory";-import type { MoodId, StyleId, MelodyType } from "./tables";-import { pcOf } from "./theory";-import { perform } from "./perform";-import { drumBar, type Groove, type Lane } from "./grooves";-import { VOCAB_TRIM, VOCAB_TARGET_FIX } from "./vocabTrim";-import { VOCAB, KINDS, BASE_SLOTS, resolveVoice, moodVoice, moodFx, fullMood, type Slot, type Voice, type SectionKind, type MoodControls } from "./vocab";--/** One chord of YOUR harmony: its voicing (a notation chord) and a one-bar bass line you wrote for it. */-export type ComposedChord = { voicing: string; bass?: string };-/** A line = notation bars, or names of your motifs, joined in order from the section's first bar. */-export type LineSpec = string | string[];-export type ComposedSection = {- id?: string; kind: SectionKind; bars: number;- /** chord names per bar (keys of `chords`), cycled to fill the section; a bar may hold two: "Dm9 G13" splits it */- harmony: string[];- /** lines play ONCE from the section's first bar (harmony cycles, lines do not); a shorter line leaves rests, unless `loopLines` */- lead?: LineSpec; counter?: LineSpec; arp?: LineSpec;- /** repeat each line to fill the section (a 2-bar motif in an 8-bar section plays 4 times) */ loopLines?: boolean;- /** modulate: this section's key and mode (default the piece's); the key check reads each key region separately */ key?: string; mode?: ModeId;- /** override the chords' bass lines for this section (one bar of notation, or one per bar) */ bass?: string | string[];- /** a key of `grooves`, or null for no drums; default by kind (main / half / build / none) */ groove?: string | null;- /** chord velocity scale (0..1.2), e.g. 0.8 for a softer intro */ chordVel?: number;- /** 0..1 (0.5 = as written): the section's dynamics for EVERY part (velocity x 0.55..1.45, about -5..+3 dB) and the density of generated grooves */ energy?: number;- /** play the section this many times (refit changes it for the stretch section) */ repeat?: number; stretch?: boolean;-};-export type Material = {- style: StyleId; title: string; seed: number; mood: MoodId; bpm: number; key: string; mode: ModeId; meter?: Meter;- chords: Record<string, ComposedChord>; motifs?: Record<string, string>; grooves?: Record<string, Groove>;- sections: ComposedSection[];- /** swap a slot's voice for one of the style's alternates by name, or give your own Voice */ voices?: Partial<Record<Slot, string | Voice>>;- /** dB OFFSET per slot, added to the voice's calibrated gain (after trims and mood): +2 = two dB louder. Set from the stem meter. */ levels?: Partial<Record<Slot, number>>;- moodControls?: MoodControls;- /** 0.5 straight .. 0.67 hard swing (default the style's lower bound) */ swing?: number;- /** the piece's dynamic level [start, end] 0..1, ramped over the whole piece (default [0.62, 0.66]); section `energy` shapes it locally */ dyn?: [number, number];- /** seconds of ring-out after the last onset (default 3.2) */ tail?: number; loop?: boolean;-};--/** line() with the composer's context on its error: which section, slot or chord wrote the bad bar. */-const lineIn = (where: string, ...a: Parameters<typeof line>) => { try { return line(...a); } catch (e) { throw new Error(`compose: ${where}: ${(e as Error).message}`); } };-const need = (ok: unknown, msg: string) => { if (!ok) throw new Error(`compose: ${msg} The style supplies sound, never notes: compose it yourself (references/music/compose.md).`); };-const fmt = (x: number) => String(+x.toFixed(4));-const lanes: Lane[] = ["kick", "snare", "ghost", "hat", "perc"];--/** Expand repeats: the sections as played, with their first bar. */-export const layout = (sections: ComposedSection[]) => {- const out: { s: ComposedSection; id: string; from: number; to: number; pass: number }[] = []; let b = 0;- sections.forEach((s, i) => { for (let k = 0; k < (s.repeat ?? 1); k++) { out.push({ s, id: s.id ?? `${s.kind}${i}`, from: b, to: b + s.bars, pass: k }); b += s.bars; } });- return out;-};--export const composePiece = (m: Material): Piece => {- const V = VOCAB[m.style]; need(V, `no vocabulary for style "${m.style}" (have: ${Object.keys(VOCAB).join(", ")}).`);- const vocab = V!, meter = m.meter ?? vocab.meters[0], bpb = beatsPerBar(meter);- need(m.title && Number.isFinite(m.seed) && m.mood, "a piece needs its own title, seed and mood.");- need(Number.isFinite(m.bpm) && m.bpm > 0, `no tempo: set bpm (this style plays ${vocab.tempo[0]}-${vocab.tempo[1]} bpm).`);- need(m.sections?.length, "no form: write the sections (kind, bars, harmony, lines).");- need(m.chords && Object.keys(m.chords).length, "no harmony: write your chords (voicing + bass line per chord).");- const lay = layout(m.sections), B = lay[lay.length - 1].to;- need(m.sections.some((s) => s.lead), "no melody: at least one section needs a lead line (your own motif).");- const motif = (x: string) => { const v = m.motifs?.[x]; if (v !== undefined) return v; need(/[:|]/.test(x), `no motif named "${x}": add motifs["${x}"] = "<bars of notation>", or write the notes inline (NOTE:DUR ...).`); return x; };- const lineOf = (spec: LineSpec) => (Array.isArray(spec) ? spec : [spec]).map(motif).join(" | ");-- // ---- harmony per bar (a bar may split into chords: "A B" = two halves)- const chordAt: string[][] = [];- for (const x of lay) {- need(x.s.harmony?.length, `section "${x.id}" has no harmony: write the chord names for its bars.`);- for (let i = 0; i < x.s.bars; i++) { const names = x.s.harmony[i % x.s.harmony.length].trim().split(/\s+/); for (const n of names) need(m.chords[n], `chord "${n}" (section "${x.id}") has no voicing: add chords["${n}"] = { voicing: "[...]", bass: "..." }.`); chordAt.push(names); }- }- const harmony = chordAt.flatMap((names, b) => names.map((name, j) => ({ t: b * bpb + (j * bpb) / names.length, name })));- const at = (b: number) => lay.find((x) => b >= x.from && b < x.to)!;-- // ---- notes- const notes: Partial<Record<Slot, Note[]>> = {};- const push = (slot: Slot, ns: Note[]) => { (notes[slot] ??= []).push(...ns); };- const vel: Record<Slot, number> = { chords: 0.62, lead: 0.72, counter: 0.5, bass: 0.85, arp: 0.55, kick: 0.85, snare: 0.7, ghost: 0.5, hat: 0.5, perc: 0.45 };- const role = (slot: Slot): Role => (slot === "chords" || slot === "arp" ? "accomp" : slot === "lead" ? "melody" : slot === "counter" ? "color" : slot === "bass" ? "bass" : "drum");- for (let b = 0; b < B; b++) {- const x = at(b), cv = x.s.chordVel, names = chordAt[b], d = bpb / names.length;- const src = names.map((n) => `${m.chords[n].voicing}:${fmt(d)}${cv !== undefined ? `@${fmt(cv)}` : ""}`).join(" ");- push("chords", lineIn(`section "${x.id}" chords (bar ${b})`, b * bpb, src, { role: "accomp", v: vel.chords, bpb, roll: 0.03 }));- if (KINDS[x.s.kind].bass) {- const ov = x.s.bass, bl = ov !== undefined ? (Array.isArray(ov) ? ov[(b - x.from) % ov.length] : ov) : names.length === 1 ? m.chords[names[0]].bass : undefined;- need(bl !== undefined, names.length > 1 ? `bar ${b} splits into ${names.join(" + ")}: give section "${x.id}" a bass override for it.` : `chord "${names[0]}" (section "${x.id}") has no bass line: add chords["${names[0]}"].bass (one bar), or a section bass override.`);- if (bl) push("bass", lineIn(`section "${x.id}" bass (bar ${b}${names.length === 1 && ov === undefined ? `, chords["${names[0]}"].bass` : ""})`, b * bpb, bl, { role: "bass", v: vel.bass, bpb }));- }- // drums- const def = KINDS[x.s.kind].drums, gname = x.s.groove === undefined ? def : x.s.groove;- if (gname) {- const g = m.grooves?.[gname];- need(g, `section "${x.id}" (${x.s.kind}) needs a groove "${gname}": add grooves["${gname}"] = { family: one of ${vocab.grooves.join(", ")}, density, variation } or write it (kick/snare/ghost/hat bars), or set groove: null.`);- const bar = drumBar(g!, meter, m.seed, b, b - x.from, x.s.bars, x.s.energy ?? 0.5);- for (const ln of lanes) if (bar[ln]) push(ln, lineIn(`section "${x.id}" ${ln} (bar ${b})`, b * bpb, bar[ln]!, { role: "drum", v: vel[ln], bpb }));- }- }- const warnings: string[] = [];- for (const x of lay) for (const slot of ["lead", "counter", "arp"] as Slot[]) {- const spec = x.s[slot as "lead" | "counter" | "arp"]; if (!spec) continue;- let src = lineOf(spec); const barsOf = (t: string) => t.split("|").filter((z) => z.trim()).length, lb = barsOf(src);- if (lb < x.s.bars) {- if (x.s.loopLines) { const reps = Math.ceil(x.s.bars / lb), all = Array.from({ length: reps }, () => src).join(" | ").split("|").map((z) => z.trim()).filter(Boolean); src = all.slice(0, x.s.bars).join(" | "); }- else if (x.pass === 0) warnings.push(`section "${x.id}": the ${slot} is ${lb} bar(s) in a ${x.s.bars}-bar section; it plays once, then rests (set loopLines: true to repeat it)`);- }- const ns = lineIn(`section "${x.id}" ${slot}`, x.from * bpb, src, { role: role(slot), v: vel[slot], bpb });- need(ns.every((n) => n.t < x.to * bpb - 1e-9), `the ${slot} line of section "${x.id}" is longer than its ${x.s.bars} bars.`);- push(slot, ns);- }-- // ---- section energy: dynamics for every part (0.5 = as written, exactly)- for (const x of lay) { const en = x.s.energy; if (en === undefined || en === 0.5) continue; const f = 0.55 + 0.9 * en, a = x.from * bpb, z = x.to * bpb;- for (const ns of Object.values(notes)) for (const n of ns!) if (n.t >= a - 1e-9 && n.t < z - 1e-9) n.v *= f; }- // ---- parts from the palette (+ alternates, levels, mood)- const mood = m.moodControls ? fullMood(m.moodControls) : null, targets: Record<string, number> = {};- const slots = [...BASE_SLOTS, ...(["arp", "perc"] as Slot[]).filter((s) => notes[s]?.length)];- const parts: Part[] = [];- for (const slot of slots) {- const pick = m.voices?.[slot];- const FALLBACK: Partial<Record<Slot, Slot>> = { perc: "hat", ghost: "snare", snare: "ghost", hat: "perc" }; // a drum lane without its own voice borrows its neighbour's- let v = typeof pick === "object" ? pick : typeof pick === "string" ? vocab.alternates[slot]?.[pick] : vocab.palette[slot] ?? (notes[slot]?.length && FALLBACK[slot] ? vocab.palette[FALLBACK[slot]!] : undefined);- need(typeof pick !== "string" || v, `style ${vocab.id} has no "${pick}" voice for ${slot} (have: ${Object.keys(vocab.alternates[slot] ?? {}).join(", ") || "none"}).`);- if (!v) { if (slot === "chords") continue; /* a style without a chord voice (chiptune): the harmony still labels bars and feeds the bass */ need(!notes[slot]?.length, `style ${vocab.id} has no ${slot} voice, but your ${slot} has notes: pick a groove family or slot this style has.`); continue; }- v = resolveVoice(v, m.bpm);- let dGain = 0; if (mood) { const r = moodVoice(slot, v, mood); v = r.voice; dGain = r.dGain; }- const lv = m.levels?.[slot];- const trim = pick !== undefined ? 0 : VOCAB_TRIM[vocab.id]?.[slot] ?? 0; let gainDb = trim ? v.gainDb + trim : v.gainDb; if (lv) gainDb += lv;- // a timpani (or any pitched drum voice) playing a drum lane is tuned to the key: the tonic in its low register- if (v.inst === "timpani" && role(slot) === "drum" && typeof pick !== "object") { const tp = pcOf(m.key.replace(/m$/, "")), lo = typeof v.opts?.pitch === "number" ? (v.opts.pitch as number) - 5 : slot === "kick" ? 31 : 38; /* the tonic nearest the voice's own register */ v = { ...v, opts: { ...(v.opts ?? {}), pitch: lo + ((tp - (lo % 12) + 12) % 12) } }; }- if (vocab.stemTargets[slot] !== undefined) targets[slot] = vocab.stemTargets[slot] + dGain + (pick === undefined ? VOCAB_TARGET_FIX[vocab.id]?.[slot] ?? 0 : 0); // a mood that lifts the hats lifts their target too- const p: Part = { id: slot, inst: v.inst, role: v.role, notes: notes[slot] ?? [], gainDb };- if (v.opts) p.opts = v.opts; if (v.send !== undefined) p.send = v.send; if (v.pan !== undefined) p.pan = v.pan;- parts.push(p);- }- const e = mood ? mood.energy - 0.5 : 0, dyn0 = m.dyn ?? [0.62, 0.66], dyn: [number, number] = mood ? [dyn0[0] + e * 0.2, dyn0[1] + e * 0.2] : dyn0;- // key regions: one plan section per run of sections in the same key and mode (a single one when the piece never modulates)- const keyOf = (x: (typeof lay)[number]) => `${x.s.key ?? m.key}|${x.s.mode ?? m.mode}`, regions: { from: number; to: number; key: string; mode: ModeId }[] = [];- for (const x of lay) { const r = regions[regions.length - 1]; if (r && `${r.key}|${r.mode}` === keyOf(x)) r.to = x.to; else regions.push({ from: x.from, to: x.to, key: x.s.key ?? m.key, mode: x.s.mode ?? m.mode }); }- const lvl = (b: number) => dyn[0] + ((dyn[1] - dyn[0]) * b) / B;- const planSections = regions.length === 1 ? [{ id: "a", bars: B, mood: m.mood, key: m.key, mode: m.mode, melody: ["stepwise", "hook"] as MelodyType[], dyn, ending: "tail" as const, repeatable: false }]- : regions.map((r, i) => ({ id: `key${i}`, bars: r.to - r.from, mood: m.mood, key: r.key, mode: r.mode, melody: ["stepwise", "hook"] as MelodyType[], dyn: [lvl(r.from), lvl(r.to)] as [number, number], ending: "tail" as const, repeatable: false }));- const piece: Piece = {- title: m.title, seed: m.seed, tail: m.tail ?? 3.2, harmony, parts,- plan: { style: m.style, tempo: m.bpm, meter, swing: m.swing ?? vocab.swing[0], ritard: m.loop ? 1 : 0.92, loop: m.loop,- sections: planSections },- fx: mood ? moodFx(vocab.fx, mood) : vocab.fx, stemTargets: targets,- arrangement: lay.map((x) => ({ id: x.id, kind: x.s.kind, from: x.from, bars: x.s.bars })),- warnings, refit: m.loop ? undefined : (seconds: number) => composePiece(refitMaterial(m, seconds)),- };- return piece;-};--/** lofiElectronic(material): composePiece in the lo-fi electronic vocabulary. */-export const lofiElectronic = (m: Omit<Material, "style">): Piece => composePiece({ ...m, style: "lofiElectronic" } as Material);--/**- * The same composition for a film `seconds` long: the `stretch` section (default the longest- * groove/hook/verse/drop) is played more or fewer times (0 = dropped), whichever puts the last- * onset nearest `seconds - tail` at the written tempo. fitToDuration then trims the tempo.- */-/** The section a film fit repeats or drops: the one marked `stretch`, else the longest groove/hook/verse/drop; -1 when none. */-export const stretchIndex = (m: Material) => {- const secs = m.sections; let si = secs.findIndex((s) => s.stretch);- if (si < 0) secs.forEach((s, i) => { if (["groove", "hook", "verse", "drop"].includes(s.kind) && (si < 0 || s.bars * (s.repeat ?? 1) > secs[si].bars * (secs[si].repeat ?? 1))) si = i; });- return si;-};-/** The same material with its stretch section played `r` times (0 = dropped). */-export const withStretch = (m: Material, r: number): Material => { const si = stretchIndex(m); return si < 0 ? m : { ...m, sections: m.sections.map((s, i) => (i === si ? { ...s, repeat: r } : s)).filter((s) => (s.repeat ?? 1) > 0) }; };-export const refitMaterial = (m: Material, seconds: number): Material => {- const want = seconds - (m.tail ?? 3.2), si = stretchIndex(m);- if (si < 0 || want <= 0) return m;- let best: { m: Material; cost: number } | null = null;- for (let r = 0; r <= 64; r++) {- const m2 = withStretch(m, r);- if (!m2.sections.some((s) => s.lead)) continue;- const t = perform(composePiece(m2), m.bpm, { expressive: true }).lastOnset, tempo = m.bpm * (t / want), cost = Math.abs(Math.log(tempo / m.bpm));- if (!best || cost < best.cost) best = { m: m2, cost };- if (tempo > m.bpm * 1.3) break;- }- return best ? best.m : m;-};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/grooves.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/grooves.tsdeleted file mode 100644index c6b5ff9..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/grooves.ts+++ /dev/null@@ -1,186 +0,0 @@-// GROOVE FAMILIES: drum grammars, not drum patterns. A family says where the weight of a bar-// goes (kick anchors, backbeat, ghost slots, hat feel); `density`, `variation`, `fill` and the-// piece's seed decide the actual hits, bar by bar, so two pieces on the same family never share-// one loop. Pure: the same (family, params, seed, bar) always gives the same bar.-//-// Lanes: kick, snare, ghost (rim/soft snare), hat (closed), perc (open hat, shaker: the style's-// perc voice). Output is line() notation for one bar per lane (null = the lane rests).-import { rng as mkRng } from "../core";-import type { Meter } from "./plan";-import { beatsPerBar, isCompound } from "./plan";--export type GrooveFamily = "bounce" | "fourFloor" | "halfTime" | "broken" | "shuffle" | "pulse" | "brushes" | "build" | "tension" | "skip" | "trap" | "epic" | "hand" | "rock" | "swing";-/** A generated groove: the composer picks the family and its knobs. */-export type GrooveChoice = { family: GrooveFamily; density?: number; variation?: number; fill?: boolean; accent?: number };-/** A written groove: one or more bars of notation per lane, cycled by the absolute bar number. */-/** A written groove: one or more bars of notation per lane. Bars cycle from each section's first bar (`cycle: "piece"` cycles on the piece's bar count instead).- * The written pitch is ignored by unpitched drums (kick, snare, hat, noise): write C4. A pitched voice in a drum lane (timpani) is tuned to the key. */-export type LiteralGroove = { kick?: string[]; snare?: string[]; ghost?: string[]; hat?: string[]; perc?: string[]; cycle?: "section" | "piece" };-export type Groove = GrooveChoice | LiteralGroove;-export type Lane = "kick" | "snare" | "ghost" | "hat" | "perc";-export type DrumBar = Partial<Record<Lane, string | null>>;--export const GROOVE_FAMILIES: Record<GrooveFamily, string> = {- bounce: "lo-fi / hip-hop bounce: kick on 1 plus syncopated pickups, backbeat on 2 and 4, ghost notes, 8th or 16th hats with accents",- fourFloor: "house / drive: kick on every beat, clap on 2 and 4, off-beat open hats, 16ths when dense",- halfTime: "half-time: kick on 1 (and a pickup), snare on 3; the same tempo feels twice as slow (a breath, a scene change)",- broken: "broken beat / garage: kicks displaced off the grid, backbeat kept, ghosted 16ths; restless, modern",- shuffle: "shuffle: triplet grid, swung hats, kick on 1 and 3 with a skip; playful, bouncy",- pulse: "pulse: a soft heartbeat kick, no backbeat, sparse shaker; ambient and cinematic under-scoring",- brushes: "brushes: soft rim on 2 and 4, shaker swishes, a gentle kick; tender, acoustic",- build: "build: snare 8ths then 16ths rising in velocity across the section, kick on quarters; ends on the next downbeat",- tension: "tension: 3-3-2 kick ostinato, accent on 4, quiet 16th hats; cinematic urgency, chases",- skip: "skip: kick on 1 and the and-of-2, clap on 2 and 4, a skipping 16th perc; playful, light",- trap: "trap: sparse syncopated kicks (the 808 bass follows them), clap on 3, 16th hats with velocity ramps and bursts, an open hat now and then",- epic: "epic: big low hits (kick / timpani in perc) in a 3-3-2 or 1-and-3 figure, a snare accent on 4; orchestral and trailer weight",- hand: "hand percussion: dum (low) on each group start, tek (rim) inside, ka (perc) fills; groups follow the meter (7/8 = 2+2+3, 9/8 = 2+2+2+3, 5/4 = 3+2)",- rock: "rock: kick on 1 and 3 with an 8th pickup, snare backbeat, 8th hats, a crash (perc) on section starts",- swing: "jazz swing: ride on the beats and the swung skip of 2 and 4, foot hi-hat (perc) on 2 and 4, feathered kick, snare comping ghosts",-};--/** Step grid for a meter: 16ths in simple meters, triplet 8ths in compound ones. */-const grid = (meter: Meter, triplet: boolean) => {- const bpb = beatsPerBar(meter), compound = isCompound(meter) || (triplet && Number.isInteger(bpb)), per = compound ? 3 : 4;- return { steps: Math.round(bpb * per), stepBeats: 1 / per, per, bpb: Math.ceil(bpb) };-};-const round = (x: number) => +x.toFixed(3);-/** Hits (step -> velocity multiplier) to one bar of notation. */-export const stepsToLine = (hits: Map<number, number>, steps: number, per: number): string | null => {- const at = [...hits.keys()].filter((s) => s >= 0 && s < steps).sort((a, b) => a - b); if (!at.length) return null;- const d = (n: number) => (per === 3 ? `${n}/3` : String(n / per)); // exact: fractions for triplets, decimals for 16ths- const toks: string[] = []; if (at[0] > 0) toks.push(`r:${d(at[0])}`);- at.forEach((s, i) => { const nx = i + 1 < at.length ? at[i + 1] : steps; toks.push(`C4:${d(nx - s)}@${round(Math.min(1, Math.max(0.05, hits.get(s)!)))}`); });- return toks.join(" ");-};--/**- * One bar of a generated groove. `pos` = bar index inside its section, `len` = section bars,- * `abs` = absolute bar (the seed's per-bar variation), `energy` 0..1 scales density.- */-export const grooveBar = (g: GrooveChoice, meter: Meter, seed: number, abs: number, pos: number, len: number, energy = 0.5): DrumBar => {- const trip = g.family === "shuffle" || g.family === "swing", G = grid(meter, trip), { steps, per, bpb } = G;- const d = Math.min(1, Math.max(0, (g.density ?? 0.5) + (energy - 0.5) * 0.6)), v = g.variation ?? 0.35, acc = g.accent ?? 1;- const r = mkRng(seed * 7919 + abs * 131 + 17), maybe = (p: number) => r() < p;- const K = new Map<number, number>(), S = new Map<number, number>(), Gh = new Map<number, number>(), H = new Map<number, number>(), P = new Map<number, number>();- const beat = (b: number, sub = 0) => b * per + sub; // step of beat b (0-based) plus a subdivision- const back = bpb >= 4 ? [beat(1), beat(3)] : bpb === 3 ? [beat(1), beat(2)] : [beat(1)];- const hats = (every: number, lo: number, hi: number, jitter = 0.08) => { for (let s = 0; s < steps; s += every) H.set(s, (s % per === 0 ? hi : lo) * (1 + (r() - 0.5) * jitter * 2)); };- switch (g.family) {- case "bounce": {- K.set(0, 1); K.set(beat(2, 2), 0.9 * acc);- for (const s of [beat(1, 3), beat(2), beat(2, 3), beat(3, 2)]) if (s < steps && maybe(0.15 + 0.35 * d * v)) K.set(s, 0.6 + 0.2 * r());- for (const s of back) S.set(s, 1);- if (d > 0.35) { const slots = [beat(1, 3), beat(3, 3), beat(0, 3), beat(2, 1)].filter((s) => s < steps); Gh.set(slots[Math.floor(r() * slots.length)], 0.45 + 0.1 * r()); }- if (d > 0.55) { const pat = [0.85, 0.35, 0.6, 0.4]; for (let s = 0; s < steps; s++) H.set(s, pat[s % 4] * (1 + (r() - 0.5) * 0.12)); } else hats(2, 0.45, 0.8);- break;- }- case "fourFloor": {- for (let b = 0; b < bpb; b++) K.set(beat(b), b === 0 ? 1 : 0.92);- for (const s of back) S.set(s, 0.95);- for (let b = 0; b < bpb; b++) P.set(beat(b, 2), 0.7);- if (d > 0.6) for (let s = 0; s < steps; s++) if (s % 2 === 1) H.set(s, 0.35 + 0.15 * r());- if (v > 0.5 && maybe(0.3)) K.set(beat(bpb - 1, 3), 0.55);- break;- }- case "halfTime": {- K.set(0, 1); if (d > 0.4) K.set(beat(Math.min(2, bpb - 1) - 1, 2) + (maybe(v) ? 1 : 0), 0.7);- S.set(beat(Math.floor(bpb / 2)), 1);- hats(d > 0.6 ? 2 : per, 0.35, 0.6);- break;- }- case "broken": {- K.set(0, 1); for (const s of [beat(1, 2), beat(2, 1), beat(2, 3), beat(3, 1)]) if (s < steps && maybe(0.25 + 0.45 * v)) K.set(s, 0.75 + 0.15 * r());- for (const s of back) S.set(s, 1);- for (let s = 0; s < steps; s++) if (s % 2 === 1 && maybe(0.2 + 0.3 * d) && !K.has(s)) Gh.set(s, 0.35 + 0.15 * r());- for (let s = 0; s < steps; s++) if (maybe(0.45 + 0.4 * d)) H.set(s, s % 2 ? 0.35 : 0.7);- break;- }- case "shuffle": {- K.set(0, 1); if (bpb >= 3) K.set(beat(2), 0.85); if (maybe(0.4 + 0.4 * v)) K.set(beat(1, 2), 0.6);- for (const s of back) S.set(s, 0.95);- for (let b = 0; b < bpb; b++) { H.set(beat(b), 0.75); if (d > 0.3) H.set(beat(b, 2), 0.45 + 0.1 * r()); }- if (d > 0.6) Gh.set(beat(bpb - 1, 2), 0.4);- break;- }- case "pulse": {- K.set(0, 0.9); if (d > 0.5 && bpb >= 3) K.set(beat(Math.floor(bpb / 2)), 0.7); if (d > 0.75) K.set(beat(Math.floor(bpb / 2) - 1, 2), 0.5);- if (d > 0.3) for (let b = 0; b < bpb; b++) P.set(beat(b, per / 2 >= 1 ? Math.floor(per / 2) : 0), 0.35 + 0.1 * r());- if (v > 0.5 && maybe(0.4)) Gh.set(beat(bpb - 1), 0.35);- break;- }- case "brushes": {- K.set(0, 0.7); if (d > 0.5 && bpb >= 3) K.set(beat(bpb >= 4 ? 2 : 1), 0.55);- for (const s of back) Gh.set(s, 0.6);- for (let s = 0; s < steps; s += per === 3 ? 1 : 2) P.set(s, (s % per === 0 ? 0.55 : 0.3) * (1 + (r() - 0.5) * 0.3));- break;- }- case "build": {- const x = len > 1 ? pos / (len - 1) : 1, every = x < 0.5 ? 2 : 1;- for (let b = 0; b < bpb; b++) K.set(beat(b), 0.9);- for (let s = 0; s < steps; s += every) S.set(s, 0.35 + 0.6 * ((pos + s / steps) / len));- hats(2, 0.4, 0.6);- break;- }- case "tension": {- for (const s of [0, 3, 6, 8, 11, 14].map((q) => Math.round((q / 16) * steps))) K.set(s, s === 0 ? 1 : 0.75);- S.set(beat(bpb - 1), 0.9 * acc);- for (let s = 0; s < steps; s++) H.set(s, (s % per === 0 ? 0.4 : 0.22) * (0.6 + 0.8 * d));- if (v > 0.4 && maybe(0.5)) Gh.set(beat(bpb - 1, per - 1), 0.5);- break;- }- case "skip": {- K.set(0, 1); K.set(beat(1, 2), 0.8); if (maybe(0.3 + 0.4 * v)) K.set(beat(3, 1) < steps ? beat(3, 1) : beat(bpb - 1), 0.6);- for (const s of back) S.set(s, 0.9);- for (let s = 0; s < steps; s++) if (s % 4 === 1 || s % 4 === 3 || maybe(0.3 * d)) P.set(s, 0.3 + 0.25 * r());- hats(2, 0.4, 0.65);- break;- }- case "trap": {- K.set(0, 1); for (const s of [beat(0, 3), beat(1, 2), beat(2, 3), beat(3, 1), beat(3, 2)]) if (s < steps && maybe(0.2 + 0.4 * v)) K.set(s, 0.8 + 0.15 * r());- S.set(beat(Math.min(2, bpb - 1)), 1);- for (let s = 0; s < steps; s++) H.set(s, (s % 2 ? 0.35 : 0.6) * (1 + (r() - 0.5) * 0.2));- if (d > 0.5) { const b0 = Math.floor(r() * bpb); for (let j = 0; j < per; j++) H.set(beat(b0, j), 0.3 + (0.5 * j) / per); }- if (maybe(0.25 * d)) P.set(beat(bpb - 1, 2), 0.5);- break;- }- case "epic": {- const fig = v > 0.5 ? [0, 3, 6, 8, 11, 14] : [0, 8, 10];- for (const q of fig) { const s = Math.round((q / 16) * steps); K.set(s, q === 0 ? 1 : 0.8); if (d > 0.4) P.set(s, 0.7); }- S.set(beat(bpb - 1), 0.9);- if (d > 0.6) for (let s = 0; s < steps; s += 2) H.set(s, 0.3);- break;- }- case "hand": {- const eighths = Math.round(steps / (per === 3 ? 1 : 2)), unit = per === 3 ? 1 : 2;- const groups = meter === "7/8" ? [2, 2, 3] : meter === "9/8" ? [2, 2, 2, 3] : meter === "5/4" ? [3, 3, 2, 2] : Array.from({ length: Math.max(1, Math.round(eighths / 2)) }, () => 2);- let e8 = 0; groups.forEach((gsz, gi) => { const s0 = e8 * unit; K.set(s0, gi === 0 ? 1 : 0.8); for (let j = 1; j < gsz; j++) Gh.set((e8 + j) * unit, 0.5 + 0.2 * r()); if (d > 0.5 && maybe(0.5)) P.set((e8 + gsz) * unit - 1, 0.4); e8 += gsz; });- if (per === 3 && meter !== "9/8") { /* compound: groups of 3 eighths */ K.clear(); Gh.clear(); for (let b = 0; b < bpb; b++) { K.set(beat(b), b === 0 ? 1 : 0.75); Gh.set(beat(b, 1), 0.45); Gh.set(beat(b, 2), 0.55); } }- break;- }- case "rock": {- K.set(0, 1); if (bpb >= 3) K.set(beat(2), 0.9); if (maybe(0.3 + 0.5 * v)) K.set(beat(Math.min(2, bpb - 1), 2), 0.75);- for (const s of back) S.set(s, 1);- hats(2, 0.55, 0.8);- if (pos === 0) P.set(0, 0.9);- break;- }- case "swing": {- for (let b = 0; b < bpb; b++) { H.set(beat(b), 0.7); K.set(beat(b), 0.25); }- for (const s of back) { H.set(s + 2, 0.5); P.set(s, 0.5); }- for (let b = 0; b < bpb; b++) if (maybe(0.2 + 0.35 * d)) Gh.set(beat(b, 2), 0.3 + 0.2 * r());- break;- }- }- if (g.fill && pos === len - 1) { const f0 = steps - per; for (let s = f0; s < steps; s++) S.set(s, 0.45 + 0.5 * ((s - f0) / per)); }- const out: DrumBar = {};- for (const [lane, m] of [["kick", K], ["snare", S], ["ghost", Gh], ["hat", H], ["perc", P]] as [Lane, Map<number, number>][]) out[lane] = stepsToLine(m, steps, per);- return out;-};--export const isLiteral = (g: Groove): g is LiteralGroove => !("family" in g);-/** One bar of any groove (literal lanes cycle on the absolute bar). */-export const drumBar = (g: Groove, meter: Meter, seed: number, abs: number, pos: number, len: number, energy?: number): DrumBar => {- if (!isLiteral(g)) return grooveBar(g, meter, seed, abs, pos, len, energy);- const k = g.cycle === "piece" ? abs : pos, pick = (xs?: string[]) => (xs && xs.length ? xs[k % xs.length] || null : null);- return { kick: pick(g.kick), snare: pick(g.snare), ghost: pick(g.ghost), hat: pick(g.hat), perc: pick(g.perc) };-};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/index.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/index.tsindex d8bfe6e..fa997b2 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/index.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/index.ts@@ -8,29 +8,19 @@ export * from "./render";export * from "./meter";export * from "./guards";export * from "./score-text";-export * from "./grooves";-export * from "./vocab";-export * from "./vocabTrim";-export * from "./compose";export * from "./novelty";-export * from "./calibration";export * as instruments from "./instruments";export * from "./sfx";-export * as orchestra from "./orchestra";import { nocturne, pianoPhrase8 } from "./pieces/nocturne";-import { launchLofi, launchLofi2, launchLofi3, launchLofi3Material } from "./pieces/launch";+import { launchLofi, launchLofi2, launchLofi3 } from "./pieces/launch";import { musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic } from "./pieces/samplers";import { marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm } from "./pieces/families";import { ghostFixture } from "./pieces/fixtures";-import { daylightCopy, daylightCopyMaterial } from "./pieces/copyFixture";-export { launchLofi, launchLofi2, launchLofi3, launchLofi3Material, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm, ghostFixture, daylightCopy, daylightCopyMaterial };-/**- * SHIPPED MUSIC: the demos (one per style/mood, written to prove the synth and the meters) and our own- * film's scores. They are listening references and the novelty corpus, NEVER a film's score: a new- * film composes its own (references/music/compose.md) and `novelty` fails it if it sounds like these.- */-export const DEMOS = { launchLofi, launchLofi2, launchLofi3, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm };-/** Families: cuts of one score (compared to each other they are the same music, by design). */-export const DEMO_FAMILIES: Record<string, string[]> = { launch: ["launchLofi", "launchLofi2", "launchLofi3"], nocturne: ["nocturne", "pianoPhrase8"] };-/** Test fixtures, never scores: the ghost (must fail the ghost guard), the copy (must fail novelty). */-export const FIXTURES = { ghostFixture, daylightCopy };+import type { Piece } from "./plan";+export { launchLofi, launchLofi2, launchLofi3, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm, ghostFixture };+/** Named pieces a film (or the tool) can ask for. ghostFixture is a test fixture, never a score. */+export const PIECES = { launchLofi, launchLofi2, launchLofi3, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm, ghostFixture };+/** Every shipped score (the novelty corpus: a new score must not sound like these). */+export const SHIPPED: Record<string, () => Piece> = Object.fromEntries(Object.entries(PIECES).filter(([k]) => k !== "ghostFixture"));+/** Cuts of one score: compared to each other they are the same music, by design. */+export const PIECE_FAMILIES: Record<string, string[]> = { launch: ["launchLofi", "launchLofi2", "launchLofi3"], nocturne: ["nocturne", "pianoPhrase8"] };diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/novelty.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/novelty.tsindex 611d8b9..e2fe2bc 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/novelty.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/novelty.ts@@ -1,10 +1,9 @@-// NOVELTY: does a new score sound like one we already shipped? Alex heard "Daylight" as "almost the-// same as our launch track" although its key, chords and pitches were new: every layer kept the-// launch's RHYTHMS, the same contour, the same chord colours and the same form. So the fingerprint-// is mostly rhythm and shape, not pitch:+// NOVELTY: does a new score sound like one we already shipped? A copy can have a new key, new+// chords and new pitches and still be the same music when every layer keeps the old RHYTHMS, the+// same contour and the same chord colours. So the fingerprint is mostly rhythm and shape, not pitch:// melody rhythm (onset positions per bar, inter-onset n-grams), melody contour (up/down n-grams),// melody intervals (transposition-free n-grams), other lines' rhythm (counter, bass), drum bars,-// chord function (root vs key + quality) n-grams, chord-quality n-grams, section-kind sequence.+// chord function (root vs key + quality) n-grams, chord-quality n-grams.// Each feature is a bag of n-grams; similarity is the cosine of the bags; the score is a weighted// mean. `demoReuse` is the stricter gate: any 6-note melody fragment (intervals + durations) taken// from a demo fails outright, transposed or not.@@ -14,8 +13,8 @@ import { pcOf } from "./theory";type Bag = Map<string, number>;export type Fingerprint = Record<Feature, Bag>;-export type Feature = "melodyRhythm" | "melodyContour" | "melodyIntervals" | "lineRhythm" | "drums" | "chords" | "qualities" | "form";-export const NOVELTY_WEIGHTS: Record<Feature, number> = { melodyRhythm: 0.2, melodyContour: 0.15, melodyIntervals: 0.1, lineRhythm: 0.15, drums: 0.15, chords: 0.1, qualities: 0.07, form: 0.08 };+export type Feature = "melodyRhythm" | "melodyContour" | "melodyIntervals" | "lineRhythm" | "drums" | "chords" | "qualities";+export const NOVELTY_WEIGHTS: Record<Feature, number> = { melodyRhythm: 0.2, melodyContour: 0.15, melodyIntervals: 0.1, lineRhythm: 0.15, drums: 0.15, chords: 0.1, qualities: 0.07 };/** Above this a piece is too close to a shipped one. Calibrated: the copy fixture scores far above it, unrelated demos far below (tools/music-unit.mjs). */export const NOVELTY_THRESHOLD = 0.5;@@ -44,7 +43,6 @@ export const fingerprint = (p: Piece): Fingerprint => {const tonic = pcOf(p.plan.sections[0].key.replace(/m$/, "")), seq: string[] = [], qs: string[] = [];for (const c of p.harmony.slice().sort((a, b) => a.t - b.t)) { const m = /^([A-G][#b]?)/.exec(c.name); if (!m) continue; const f = `${(pcOf(m[1]) - tonic + 12) % 12}${quality(c.name)}`; if (seq[seq.length - 1] !== f) { seq.push(f); qs.push(quality(c.name)); } }grams(seq, 3, (g) => g.join(" "), F.chords); grams(qs, 3, (g) => g.join(" "), F.qualities);- const kinds = (p.arrangement ?? []).map((a) => a.kind); grams(kinds, 2, (g) => g.join(">"), F.form);return F;};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/orchestra.tsdeleted file mode 100644index 1dd887b..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts+++ /dev/null@@ -1,110 +0,0 @@-// ORCHESTRA AND BAND VOICES, added for breadth (orchestral, choral, suspense, rock, synthwave,-// world). Procedural approximations, deterministic, pure in (keys, sr, n, opts, rng). Acoustic-// timbres made this way are approximations: a human listens before one carries a film (spec 08-// DECISION B). Each voice states the physics it borrows.-import { type Rng, TAU, clamp, pan, SVF, blep, gauss } from "./dsp";-import type { Played } from "./perform";--type Out = { L: Float32Array; R: Float32Array };-type Opts = Record<string, number | boolean | string>;-const num = (o: Opts, k: string, d: number) => (typeof o[k] === "number" ? (o[k] as number) : d);-const f0 = (m: number) => 440 * Math.pow(2, (m - 69) / 12);-const out0 = (n: number): Out => ({ L: new Float32Array(n), R: new Float32Array(n) });-const byPitch = (p: number, w: number) => pan(clamp((p - 60) / 30, -1, 1) * w);-/** attack / sustain / release envelope for a held key */-const asr = (t: number, dur: number, atk: number, rel: number) => (t < dur ? Math.min(1, t / atk) : Math.min(1, dur / atk) * Math.exp(-(t - dur) / (rel / 4)));--/** Pipe organ: drawbar ranks (harmonics 1 2 3 4 6 8) summed per pipe, two detuned copies (chorus), a slow tremulant. `bright` weights the upper ranks. */-export const organ = (keys: Played[], sr: number, n: number, o: Opts): Out => {- const out = out0(n), bright = num(o, "bright", 1), trem = num(o, "trem", 5.5), ranks = [[1, 1], [2, 0.7], [3, 0.35 * bright], [4, 0.35 * bright], [6, 0.18 * bright], [8, 0.12 * bright]];- for (const k of keys) {- const f = f0(k.p), i0 = Math.round(k.t * sr), dur = k.off - k.t, len = Math.min(n - i0, Math.ceil((dur + 0.15) * sr)), [gl, gr] = byPitch(k.p, 0.5);- for (let i = 0; i < len; i++) { const t = i / sr, e = asr(t, dur, 0.015, 0.08) * k.v * 0.09 * (1 + 0.06 * Math.sin(TAU * trem * t));- let s = 0; for (const [h, a] of ranks) if (f * h < sr / 2.2) s += a * (Math.sin(TAU * f * h * t) + Math.sin(TAU * f * h * 1.0012 * t + 1.3)) * 0.5;- out.L[i0 + i] += s * e * gl; out.R[i0 + i] += s * e * gr; }- }- return out;-};--/** Brass: a PolyBLEP saw whose low-pass opens with loudness (the brass "bite"), the pitch rising ~25 cents into the note, vibrato delayed. `attack`, `bright`. */-export const brass = (keys: Played[], sr: number, n: number, o: Opts): Out => {- const out = out0(n), atk = num(o, "attack", 0.06), bright = num(o, "bright", 1), w = num(o, "width", 0.5);- for (const k of keys) {- const f = f0(k.p), i0 = Math.round(k.t * sr), dur = k.off - k.t, len = Math.min(n - i0, Math.ceil((dur + 0.3) * sr)), lp = new SVF(sr, 800, 0.8), [gl, gr] = byPitch(k.p, w); let ph = 0;- for (let i = 0; i < len; i++) { const t = i / sr, e = asr(t, dur, atk, 0.25), cents = -25 * Math.exp(-t / 0.05) + (t > 0.25 ? 12 * Math.sin(TAU * 5.2 * t) * Math.min(1, (t - 0.25) / 0.3) : 0), inc = (f * Math.pow(2, cents / 1200)) / sr;- ph += inc; if (ph >= 1) ph -= 1; if ((i & 15) === 0) lp.set(clamp(f * (1.5 + 7 * e * k.v * bright), 200, 12000), 0.8);- const y = lp.tick(2 * ph - 1 - blep(ph, inc)) * e * k.v * 0.22; out.L[i0 + i] += y * gl; out.R[i0 + i] += y * gr; }- }- return out;-};--/** Woodwind: flute (sine + weak 2nd/3rd + breath noise at the pitch) or `reed: true` clarinet (odd harmonics, darker). Delayed vibrato. */-export const woodwind = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => {- const out = out0(n), reed = o.reed === true, breath = num(o, "breath", reed ? 0.02 : 0.08), w = num(o, "width", 0.3);- for (const k of keys) {- const f = f0(k.p), i0 = Math.round(k.t * sr), dur = k.off - k.t, len = Math.min(n - i0, Math.ceil((dur + 0.2) * sr)), bp = new SVF(sr, f, 4), [gl, gr] = byPitch(k.p, w); let ph = 0;- for (let i = 0; i < len; i++) { const t = i / sr, e = asr(t, dur, reed ? 0.04 : 0.07, 0.15), vib = t > 0.2 ? 1 + 0.004 * Math.sin(TAU * 5 * t) * Math.min(1, (t - 0.2) / 0.3) : 1;- ph += (f * vib) / sr; if (ph >= 1) ph -= 1; const x = TAU * ph;- const tone = reed ? Math.sin(x) + 0.33 * Math.sin(3 * x) + 0.18 * Math.sin(5 * x) + 0.08 * Math.sin(7 * x) : Math.sin(x) + 0.12 * Math.sin(2 * x) + 0.05 * Math.sin(3 * x);- bp.tick(gauss(r)); const y = (tone * 0.8 + bp.bp * breath * 6) * e * k.v * 0.16; out.L[i0 + i] += y * gl; out.R[i0 + i] += y * gr; }- }- return out;-};--const VOWELS: Record<string, [number, number, number]> = { a: [700, 1220, 2600], o: [450, 800, 2830], u: [325, 700, 2530], e: [530, 1840, 2480], i: [300, 2200, 3000] };-/** Choir: three detuned saws per note through the formants of a vowel (`vowel`: a o u e i), slow attack. Texture and pads; never a lead. */-export const choir = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => {- const out = out0(n), fm = VOWELS[String(o.vowel ?? "a")] ?? VOWELS.a, atk = num(o, "attack", 0.35), w = num(o, "width", 0.8);- for (const k of keys) {- const f = f0(k.p), i0 = Math.round(k.t * sr), dur = k.off - k.t, len = Math.min(n - i0, Math.ceil((dur + 0.8) * sr));- const dets = [-9, 0, 8], phs = dets.map(() => r()), vr = dets.map(() => 4.5 + r()), pans = dets.map((_, j) => pan((j - 1) * w));- const fl = [0, 1].map(() => fm.map((q, j) => new SVF(sr, q, [9, 11, 13][j])));- for (let i = 0; i < len; i++) { const t = i / sr, e = asr(t, dur, atk, 0.7) * k.v * 0.14; let sl = 0, sR = 0;- for (let v = 0; v < 3; v++) { const inc = (f * Math.pow(2, (dets[v] + 10 * Math.sin(TAU * vr[v] * t)) / 1200)) / sr; let ph = phs[v] + inc; if (ph >= 1) ph -= 1; phs[v] = ph; const s = 2 * ph - 1 - blep(ph, inc); sl += s * pans[v][0]; sR += s * pans[v][1]; }- let yl = 0, yr = 0; for (let j = 0; j < 3; j++) { fl[0][j].tick(sl); fl[1][j].tick(sR); yl += fl[0][j].bp * [1, 0.6, 0.3][j]; yr += fl[1][j].bp * [1, 0.6, 0.3][j]; }- out.L[i0 + i] += yl * e; out.R[i0 + i] += yr * e; }- }- return out;-};--/** Timpani (`pitch`: a MIDI note to tune it when it plays a drum lane): a tuned membrane (modal partials 1, 1.5, 1.99, 2.44, 2.97 with their own decays), a small downward pitch settle, a felt-mallet thump. Pitched on the note. */-export const timpani = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => {- const out = out0(n), dec = num(o, "decay", 1.6), P = [[1, 1, 1], [1.5, 0.5, 0.7], [1.99, 0.35, 0.5], [2.44, 0.2, 0.35], [2.97, 0.12, 0.25]];- for (const k of keys) {- const f = f0(typeof o.pitch === "number" ? (o.pitch as number) : k.p), i0 = Math.round(k.t * sr), len = Math.min(n - i0, Math.ceil(dec * 4 * sr)), lp = new SVF(sr, 400, 0.7);- for (let i = 0; i < len; i++) { const t = i / sr, bend = 1 + 0.03 * Math.exp(-t / 0.08); let s = 0;- for (const [h, a, d] of P) s += a * Math.sin(TAU * f * h * bend * t) * Math.exp(-t / (dec * d));- lp.tick(gauss(r)); const y = (s + lp.lp * Math.exp(-t / 0.012) * 3) * k.v * 0.3; out.L[i0 + i] += y; out.R[i0 + i] += y * 0.97; }- }- return out;-};--/** Lead synth: monophonic saw + square, portamento `glide` s between touching notes, a filter envelope re-struck each note, vibrato blooming on long notes (spec 06 lead). */-export const leadSynth = (keys: Played[], sr: number, n: number, o: Opts): Out => {- const out = out0(n), glide = num(o, "glide", 0.03), cut = num(o, "cut", 1700), envAmt = num(o, "env", 4500), sq = num(o, "square", 0.4), [gl, gr] = pan(num(o, "pan", 0));- const ks = keys.slice().sort((a, b) => a.t - b.t); let prevF = 0, prevOff = -1, ph = 0, ph2 = 0; const lp = new SVF(sr, cut, 1.2);- ks.forEach((k, idx) => {- const f = f0(k.p), i0 = Math.round(k.t * sr), nextT = idx + 1 < ks.length ? ks[idx + 1].t : Infinity, dur = Math.min(k.off, nextT) - k.t, tail = nextT < k.off + 0.12 ? nextT - k.t : dur + 0.12;- const len = Math.min(n - i0, Math.ceil(Math.max(0.01, tail) * sr)), from = prevF && k.t - prevOff < 0.05 ? prevF : f;- for (let i = 0; i < len; i++) { const t = i / sr, fr = from + (f - from) * Math.min(1, t / Math.max(1e-4, glide)), vib = t > 0.3 ? 1 + 0.006 * Math.sin(TAU * 5.5 * t) * Math.min(1, (t - 0.3) / 0.4) : 1, inc = (fr * vib) / sr;- ph += inc; if (ph >= 1) ph -= 1; ph2 += inc; if (ph2 >= 1) ph2 -= 1;- const e = Math.min(1, t / 0.006) * (t < dur ? 1 : Math.exp(-(t - dur) / 0.03));- if ((i & 15) === 0) lp.set(clamp(cut + envAmt * k.v * Math.exp(-t / 0.18), 150, 14000), 1.2);- const y = lp.tick((2 * ph - 1 - blep(ph, inc)) + sq * (ph2 < 0.5 ? 1 : -1)) * e * k.v * 0.18; out.L[i0 + i] += y * gl; out.R[i0 + i] += y * gr; }- prevF = f; prevOff = k.t + dur;- });- return out;-};--/** Bowed solo (violin / cello): one saw with delayed vibrato and bow noise through body resonances (~280, 450, 2800 Hz), a bowed attack. */-export const bowedSolo = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => {- const out = out0(n), atk = num(o, "attack", 0.09), vibC = num(o, "vibrato", 22), [gl, gr] = pan(num(o, "pan", -0.1));- const body = o.cello === true ? [140, 300, 1600] : [280, 450, 2800];- for (const k of keys) {- const f = f0(k.p), i0 = Math.round(k.t * sr), dur = k.off - k.t, len = Math.min(n - i0, Math.ceil((dur + 0.35) * sr)), bs = body.map((q) => new SVF(sr, q, 2.2)), lp = new SVF(sr, 5000, 0.7); let ph = 0;- for (let i = 0; i < len; i++) { const t = i / sr, e = asr(t, dur, atk, 0.3), vib = t > 0.15 ? vibC * Math.sin(TAU * 5.6 * t) * Math.min(1, (t - 0.15) / 0.35) : 0, inc = (f * Math.pow(2, vib / 1200)) / sr;- ph += inc; if (ph >= 1) ph -= 1; const x = 2 * ph - 1 - blep(ph, inc) + gauss(r) * 0.06;- let y = lp.tick(x) * 0.35; for (const b of bs) { b.tick(x); y += b.bp * 0.5; } y *= e * k.v * 0.16; out.L[i0 + i] += y * gl; out.R[i0 + i] += y * gr; }- }- return out;-};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/copyFixture.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/copyFixture.tsdeleted file mode 100644index 258b9ff..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/copyFixture.ts+++ /dev/null@@ -1,34 +0,0 @@-// COPY FIXTURE (a test fixture, never a score). "Daylight" was offered as a lo-fi electronic example-// and Alex heard it at once: "almost the same as our launch track". It changed the key (D), the-// chords (I-vi-IV-V) and the pitches, but kept the launch's rhythms in every layer (hook cell per-// chord, sparkle answer, sub root + walk, the same drum bars) and its arrangement. The novelty gate-// (novelty.ts) must score it as a copy of launchLofi3: that is the proof the gate hears what she heard.-import type { Piece } from "../plan";-import { composePiece, type Material } from "../compose";--const HATS = Array.from({ length: 16 }, (_, i) => `C4:.25@${[0.85, 0.35, 0.6, 0.4][i % 4]}`).join(" ");-export const daylightCopyMaterial = (): Material => ({- style: "lofiElectronic", title: "Daylight (copy fixture)", seed: 96, mood: "joy", bpm: 96, key: "D", mode: "major", swing: 0.54,- chords: {- Dmaj9: { voicing: "[F#3 A3 C#4 E4]", bass: "D2:3 r:.5 A1:.5" }, Bm9: { voicing: "[F#3 A3 C#4 D4]", bass: "B1:3 r:.5 F#1:.5" },- Gmaj9: { voicing: "[F#3 A3 B3 D4]", bass: "G1:3 r:.5 D2:.5" }, A13: { voicing: "[G3 B3 C#4 F#4]", bass: "A1:3 r:.5 E2:.5" },- },- motifs: {- h0: "r:.5 F#4:.5 A4:.5 D5:1 C#5:.5 A4:1", h1: "r:.5 F#4:.5 B4:.5 C#5:.5 D5:1 B4:1", h2: "r:.5 D5:.5 E5:.5 F#5:1 E5:.5 D5:1", h3: "C#5:1.5 B4:.5 A4:1 r:1",- s0: "r:1 A5:.5 C#6:.5 E6:2", s1: "r:1 F#5:.5 A5:.5 C#6:2", s2: "r:1 F#6:.5 D6:.5 B5:2", s3: "C#6:1 B5:1 A5:2",- },- grooves: {- main: { kick: ["C4:1.5 C4:[email protected] C4:[email protected]", "C4:1.5 C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected]"], snare: ["r:1 C4:2 C4:1"], ghost: ["r:3.75 C4:[email protected]", "r:1.75 C4:[email protected] r:2"], hat: [HATS], cycle: "piece" },- half: { kick: ["C4:2 r:2"], snare: ["r:2 C4:2"], hat: ["C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected]"], cycle: "piece" },- },- sections: [- { kind: "intro", bars: 2, harmony: ["Gmaj9", "A13"], chordVel: 0.8 },- { kind: "hook", bars: 4, harmony: ["Dmaj9", "Bm9", "Gmaj9", "A13"], lead: ["h0", "h1", "h2", "h3"] },- { kind: "hook", bars: 4, harmony: ["Dmaj9", "Bm9", "Gmaj9", "A13"], lead: ["h0", "h1", "h2", "h3"], counter: ["s0", "s1", "s2", "s3"] },- { kind: "half", bars: 2, harmony: ["Dmaj9", "Bm9"], counter: ["s0", "s1"] },- { kind: "breakdown", bars: 2, harmony: ["Gmaj9", "A13"] },- { kind: "drop", bars: 1, harmony: ["Dmaj9"], lead: ["h0"] },- { kind: "outro", bars: 2, harmony: ["Dmaj9"], chordVel: 0.75, bass: "D2:4", lead: ["r:4", "D5:4"] },- ],-});-export const daylightCopy = (): Piece => composePiece(daylightCopyMaterial());diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/launch.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/launch.tsindex 65ea174..8957db6 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/launch.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/launch.ts@@ -4,7 +4,7 @@// (lofiKit.ts): no electric piano, no vinyl, no bit-crush, a clean master, a tight detuned-saw pad// pumping under the kick, a bright pluck lead through a dotted-eighth ping-pong delay, high sparkle// plucks, a sine sub, a bouncy kick, a snare on 2 and 4 with rim ghosts, 16th hats. Levels were set-// by measuring each part (node tools/music.mjs stems) against published targets.+// by measuring each part's stem (stemTargets below, checked by node tools/music.mjs stems).// Harmony: the ii-V-I-vi loop Dm9 G13 Cmaj9 Am9 from bar 2, every 4 bars, so bar 36 (the film's// "All in pure code.") lands on Cmaj9, home, and the last bar holds it.//@@ -14,7 +14,6 @@// [the live page] · 30-33 hook + sparkle [the film] · 34-35 breakdown, drums out [the reveal] ·// 36 everything back [All in pure code.] · 37-38 outro, Cmaj9 held [the end card].import { line, type Note, type Piece, type Role } from "../plan";-import { composePiece, type Material } from "../compose";export const LAUNCH_BPM = 90, LAUNCH_BARS = 39;const L = (t: number, s: string, role: Role, v = 0.7, extra: { roll?: number } = {}) => line(t, s, { role, v, bpb: 4, ...extra });@@ -67,39 +66,24 @@ export const launchLofi2 = (): Piece => {// 11-13 hook [bricks] · 14-15 half-time [Van Gogh] · 16 sparkle [LOOPS] · 17-21 groove, hook from// 19 [INTERACTIVE, the site] · 22-23 sparkle [FILMS, the film] · 24-25 breakdown [the five words] ·// 26 everything back [All in pure code.] · 27-28 home [the end card].-// Written as composed material on the lo-fi electronic vocabulary (compose.ts); its audio is-// bit-identical to the hand-written v6 (md5 of renderPiece at 48 kHz d20789f2344e6fff0d2a380c7c7825d2,-// guarded by tools/music-unit.mjs). This is OUR film's score: a demo, never a template (the novelty-// gate fails any film that reuses it).export const LAUNCH3_BARS = 29;-export const launchLofi3Material = (): Material => {- const hk = (i: number) => `hook${i}`, sp = (i: number) => `spark${i}`;- return {- style: "lofiElectronic", title: "anidoodle launch, cut 3", seed: 2027, mood: "calm", bpm: LAUNCH_BPM, key: "C", mode: "major", swing: 0.54, tail: 3.2,- chords: { Dm9: { voicing: PAD[0], bass: SUB[0] }, G13: { voicing: PAD[1], bass: SUB[1] }, Cmaj9: { voicing: PAD[2], bass: SUB[2] }, Am9: { voicing: PAD[3], bass: SUB[3] } },- motifs: Object.fromEntries([...HOOK.map((h, i) => [hk(i), h]), ...SPARK.map((x, i) => [sp(i), x])]),- grooves: {- main: { kick: [KICK[0], KICK[1]], snare: ["r:1 C4:2 C4:1"], ghost: ["r:3.75 C4:[email protected]", "r:1.75 C4:[email protected] r:2"], hat: [HATS], cycle: "piece" },- half: { kick: ["C4:2 r:2"], snare: ["r:2 C4:2"], hat: ["C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected]"], cycle: "piece" },- },- sections: [- { kind: "intro", bars: 2, harmony: ["Cmaj9", "Am9"], chordVel: 0.8 },- { kind: "groove", bars: 4, harmony: ["Cmaj9", "Am9", "Dm9", "G13"] },- { kind: "hook", bars: 2, harmony: ["Cmaj9", "Am9"], lead: [hk(2), hk(3)] },- { kind: "hook", bars: 3, harmony: ["Dm9", "G13", "Cmaj9"], lead: [hk(0), hk(1), hk(2)], counter: [sp(0), sp(1), sp(2)] },- { kind: "hook", bars: 3, harmony: ["Am9", "Dm9", "G13"], lead: [hk(3), hk(0), hk(1)] },- { kind: "half", bars: 2, harmony: ["Cmaj9", "Am9"] },- { kind: "groove", bars: 1, harmony: ["Dm9"], counter: [sp(0)] },- { kind: "groove", bars: 2, harmony: ["G13", "Cmaj9"] },- { kind: "hook", bars: 3, harmony: ["Am9", "Dm9", "G13"], lead: [hk(3), hk(0), hk(1)] },- { kind: "groove", bars: 2, harmony: ["Cmaj9", "Am9"], counter: [sp(2), sp(3)] },- { kind: "breakdown", bars: 2, harmony: ["Dm9", "G13"], counter: [sp(0), sp(1)] },- { kind: "drop", bars: 1, id: "claim", harmony: ["Cmaj9"], lead: [hk(2)] },- { kind: "outro", bars: 2, harmony: ["Cmaj9"], chordVel: 0.75, bass: "C2:4", lead: ["r:4", "C5:4"] },- ],- };+export const launchLofi3 = (): Piece => {+ const B = LAUNCH3_BARS, last = B - 1, ci = (b: number) => (b < 2 ? -1 : b % 4);+ const bars = (fn: (b: number, c: number) => string | null, role: Role, v: number, extra: { roll?: number } = {}): Note[] => { const out: Note[] = []; for (let b = 0; b < B; b++) { const x = fn(b, ci(b)); if (x) out.push(...L(b * 4, x, role, v, extra)); } return out; };+ const full: [number, number][] = [[2, 13], [16, 23], [26, 26]], half: [number, number][] = [[14, 15]];+ const pad = bars((b, c) => (b >= 27 ? `${PAD[2]}:[email protected]` : c < 0 ? `${PAD_INTRO[b]}:[email protected]` : `${PAD[c]}:4`), "accomp", 0.62, { roll: 0.03 });+ const sub = bars((b, c) => (c < 0 || inRanges(b, [[24, 25]]) ? null : b >= 27 ? "C2:4" : SUB[c]), "bass", 0.85);+ const kick = bars((b) => (inRanges(b, full) ? KICK[b % 2] : inRanges(b, half) ? "C4:2 r:2" : null), "drum", 0.85);+ const snare = bars((b) => (inRanges(b, full) ? "r:1 C4:2 C4:1" : inRanges(b, half) ? "r:2 C4:2" : null), "drum", 0.7);+ const ghost = bars((b) => (inRanges(b, full) ? (b % 2 ? "r:1.75 C4:[email protected] r:2" : "r:3.75 C4:[email protected]") : null), "drum", 0.5);+ const hats = bars((b) => (inRanges(b, full) ? HATS : inRanges(b, half) ? "C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected]" : null), "drum", 0.5);+ const lead = bars((b, c) => (inRanges(b, [[6, 13], [19, 21], [26, 26]]) ? HOOK[c] : b === last ? "C5:4" : null), "melody", 0.72);+ const sparkle = bars((b, c) => (inRanges(b, [[8, 10], [16, 16], [22, 25]]) ? SPARK[c] : null), "color", 0.5);+ const harmony = Array.from({ length: B }, (_, b) => ({ t: b * 4, name: b < 2 ? ["Cmaj9", "Am9"][b] : b >= 27 ? "Cmaj9" : ["Dm9", "G13", "Cmaj9", "Am9"][b % 4] }));+ const base = launchLofi();+ return { ...base, title: "anidoodle launch, cut 3", harmony, plan: { ...base.plan, sections: [{ ...base.plan.sections[0], bars: B }] },+ parts: base.parts.map((pt) => ({ ...pt, notes: ({ pad, lead, sparkle, sub, kick, snare, ghost, hat: hats } as Record<string, Note[]>)[pt.id] })) };};-export const launchLofi3 = (): Piece => composePiece(launchLofi3Material());export const launchLofi = (): Piece => {const full: [number, number][] = [[2, 18], [23, 33], [36, 36]], half: [number, number][] = [[19, 22]], last = LAUNCH_BARS - 1;@@ -126,5 +110,7 @@ export const launchLofi = (): Piece => {{ id: "hat", inst: "hat", role: "drum", notes: hats, opts: { pan: 0.25 }, gainDb: 20, send: 0.1 },],fx: { clean: true, duck: { by: "kick", parts: ["pad", "sparkle"], depth: 0.38, release: 0.24 }, tape: { wowCents: 2.5, wowHz: 0.4, flutterCents: 0, flutterHz: 6, drive: 1.02 } },+ // the mix as it was balanced by ear and meter: each stem's RMS (dBFS, active samples) within 3 dB+ stemTargets: { kick: -14, snare: -20, hat: -28, sub: -18, pad: -21, lead: -16.5, sparkle: -24 },};};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/plan.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/plan.tsindex c7fd979..c035e9d 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/plan.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/plan.ts@@ -4,15 +4,13 @@import { midi, type ModeId, MODES, detectMode, pcOf, modeFit } from "./theory";import { MOODS, STYLES, REFUSED_BLENDS, type MoodId, type StyleId, type MelodyType } from "./tables";-export type Meter = "2/4" | "3/4" | "4/4" | "5/4" | "6/8" | "7/8" | "9/8" | "12/8";-/** Beats per bar. Simple meters count quarters (7/8 = 3.5 quarters, write eighths as .5); compound meters (6/8, 9/8, 12/8) count dotted quarters (write eighths as 1/3). */-export const beatsPerBar = (m: Meter) => ({ "2/4": 2, "3/4": 3, "4/4": 4, "5/4": 5, "6/8": 2, "7/8": 3.5, "9/8": 3, "12/8": 4 })[m];-export const isCompound = (m: Meter) => m === "6/8" || m === "9/8" || m === "12/8";+export type Meter = "3/4" | "4/4" | "6/8" | "12/8";+export const beatsPerBar = (m: Meter) => (m === "3/4" ? 3 : m === "4/4" ? 4 : m === "6/8" ? 2 : 4);export type Role = "melody" | "inner" | "bass" | "accomp" | "color" | "drum";/** t, d in beats from the piece start; p = MIDI; v = written velocity 0..1 (performance shapes it). */export type Note = { t: number; d: number; p: number; v: number; role: Role; roll?: number; kind?: string };-export type InstId = "piano" | "musicBox" | "bell" | "celesta" | "marimba" | "vibes" | "harp" | "guitar" | "strings" | "fmBell" | "ePiano" | "pulse" | "triangle" | "noiseDrum" | "kick" | "snare" | "hat" | "bass" | "vinyl" | "warmPad" | "softPluck" | "sub" | "organ" | "brass" | "woodwind" | "choir" | "timpani" | "leadSynth" | "bowedSolo";+export type InstId = "piano" | "musicBox" | "bell" | "celesta" | "marimba" | "vibes" | "harp" | "guitar" | "strings" | "fmBell" | "ePiano" | "pulse" | "triangle" | "noiseDrum" | "kick" | "snare" | "hat" | "bass" | "vinyl" | "warmPad" | "softPluck" | "sub";export type Part = { id: string; inst: InstId; role: Role; notes: Note[]; gainDb?: number; pan?: number; opts?: Record<string, number | boolean | string>; send?: number };export type Section = {id: string; bars: number; mood: MoodId | [MoodId, MoodId, number]; key: string; mode: ModeId; melody: MelodyType[];@@ -30,10 +28,7 @@ export type Chord = { t: number; name: string };export type PieceFx = { clean?: boolean /* skip the lo-fi master tone (low-pass, shelf, saturation) */; duck?: { by: string; parts: string[]; depth?: number; release?: number }; tape?: { wowCents?: number; wowHz?: number; flutterCents?: number; flutterHz?: number; drive?: number } };export type Piece = { title: string; plan: MusicPlan; parts: Part[]; harmony: Chord[]; tail: number; seed: number; fx?: PieceFx;/** a shorter complete form of the same music, chosen automatically when the film is too short for this one */ shortForm?: () => Piece;- /** rebuild the same music for a film `seconds` long so it still ends on its phrase (lofiElectronic: loop cycles added or removed); `fitScore` calls it before fitToDuration */ refit?: (seconds: number) => Piece;- /** composer-facing notes from compose (a line shorter than its section, ...): printed by tools/music.mjs check */ warnings?: string[];- /** mix targets: RMS dBFS of each part's stem, measured over its active samples (`stemBalance`) */ stemTargets?: Record<string, number>;- /** the arrangement as bar ranges, for the score and the docs (the plan may keep a single dynamics section) */ arrangement?: { id: string; kind: string; from: number; bars: number }[] };+ /** mix targets: RMS dBFS of each part's stem, measured over its active samples (`stemBalance`) */ stemTargets?: Record<string, number> };// ---------------------------------------------------------------- notation// "Eb4:1 | C5:2 Bb4:.5 Ab4:.5 | [Ab2 Eb3]:1 r:2 | G5:1/[email protected] ..." ; a token is NOTE:DUR[@VEL] ordiff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/render.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/render.tsindex f9fa296..872590d 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/render.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/render.ts@@ -6,7 +6,6 @@ import { type Piece, type Part, resequence, beatsPerBar } from "./plan";import { perform, type Performance, type Played } from "./perform";import { renderPiano, PIANO_REAL, type PianoOpts } from "./piano";import * as I from "./instruments";-import * as O from "./orchestra";import { room, Biquad, db } from "./dsp";import { warmPad, softPluck, sub, duckCurve, tape } from "./lofiKit";import { loudness, truePeak, stemBalance } from "./meter";@@ -41,13 +40,6 @@ const voice = (pt: Part, keys: Played[], sr: number, n: number, seed: number) =>case "warmPad": return warmPad(keys, sr, n, o, r);case "softPluck": return softPluck(keys, sr, n, o);case "sub": return sub(keys, sr, n, o);- case "organ": return O.organ(keys, sr, n, o);- case "brass": return O.brass(keys, sr, n, o);- case "woodwind": return O.woodwind(keys, sr, n, o, r);- case "choir": return O.choir(keys, sr, n, o, r);- case "timpani": return O.timpani(keys, sr, n, o, r);- case "leadSynth": return O.leadSynth(keys, sr, n, o);- case "bowedSolo": return O.bowedSolo(keys, sr, n, o, r);default: throw new Error(`no instrument ${pt.inst}`);}};@@ -110,8 +102,6 @@ export const master = (L: Float32Array, R: Float32Array, sr: number, masterMode:if (masterMode === "gentle") { const cut = tp + 1.05; gainDb -= cut; for (let i = 0; i < n; i++) { L[i] *= db(-cut); R[i] *= db(-cut); } }else {limiter(L, R, sr, db(-1.3)); const again = target - loudness([L, R], sr).integrated; if (again > 0) { const g = db(Math.min(again, 1)); for (let i = 0; i < n; i++) { L[i] *= g; R[i] *= g; } limiter(L, R, sr, db(-1.3)); }- const tp2 = truePeak([L, R]).dbtp; // harsh waveforms (pulses) can still overshoot between samples: a last static trim- if (tp2 > -1) { const cut = tp2 + 1.05; gainDb -= cut; for (let i = 0; i < n; i++) { L[i] *= db(-cut); R[i] *= db(-cut); } }}}return gainDb;@@ -132,9 +122,6 @@ export const renderLoop = (piece: Piece, sr: number): Rendered & { loopS: numberreturn { ...r, L, R, gainDb, masterMode: mode, loopS };};-/** The score for a film `seconds` long: the piece's own `refit` first (so it still ends on a phrase), then fitToDuration for the tempo. */-export const fitScore = (piece: Piece, seconds: number) => fitToDuration(piece.refit ? piece.refit(seconds) : piece, seconds);-/** Each part's stem level against the piece's targets (unmastered, pre-room: the mix as the parts were set). */export const measureStems = (piece: Piece, sr: number, o: RenderOpts = {}, tolDb = 3) => {const r = renderPiece(piece, sr, { ...o, stems: true, master: "none" });@@ -190,6 +177,6 @@ export const fitToDuration = (piece: Piece, seconds: number): { piece: Piece; te/** What a Film's `audio(sampleRate)` returns: [L, R] at exactly the film's length. */export const filmAudio = (piece: Piece, seconds: number) => (sr: number): [Float32Array, Float32Array] => {- const fit = fitScore(piece, seconds), r = renderPiece(fit.piece, sr, { seconds, tempo: fit.tempo });+ const fit = fitToDuration(piece, seconds), r = renderPiece(fit.piece, sr, { seconds, tempo: fit.tempo });return [r.L, r.R];};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/tables.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/tables.tsindex 2e2ddc4..d86db96 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/tables.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/tables.ts@@ -4,14 +4,14 @@import type { ModeId } from "./theory";export type MelodyType = "arpeggio" | "stepwise" | "hook" | "ostinato" | "drone" | "callResponse" | "counterMelody" | "sequence" | "themeTransformation";-export type Family = "piano" | "musicBox" | "celesta" | "mallets" | "pluck" | "harp" | "guitar" | "strings" | "fmBell" | "ePiano" | "chip" | "drums" | "organ" | "bass" | "pad" | "brass" | "woodwind" | "choir" | "orchPerc" | "synthLead" | "bowed";+export type Family = "piano" | "musicBox" | "celesta" | "mallets" | "pluck" | "harp" | "guitar" | "strings" | "fmBell" | "ePiano" | "chip" | "drums" | "organ" | "bass";export type Range = [number, number];export type Mood = {id: MoodId; modes: ModeId[]; tempo: Range; meters: string[]; harmonicRhythmBars: Range; register: Range;onsetsPerBeat: Range; attackMs: Range; lra: Range; centroidHz: Range | null; families: Family[]; melody: MelodyType[];master: "gentle" | "dense"; confirmedBy?: { date: string; words: string };};-export type MoodId = "joy" | "playful" | "tender" | "wistful" | "melancholy" | "hopeful" | "curious" | "tension" | "dread" | "awe" | "triumph" | "drive" | "calm" | "nostalgic" | "romantic" | "anger" | "eerie" | "mischief" | "heroic" | "sensual" | "grief";+export type MoodId = "joy" | "playful" | "tender" | "wistful" | "melancholy" | "hopeful" | "curious" | "tension" | "dread" | "awe" | "triumph" | "drive" | "calm" | "nostalgic" | "romantic";// centroid null = report only (spec 08 drive row; ADVISORY 4.1: piano brightness is never gated).export const MOODS: Record<MoodId, Mood> = {@@ -29,12 +29,6 @@ export const MOODS: Record<MoodId, Mood> = {drive: { id: "drive", modes: ["aeolian", "dorian", "mixolydian"], tempo: [110, 140], meters: ["4/4"], harmonicRhythmBars: [1, 1], register: [60, 86], onsetsPerBeat: [4, 8], attackMs: [1, 5], lra: [4, 8], centroidHz: null, families: ["drums", "bass", "pluck"], melody: ["hook", "arpeggio", "ostinato"], master: "dense" },calm: { id: "calm", modes: ["mixolydian", "majorPentatonic", "major"], tempo: [60, 90], meters: ["6/8", "3/4"], harmonicRhythmBars: [2, 2], register: [60, 84], onsetsPerBeat: [1, 2], attackMs: [5, 30], lra: [4, 8], centroidHz: [1000, 2000], families: ["guitar", "fmBell"], melody: ["stepwise", "drone"], master: "gentle" },nostalgic: { id: "nostalgic", modes: ["major"], tempo: [70, 95], meters: ["4/4"], harmonicRhythmBars: [0.5, 1], register: [60, 84], onsetsPerBeat: [1.5, 3], attackMs: [5, 20], lra: [6, 10], centroidHz: [900, 1600], families: ["ePiano", "drums", "bass"], melody: ["stepwise", "hook"], master: "dense" },- anger: { id: "anger", modes: ["phrygian", "aeolian", "harmonicMinor"], tempo: [120, 170], meters: ["4/4", "7/8"], harmonicRhythmBars: [1, 2], register: [40, 72], onsetsPerBeat: [3, 8], attackMs: [1, 5], lra: [4, 8], centroidHz: [1200, 5000], families: ["drums", "bass", "brass", "synthLead"], melody: ["ostinato", "hook"], master: "dense" },- eerie: { id: "eerie", modes: ["wholeTone", "locrian", "phrygian", "harmonicMinor"], tempo: [50, 90], meters: ["4/4", "3/4", "5/4"], harmonicRhythmBars: [2, 4], register: [48, 96], onsetsPerBeat: [0.25, 1], attackMs: [50, 400], lra: [10, 18], centroidHz: null, families: ["bowed", "choir", "celesta", "fmBell"], melody: ["drone", "sequence"], master: "gentle" },- mischief: { id: "mischief", modes: ["blues", "dorian", "mixolydian", "wholeTone"], tempo: [100, 150], meters: ["4/4", "2/4", "6/8"], harmonicRhythmBars: [0.5, 1], register: [55, 90], onsetsPerBeat: [1.5, 3], attackMs: [2, 8], lra: [6, 12], centroidHz: [1200, 4000], families: ["woodwind", "pluck", "mallets", "bass"], melody: ["callResponse", "hook"], master: "gentle" },- heroic: { id: "heroic", modes: ["major", "mixolydian", "dorian"], tempo: [90, 130], meters: ["4/4", "3/4"], harmonicRhythmBars: [1, 2], register: [55, 84], onsetsPerBeat: [1, 3], attackMs: [10, 60], lra: [8, 14], centroidHz: null, families: ["brass", "strings", "orchPerc", "choir"], melody: ["hook", "themeTransformation"], master: "gentle" },- sensual: { id: "sensual", modes: ["dorian", "aeolian", "mixolydian"], tempo: [65, 95], meters: ["4/4", "12/8"], harmonicRhythmBars: [1, 2], register: [55, 80], onsetsPerBeat: [0.75, 2], attackMs: [10, 60], lra: [6, 10], centroidHz: [800, 2000], families: ["ePiano", "bass", "woodwind", "drums"], melody: ["stepwise", "counterMelody"], master: "dense" },- grief: { id: "grief", modes: ["aeolian", "harmonicMinor"], tempo: [40, 62], meters: ["3/4", "4/4"], harmonicRhythmBars: [2, 4], register: [48, 76], onsetsPerBeat: [0.5, 1], attackMs: [40, 200], lra: [10, 16], centroidHz: null, families: ["bowed", "piano", "strings", "choir"], melody: ["stepwise", "themeTransformation"], master: "gentle" },romantic: { id: "romantic", modes: ["major", "aeolian"], tempo: [60, 85], meters: ["3/4", "4/4"], harmonicRhythmBars: [1, 1], register: [60, 88], onsetsPerBeat: [1, 2.5], attackMs: [10, 60], lra: [8, 14], centroidHz: [1000, 2000], families: ["piano", "strings"], melody: ["stepwise", "counterMelody"], master: "gentle" },};@@ -42,7 +36,7 @@ export const MOODS: Record<MoodId, Mood> = {export const REFUSED_BLENDS: [MoodId, MoodId][] = [["joy", "dread"], ["playful", "melancholy"], ["calm", "tension"]];export const ARCS: Record<string, MoodId[]> = { rise: ["melancholy", "hopeful", "triumph"], turn: ["joy", "tension", "joy"], fallAndReturn: ["tender", "melancholy", "tender"], wonder: ["curious", "awe"], comic: ["playful", "tension", "playful"] };-export type StyleId = "musicBox" | "nocturne" | "drive" | "cinematic" | "chiptune" | "lofi" | "lofiElectronic" | "folk" | "minimalist" | "jazz" | "lullaby" | "ambient" | "playful" | "orchestral" | "suspense" | "rock" | "hipHop" | "house" | "synthwave" | "world" | "choral";+export type StyleId = "musicBox" | "nocturne" | "drive" | "cinematic" | "chiptune" | "lofi" | "folk" | "minimalist" | "jazz" | "lullaby" | "ambient";export type Style = { id: StyleId; tempo: Range; meters: string[]; families: Family[]; moods: MoodId[]; master: "gentle" | "dense"; arrangement: string; guards: string[]; reverb: "none" | "room" | "hall"; swing?: Range };export const STYLES: Record<StyleId, Style> = {musicBox: { id: "musicBox", tempo: [110, 130], meters: ["12/8"], families: ["musicBox", "fmBell"], moods: ["joy", "curious", "tender", "playful", "wistful"], master: "gentle", reverb: "room", arrangement: "melody -> +bass -> +arp -> +octave sparkle -> bell", guards: ["pluck-only instruments", "more notes, never longer notes"] },@@ -51,16 +45,6 @@ export const STYLES: Record<StyleId, Style> = {cinematic: { id: "cinematic", tempo: [60, 120], meters: ["4/4", "3/4"], families: ["strings", "piano", "harp", "fmBell", "drums"], moods: ["awe", "triumph", "melancholy", "tension", "hopeful"], master: "gentle", reverb: "hall", arrangement: "layered by register slot; crescendos over 4-8 bars", guards: ["max 4 families at once outside climaxes"] },chiptune: { id: "chiptune", tempo: [120, 160], meters: ["4/4"], families: ["chip"], moods: ["joy", "playful", "drive", "tension"], master: "dense", reverb: "none", arrangement: "2 pulses, triangle bass, noise drums; fast arpeggios fake chords", guards: ["<= 4 voices", "no reverb", "PolyBLEP pulses"] },lofi: { id: "lofi", tempo: [70, 90], meters: ["4/4"], families: ["ePiano", "drums", "bass"], moods: ["nostalgic", "calm", "wistful"], master: "dense", reverb: "room", swing: [0.55, 0.62], arrangement: "4 or 8 bar loop with small variations", guards: ["no 2 consecutive identical 8-bar blocks", "master low-pass <= 9 kHz allowed"] },- lofiElectronic: { id: "lofiElectronic", tempo: [80, 100], meters: ["4/4"], families: ["pad", "pluck", "bass", "drums"], moods: ["calm", "joy", "hopeful", "nostalgic"], master: "dense", reverb: "room", swing: [0.52, 0.56], arrangement: "4-bar chord loop; sections add and remove layers (intro, groove, hook, half-time, breakdown, drop, outro); a chosen bar lands on the home chord", guards: ["no ePiano, no vinyl, no bit-crush: clean", "balance by stem RMS vs targets, not LUFS alone"] },- playful: { id: "playful", tempo: [100, 150], meters: ["4/4", "6/8", "2/4"], families: ["mallets", "pluck", "bass", "drums"], moods: ["playful", "joy", "curious", "mischief"], master: "gentle", reverb: "room", swing: [0.5, 0.6], arrangement: "short sections, stop-time, call and response", guards: ["a button ending"] },- orchestral: { id: "orchestral", tempo: [70, 140], meters: ["4/4", "3/4", "6/8"], families: ["strings", "brass", "choir", "orchPerc", "woodwind", "harp"], moods: ["heroic", "triumph", "awe", "tension", "grief"], master: "gentle", reverb: "hall", arrangement: "theme in brass or strings, ostinato engine, build to a tutti climax", guards: ["max 4 families at once outside the climax"] },- suspense: { id: "suspense", tempo: [50, 110], meters: ["4/4", "5/4", "3/4"], families: ["bowed", "strings", "choir", "orchPerc", "bass"], moods: ["tension", "dread", "eerie"], master: "gentle", reverb: "hall", arrangement: "drone + pulse, stingers on picture hits, withheld resolution", guards: ["ghost guard: a pulse or a motif at least every 4 bars"] },- rock: { id: "rock", tempo: [90, 160], meters: ["4/4", "6/8"], families: ["guitar", "bass", "drums", "organ"], moods: ["drive", "anger", "triumph", "joy"], master: "dense", reverb: "room", arrangement: "riff intro, verse, chorus, bridge, chorus; tight kit", guards: ["the riff returns"] },- hipHop: { id: "hipHop", tempo: [70, 100], meters: ["4/4"], families: ["drums", "bass", "piano", "strings", "pluck"], moods: ["drive", "calm", "nostalgic", "sensual", "anger"], master: "dense", reverb: "room", swing: [0.52, 0.6], arrangement: "4 or 8 bar loop, drops and switch-ups every 8 bars", guards: ["808 carries content above 500 Hz"] },- house: { id: "house", tempo: [118, 128], meters: ["4/4"], families: ["drums", "bass", "pad", "pluck", "organ"], moods: ["joy", "drive", "sensual", "hopeful"], master: "dense", reverb: "room", arrangement: "16-bar blocks, filter builds, breakdown, drop", guards: ["kick on every beat in the groove sections"] },- synthwave: { id: "synthwave", tempo: [80, 118], meters: ["4/4"], families: ["synthLead", "pad", "bass", "drums"], moods: ["nostalgic", "drive", "heroic", "romantic"], master: "dense", reverb: "hall", arrangement: "intro pad, arpeggiated bass, big gated snare, lead hook", guards: ["one lead at a time"] },- world: { id: "world", tempo: [60, 140], meters: ["7/8", "9/8", "12/8", "6/8", "4/4", "5/4"], families: ["pluck", "woodwind", "drums", "mallets"], moods: ["calm", "joy", "curious", "mischief", "awe"], master: "gentle", reverb: "room", arrangement: "drone + modal melody + hand percussion cycle; odd meters welcome", guards: ["name the tradition you draw on, write your own melody"] },- choral: { id: "choral", tempo: [50, 90], meters: ["4/4", "3/4"], families: ["choir", "organ", "strings", "fmBell"], moods: ["awe", "grief", "hopeful", "tender", "heroic"], master: "gentle", reverb: "hall", arrangement: "voices in 4 parts, chorale phrases with cadences, a swell to the last chord", guards: ["choir is harmony and texture; the line on top must still move"] },folk: { id: "folk", tempo: [80, 120], meters: ["6/8", "3/4", "4/4"], families: ["guitar", "harp", "fmBell"], moods: ["calm", "wistful", "joy", "nostalgic"], master: "gentle", reverb: "room", arrangement: "fingerpicked pattern + lead", guards: ["strum spread 10-30 ms low to high"] },minimalist: { id: "minimalist", tempo: [100, 140], meters: ["4/4", "12/8"], families: ["mallets", "piano"], moods: ["curious", "tension", "awe"], master: "gentle", reverb: "room", arrangement: "interlocking ostinatos; one change every 8-16 bars", guards: ["a change at least every 16 bars"] },jazz: { id: "jazz", tempo: [90, 180], meters: ["4/4"], families: ["piano", "bass", "drums"], moods: ["playful", "nostalgic", "romantic", "curious"], master: "gentle", reverb: "room", swing: [0.6, 0.67], arrangement: "walking bass on quarters, comping off the beat", guards: ["7th chords required"] },diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/theory.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/theory.tsindex 801378e..24823bf 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/theory.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/theory.ts@@ -7,7 +7,7 @@ export type Mode = { id: ModeId; intervals: number[]; color: string; use: string// Intervals are semitones above the tonic. `color` is the degree that makes the mode read as itself.export const MODES: Record<ModeId, Mode> = {- major: { id: "major", intervals: [0, 2, 4, 5, 7, 9, 11], color: "3, 7", use: "joy, arrival, sunlight", guard: "section 7 only" },+ major: { id: "major", intervals: [0, 2, 4, 5, 7, 9, 11], color: "3, 7", use: "joy, arrival, sunlight; the music-box default", guard: "section 7 only" },aeolian: { id: "aeolian", intervals: [0, 2, 3, 5, 7, 8, 10], color: "b3, b6", use: "sadness, longing, gravity, night", guard: "tonic clarity" },harmonicMinor: { id: "harmonicMinor", intervals: [0, 2, 3, 5, 7, 8, 11], color: "raised 7 over V", use: "drama, fate, cadences inside minor", guard: "augmented step b6-7 only as a passing figure, max 2 per phrase" },melodicMinor: { id: "melodicMinor", intervals: [0, 2, 3, 5, 7, 9, 11], color: "raised 6 and 7", use: "hopeful minor, yearning lines that climb", guard: "rising lines only; falling lines revert to aeolian" },diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocab.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocab.tsdeleted file mode 100644index 21563ab..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocab.ts+++ /dev/null@@ -1,247 +0,0 @@-// STYLE VOCABULARIES. A style is a vocabulary, never notes: the sound palette (a voice per slot,-// with levels and stem targets), the groove families that fit it, its harmony language, its melody-// rules, its arrangement grammar, and how five MOOD controls turn into real parameters. The composer-// (the model) writes every note: harmony, bass lines, motifs, form (compose.ts, references/music/compose.md).-// Nothing here is a melody, a progression or a riff, and nothing here should ever become one.-import type { InstId, Role, PieceFx, Meter } from "./plan";-import type { ModeId } from "./theory";-import type { MoodId, StyleId } from "./tables";-import type { GrooveFamily } from "./grooves";-import { VOCAB_MORE } from "./vocabMore";--/** Voice slots. Line slots (the composer writes them): chords, bass, lead, counter, arp. Drum slots are filled by a groove. */-export type Slot = "chords" | "lead" | "counter" | "bass" | "kick" | "snare" | "ghost" | "hat" | "arp" | "perc";-export const BASE_SLOTS: Slot[] = ["chords", "lead", "counter", "bass", "kick", "snare", "ghost", "hat"];-export const EXTRA_SLOTS: Slot[] = ["arp", "perc"];-/** opts values "beats:x" are resolved to x beats in seconds at the piece's tempo (delay times). */-export type Voice = { inst: InstId; role: Role; gainDb: number; opts?: Record<string, number | boolean | string>; send?: number; pan?: number };-/** Five mood controls, each 0..1, 0.5 = the calibrated palette unchanged. */-export type MoodControls = { energy?: number; warmth?: number; brightness?: number; tension?: number; space?: number };--export type SectionKind = "intro" | "verse" | "groove" | "hook" | "build" | "half" | "breakdown" | "drop" | "bridge" | "swell" | "breath" | "outro";-/** Arrangement grammar: which layers a section kind lets sound, and the groove it asks for by default. Lines sound only where written. */-export const KINDS: Record<SectionKind, { drums: "main" | "half" | "build" | null; bass: boolean; what: string }> = {- intro: { drums: null, bass: false, what: "chords (and any line you write) without drums or bass: set the colour, state the key" },- verse: { drums: "main", bass: true, what: "the groove under a lighter line: room for picture and words" },- groove: { drums: "main", bass: true, what: "chords, bass, drums: the bed, no lead unless you write one" },- hook: { drums: "main", bass: true, what: "full groove under the motif: the memorable part" },- build: { drums: "build", bass: true, what: "rising density (snare 8ths to 16ths), rising line, lands on the next downbeat" },- half: { drums: "half", bass: true, what: "half-time drums: the same tempo feels slower (a scene change, a breath with pulse)" },- breakdown: { drums: null, bass: false, what: "drums and bass out, chords and a thin line: the held breath before a landing" },- drop: { drums: "main", bass: true, what: "everything back on a strong chord: the landing, put it on the picture's key beat" },- bridge: { drums: "main", bass: true, what: "new harmony away from home (a borrowed or relative area) before the return" },- swell: { drums: null, bass: true, what: "long notes crescendo over 2-8 bars (orchestral swell), peaks on the downbeat after" },- breath: { drums: null, bass: false, what: "near silence: one held chord or nothing, authored (max 2 bars)" },- outro: { drums: null, bass: true, what: "home chord held, the motif's last word, then the tail" },-};--export type StyleVocab = {- id: StyleId; name: string; atmosphere: string; tempo: [number, number]; meters: Meter[]; swing: [number, number];- palette: Partial<Record<Slot, Voice>>; alternates: Partial<Record<Slot, Record<string, Voice>>>;- fx: PieceFx; stemTargets: Record<string, number>; calibrated: boolean;- grooves: GrooveFamily[]; moods: MoodId[];- harmony: { modes: ModeId[]; qualities: string; tendencies: string; rhythm: string; voicing: string; tension: string };- melody: { range: string; contour: string; density: string; motif: string };- arrangement: { shape: string; transitions: string; endings: string };- avoid: string;-};--const bassDelay = (x: number) => `beats:${x}`;-export const VOCAB: Partial<Record<StyleId, StyleVocab>> = {- lofiElectronic: {- id: "lofiElectronic", name: "lo-fi electronic", atmosphere: "warm, chill but upbeat, clean: a breathing pad, a plucked hook through ping-pong echoes, a round sub, a bouncy kit",- tempo: [80, 100], meters: ["4/4"], swing: [0.52, 0.56],- palette: {- chords: { inst: "warmPad", role: "accomp", gainDb: -3, opts: { cut: 2600, attack: 0.5, release: 1.4, spread: 0.55 }, send: 0.35 },- lead: { inst: "softPluck", role: "melody", gainDb: 6, opts: { decay: 0.42, bright: 6000, delay: bassDelay(0.75), feedback: 0.28, delayMix: 0.24 }, send: 0.25 },- counter: { inst: "softPluck", role: "color", gainDb: 8, opts: { decay: 0.35, bright: 5200, pan: 0.35, delay: bassDelay(0.75), feedback: 0.3, delayMix: 0.35 }, send: 0.6 },- bass: { inst: "sub", role: "bass", gainDb: -6, opts: { cut: 150 } },- kick: { inst: "kick", role: "drum", gainDb: 0.5, send: 0.1 },- snare: { inst: "snare", role: "drum", gainDb: 8, send: 0.3 },- ghost: { inst: "snare", role: "drum", gainDb: 4, opts: { rim: true }, send: 0.2 },- hat: { inst: "hat", role: "drum", gainDb: 20, opts: { pan: 0.25 }, send: 0.1 },- arp: { inst: "softPluck", role: "accomp", gainDb: 4, opts: { decay: 0.22, bright: 3800, pan: -0.3, delay: bassDelay(0.5), feedback: 0.2, delayMix: 0.2 }, send: 0.3 },- perc: { inst: "hat", role: "drum", gainDb: 14, opts: { pan: -0.3 }, send: 0.2 },- },- alternates: {- lead: { bell: { inst: "fmBell", role: "melody", gainDb: 0, opts: { ratio: 3.5 }, send: 0.3 }, mallet: { inst: "marimba", role: "melody", gainDb: 2, send: 0.25 }, guitar: { inst: "guitar", role: "melody", gainDb: 2, send: 0.25 } },- chords: { strings: { inst: "strings", role: "accomp", gainDb: -6, opts: { attack: 0.35, release: 1.0, bright: 0.8 }, send: 0.35 }, piano: { inst: "piano", role: "accomp", gainDb: -4, send: 0.3 } },- bass: { warm: { inst: "bass", role: "bass", gainDb: -2, opts: { drive: 1.4 } } },- },- fx: { clean: true, duck: { by: "kick", parts: ["chords", "counter"], depth: 0.38, release: 0.24 }, tape: { wowCents: 2.5, wowHz: 0.4, flutterCents: 0, flutterHz: 6, drive: 1.02 } },- stemTargets: { kick: -14, snare: -20, hat: -28, bass: -18, chords: -21, lead: -16.5, counter: -24 }, calibrated: true,- grooves: ["bounce", "halfTime", "broken", "skip", "pulse", "build"], moods: ["calm", "joy", "hopeful", "nostalgic", "wistful", "curious"],- harmony: { modes: ["major", "dorian", "lydian", "aeolian", "mixolydian"], qualities: "7ths, 9ths, 11ths and 13ths; add9; sus2/sus4 for air; avoid bare triads except on the landing",- tendencies: "loops of 2, 4 or 8 bars; ii-V motion, IV-iii-vi drifts, modal vamps (i-IV in dorian, I-II in lydian), borrowed iv or bVII for a wistful turn; the home chord arrives on a structural beat",- rhythm: "one chord per bar or two per bar; the change can anticipate the bar by an eighth", voicing: "rootless 3-4 note voicings between E3 and E4 moving by step (common tones held); the bass owns the root",- tension: "sus4 and 13ths lean, maj7#11 floats, a dominant 7b9 or a borrowed iv aches; release by resolving the lean voice down a step" },- melody: { range: "C4-A5 for the lead, the octave above for counter lines", contour: "short arches; the high point in the second half of a phrase; answer phrases end lower", density: "1-3 notes per beat; leave rests so the echo answers",- motif: "a 2-5 note cell with its own rhythm; repeat it, then vary it (shift it up a step, invert the last interval, displace it by an eighth); call and response between lead and counter" },- arrangement: { shape: "intro -> groove -> hook -> (half-time or breakdown) -> drop on home -> outro; add or remove one layer at a time", transitions: "a fill bar, a half-time bar, drums out for a breakdown, then everything back on a downbeat", endings: "home chord held with the motif's last note, or a clean button on 1" },- avoid: "synth ePiano, vinyl crackle, bit-crush, a dark master low-pass: that is dusty lo-fi hip-hop, not clean electronic",- },- drive: {- id: "drive", name: "driving electronic", atmosphere: "forward, bright, confident: four-on-the-floor, a pumping supersaw bed, a gritty bass line, a plucked arp",- tempo: [110, 140], meters: ["4/4"], swing: [0.5, 0.52],- palette: {- chords: { inst: "strings", role: "accomp", gainDb: -8, opts: { attack: 0.25, release: 0.5, bright: 1.3, width: 0.95, grid: true }, send: 0.3 },- lead: { inst: "strings", role: "melody", gainDb: -2, opts: { attack: 0.012, release: 0.15, bright: 1.8, width: 0.4, grid: true }, send: 0.25 },- counter: { inst: "fmBell", role: "color", gainDb: -6, opts: { ratio: 3.5 }, send: 0.4 },- bass: { inst: "bass", role: "bass", gainDb: -3, opts: { drive: 2.4, grid: true } },- kick: { inst: "kick", role: "drum", gainDb: 2, opts: { soft: 0.3, grid: true }, send: 0 },- snare: { inst: "snare", role: "drum", gainDb: 2, opts: { grid: true }, send: 0.4 },- ghost: { inst: "snare", role: "drum", gainDb: -2, opts: { rim: true, grid: true }, send: 0.2 },- hat: { inst: "hat", role: "drum", gainDb: 12, opts: { pan: 0.2, grid: true }, send: 0.1 },- arp: { inst: "softPluck", role: "accomp", gainDb: 3, opts: { decay: 0.2, bright: 5000, delay: bassDelay(0.75), feedback: 0.3, delayMix: 0.25, grid: true }, send: 0.25 },- perc: { inst: "hat", role: "drum", gainDb: 10, opts: { pan: -0.2, grid: true }, send: 0.15 },- },- alternates: { lead: { pluck: { inst: "softPluck", role: "melody", gainDb: 5, opts: { decay: 0.3, bright: 7000, delay: bassDelay(0.75), feedback: 0.3, delayMix: 0.25 }, send: 0.25 } }, bass: { sub: { inst: "sub", role: "bass", gainDb: -5, opts: { cut: 160 } } } },- fx: { clean: true, duck: { by: "kick", parts: ["chords", "arp", "counter"], depth: 0.55, release: 0.2 } },- stemTargets: { kick: -12, snare: -18, hat: -26, perc: -27, bass: -16, chords: -22, lead: -16, arp: -21, counter: -24 }, calibrated: false,- grooves: ["fourFloor", "broken", "build", "halfTime", "tension"], moods: ["drive", "triumph", "tension", "joy", "awe"],- harmony: { modes: ["aeolian", "dorian", "mixolydian", "major"], qualities: "triads and power voicings, sus2, add9; minor with a major IV (dorian) for lift", tendencies: "i-VI-III-VII, i-v-VI-IV, bVI-bVII-i climbs; long pedal tones under changing chords; a key lift of a step for the last chorus",- rhythm: "one chord per bar or per two bars; stabs on off-beats", voicing: "wide: root-fifth-octave low, tight triads above C4; the bass line is 8ths or offbeat", tension: "a pedal under a moving chord, a build that withholds the kick, a riser into a drop; release on the downbeat with everything" },- melody: { range: "A3-E6", contour: "repeated cells climbing by step; big leaps at the drop", density: "8ths and 16ths; arps in 3-note cells across 4/4 (hemiola)", motif: "a rhythmic riff of 3-6 notes, repeated with the last note changed; sequence it up the scale in the build" },- arrangement: { shape: "intro (filtered) -> build -> drop -> breakdown -> build -> bigger drop -> outro", transitions: "builds of 4-8 bars, a one-beat breath before the drop", endings: "a button on 1 or a filtered fade of the groove" },- avoid: "swing, soft attacks on the lead, more than 4 layers in the breakdown",- },- cinematic: {- id: "cinematic", name: "cinematic / orchestral", atmosphere: "wide and emotional: string swells, low ostinatos for tension, harp and bell colour, a low boom on the arrival",- tempo: [60, 120], meters: ["4/4", "3/4", "6/8"], swing: [0.5, 0.5],- palette: {- chords: { inst: "strings", role: "accomp", gainDb: -4, opts: { attack: 1.1, release: 1.6, bright: 0.9 }, send: 0.5 },- lead: { inst: "strings", role: "melody", gainDb: 0, opts: { attack: 0.18, release: 0.9, bright: 1.1, width: 0.4 }, send: 0.45 },- counter: { inst: "harp", role: "color", gainDb: 0, send: 0.5 },- bass: { inst: "strings", role: "bass", gainDb: -3, opts: { attack: 0.6, release: 1.4, bass: true, bright: 0.6 }, send: 0.35 },- arp: { inst: "strings", role: "accomp", gainDb: -4, opts: { attack: 0.01, release: 0.12, bright: 1.2, width: 0.6 }, send: 0.3 },- kick: { inst: "kick", role: "drum", gainDb: 2, opts: { soft: 1 }, send: 0.6 },- snare: { inst: "snare", role: "drum", gainDb: -2, send: 0.6 },- ghost: { inst: "snare", role: "drum", gainDb: -4, opts: { rim: true }, send: 0.5 },- hat: { inst: "hat", role: "drum", gainDb: 6, send: 0.4 },- perc: { inst: "fmBell", role: "color", gainDb: -8, opts: { ratio: 2.4 }, send: 0.6 },- },- alternates: { lead: { piano: { inst: "piano", role: "melody", gainDb: 0, send: 0.4 }, bell: { inst: "fmBell", role: "melody", gainDb: -4, send: 0.5 }, celesta: { inst: "celesta", role: "melody", gainDb: 0, send: 0.5 } }, counter: { piano: { inst: "piano", role: "color", gainDb: -3, send: 0.4 } } },- fx: {},- stemTargets: { chords: -18, bass: -19, lead: -17, counter: -22, arp: -21, kick: -16, snare: -24, hat: -32 }, calibrated: false,- grooves: ["pulse", "tension", "build", "halfTime"], moods: ["awe", "triumph", "tension", "melancholy", "hopeful", "dread"],- harmony: { modes: ["aeolian", "harmonicMinor", "lydian", "major", "phrygian", "dorian"], qualities: "open fifths, add9, sus2/sus4, minor with a major IV; chromatic mediants (C to E, C to Ab) for awe",- tendencies: "slow harmonic rhythm (1-2 bars per chord); i-bVI-bVII-i for epic, i-iv-V for drama, lydian II for wonder, a pedal bass under moving chords for tension; big arrivals on chromatic mediants",- rhythm: "one chord per 1-2 bars; tension sections hold one chord over an ostinato", voicing: "spread wide: bass octaves below C3, open fifths, the melody doubled an octave on the climax (stagger the bass to keep peaks musical)",- tension: "minor seconds against a pedal, a b6 leaning to 5, suspended 4ths held long, harmonic minor's raised 7th; release to a major chord or a picardy third" },- melody: { range: "G3-C6 (strings), harp and bell above", contour: "long arcs over 4-8 bars, a big leap (6th, octave) then stepwise fall", density: "0.5-2 notes per beat; tension ostinatos 2-4 per beat", motif: "a 3-4 note idea that returns transformed: augmented (slower) at the climax, in the bass for menace, in the harp for tenderness" },- arrangement: { shape: "intro (a colour, a drone) -> theme -> swell/build -> climax on the key picture beat -> release -> quiet coda", transitions: "crescendo over 4-8 bars; a breath of silence before the arrival; a low boom on the downbeat", endings: "a held chord ringing into the tail, or a hard-out on the cut" },- avoid: "more than four families at once outside the climax; fast drums under a tender theme",- },- ambient: {- id: "ambient", name: "airy ambient", atmosphere: "floating, spacious, luminous: long pads, bells and plucks with space around them, a soft heartbeat at most",- tempo: [50, 80], meters: ["4/4", "3/4"], swing: [0.5, 0.5],- palette: {- chords: { inst: "warmPad", role: "accomp", gainDb: -1, opts: { cut: 3400, attack: 1.6, release: 3.0, spread: 1.0, width: 1 }, send: 0.7 },- lead: { inst: "fmBell", role: "melody", gainDb: 0, opts: { ratio: 3.5, width: 0.6 }, send: 0.7 },- counter: { inst: "softPluck", role: "color", gainDb: 6, opts: { decay: 0.6, bright: 4200, pan: -0.35, delay: bassDelay(1.5), feedback: 0.4, delayMix: 0.4 }, send: 0.8 },- bass: { inst: "sub", role: "bass", gainDb: -8, opts: { cut: 120 } },- arp: { inst: "celesta", role: "accomp", gainDb: -4, send: 0.7 },- kick: { inst: "kick", role: "drum", gainDb: -4, opts: { soft: 1 }, send: 0.3 },- ghost: { inst: "snare", role: "drum", gainDb: -6, opts: { rim: true }, send: 0.6 },- hat: { inst: "hat", role: "drum", gainDb: 6, send: 0.5 },- perc: { inst: "hat", role: "drum", gainDb: 4, opts: { pan: -0.4 }, send: 0.6 },- },- alternates: { lead: { pluck: { inst: "softPluck", role: "melody", gainDb: 5, opts: { decay: 0.8, bright: 3800, delay: bassDelay(1.5), feedback: 0.4, delayMix: 0.4 }, send: 0.7 }, vibes: { inst: "vibes", role: "melody", gainDb: 0, send: 0.6 } } },- fx: { clean: true, tape: { wowCents: 4, wowHz: 0.25, flutterCents: 0, flutterHz: 6, drive: 1.0 } },- stemTargets: { chords: -19, bass: -22, lead: -20, counter: -25, arp: -24, kick: -20, hat: -32 }, calibrated: false,- grooves: ["pulse", "brushes"], moods: ["awe", "calm", "hopeful", "tender", "dread"],- harmony: { modes: ["lydian", "major", "dorian", "majorPentatonic", "aeolian"], qualities: "maj7, add9, maj7#11, sus2, quartal stacks (4ths)", tendencies: "two-chord oscillations (I-II lydian, i-IV dorian), planing (the same shape moved by step), a pedal note held through changes",- rhythm: "slow: one chord per 2-4 bars", voicing: "wide and open, high register, no thirds low; let voices ring", tension: "a #11 or a 9 against the root; release by the melody settling on the fifth or the root" },- melody: { range: "C5-C7 bells, pluck echoes above", contour: "sparse, falling phrases of 2-5 notes; rests as long as the notes", density: "0.25-1 note per beat, but a motif at least every 8 bars (the ghost guard)", motif: "a 3-note bell figure that returns, echoed by the pluck at a new register" },- arrangement: { shape: "slow evolution: add one layer every 4-8 bars, take one away before the end", transitions: "crossfades; a pad change on a bar line", endings: "the motif once more, alone, into the tail" },- avoid: "formlessness: sustained pads with no onsets and no cadence (the ghost failure); run the guards",- },- folk: {- id: "folk", name: "tender acoustic", atmosphere: "intimate and warm: fingerpicked guitar, soft piano, a harp or celesta line, brushes",- tempo: [60, 110], meters: ["6/8", "3/4", "4/4"], swing: [0.5, 0.54],- palette: {- chords: { inst: "piano", role: "accomp", gainDb: -5, send: 0.35 },- arp: { inst: "guitar", role: "accomp", gainDb: -4, send: 0.3 },- lead: { inst: "harp", role: "melody", gainDb: 2, send: 0.35 },- counter: { inst: "celesta", role: "color", gainDb: -3, send: 0.4 },- bass: { inst: "bass", role: "bass", gainDb: -6, opts: { drive: 1.1 } },- kick: { inst: "kick", role: "drum", gainDb: -4, opts: { soft: 1 }, send: 0.2 },- snare: { inst: "snare", role: "drum", gainDb: -6, opts: { rim: true }, send: 0.4 },- ghost: { inst: "snare", role: "drum", gainDb: -6, opts: { rim: true }, send: 0.4 },- hat: { inst: "hat", role: "drum", gainDb: 2, send: 0.3 },- perc: { inst: "hat", role: "drum", gainDb: 2, opts: { pan: -0.3 }, send: 0.3 },- },- alternates: { lead: { piano: { inst: "piano", role: "melody", gainDb: 0, send: 0.3 }, guitar: { inst: "guitar", role: "melody", gainDb: 2, send: 0.3 }, strings: { inst: "strings", role: "melody", gainDb: -2, opts: { attack: 0.2, release: 0.8 }, send: 0.4 } }, chords: { strings: { inst: "strings", role: "accomp", gainDb: -8, opts: { attack: 0.8, release: 1.2, bright: 0.7 }, send: 0.4 } } },- fx: {},- stemTargets: { chords: -20, arp: -21, lead: -16, counter: -24, bass: -21, kick: -20, snare: -26, ghost: -28, hat: -30, perc: -30 }, calibrated: false,- grooves: ["brushes", "pulse", "shuffle"], moods: ["tender", "calm", "wistful", "nostalgic", "hopeful", "romantic"],- harmony: { modes: ["major", "mixolydian", "dorian", "majorPentatonic", "aeolian"], qualities: "triads, add9, sus2, slash chords with a walking bass (I - V/7 - vi)", tendencies: "I-V/7-vi-IV descents, bVII-IV-I (mixolydian), plagal IV-I endings, a relative minor detour",- rhythm: "one chord per bar in 6/8 or 3/4; two per bar in 4/4", voicing: "guitar-shaped: root-fifth-tenth, open strings ringing; piano in the middle, melody on top", tension: "a suspended 4th resolving, a IV minor (iv) borrowed for the ache; release plagal (IV-I)" },- melody: { range: "D4-G5, singable (a 10th at most)", contour: "stepwise with one leap per phrase, rising question, falling answer", density: "1-2 notes per beat, a held note at each phrase end", motif: "a singable 4-bar phrase; the answer repeats its start and changes its end" },- arrangement: { shape: "guitar alone -> + melody -> + piano and bass -> + counter line -> thin to guitar and melody for the end", transitions: "a pickup note into each phrase; a bar of guitar alone between verses", endings: "plagal cadence, a rolled final chord" },- avoid: "four-on-the-floor, heavy drums, synth pads, fast arpeggios that bury the melody",- },- playful: {- id: "playful", name: "playful / bouncy", atmosphere: "light, cheeky, springy: marimba and pizzicato-like plucks, a bouncy bass, a skipping kit",- tempo: [100, 150], meters: ["4/4", "6/8"], swing: [0.5, 0.6],- palette: {- lead: { inst: "marimba", role: "melody", gainDb: 2, send: 0.25 },- chords: { inst: "vibes", role: "accomp", gainDb: -6, opts: { trem: 4.5 }, send: 0.3 },- arp: { inst: "harp", role: "accomp", gainDb: -4, send: 0.25 },- counter: { inst: "celesta", role: "color", gainDb: -2, send: 0.35 },- bass: { inst: "bass", role: "bass", gainDb: -3, opts: { drive: 1.8 } },- kick: { inst: "kick", role: "drum", gainDb: 0, opts: { soft: 0.6 }, send: 0.1 },- snare: { inst: "snare", role: "drum", gainDb: 3, send: 0.25 },- ghost: { inst: "snare", role: "drum", gainDb: 0, opts: { rim: true }, send: 0.2 },- hat: { inst: "hat", role: "drum", gainDb: 12, send: 0.1 },- perc: { inst: "hat", role: "drum", gainDb: 10, opts: { pan: -0.35 }, send: 0.15 },- },- alternates: { lead: { chip: { inst: "pulse", role: "melody", gainDb: -4, opts: { duty: 0.25 } }, pluck: { inst: "softPluck", role: "melody", gainDb: 5, opts: { decay: 0.2, bright: 6000 } }, bell: { inst: "fmBell", role: "melody", gainDb: -2 } }, bass: { tuba: { inst: "sub", role: "bass", gainDb: -4, opts: { cut: 220 } } } },- fx: { clean: true },- stemTargets: { lead: -16, chords: -22, arp: -21, counter: -23, bass: -18, kick: -15, snare: -21, ghost: -26, hat: -28, perc: -29 }, calibrated: false,- grooves: ["skip", "shuffle", "bounce", "fourFloor"], moods: ["playful", "joy", "curious"],- harmony: { modes: ["major", "mixolydian", "majorPentatonic", "lydian", "blues"], qualities: "triads and 6ths, dominant 7ths, chromatic passing chords (a diminished between I and ii)", tendencies: "fast harmonic rhythm (2 chords a bar), I-vi-ii-V turnarounds, secondary dominants (V/V), a surprise bVI",- rhythm: "two chords per bar, on-beat stabs", voicing: "close, mid-high; the bass bounces root-fifth (oom-pah) or walks", tension: "a chromatic approach note, a held dominant with a pause; release with a cheeky button" },- melody: { range: "C4-C7 (mallets love the top)", contour: "leaps and staccato repeated notes; zig-zags; grace-note slides", density: "2-4 notes per beat, with sudden rests (comic timing)", motif: "a 3-note staccato cell with a leap; answer it lower, then sequence it" },- arrangement: { shape: "short sections (4-8 bars), stop-time breaks, call and response between lead and counter", transitions: "a stop (all out for a beat), a drum fill, a key lift", endings: "a button: a short tutti hit on 1, sometimes after a comic pause" },- avoid: "long pads, slow tempo, minor-key sustained melodies",- },-};--/** Resolve a voice: "beats:x" opts to seconds at this tempo. */-export const resolveVoice = (v: Voice, bpm: number): Voice => {- if (!v.opts) return v;- const o: Record<string, number | boolean | string> = {};- for (const [k, x] of Object.entries(v.opts)) o[k] = typeof x === "string" && x.startsWith("beats:") ? (60 / bpm) * Number(x.slice(6)) : x;- return { ...v, opts: o };-};--/**- * The mood controls as real parameters. 0.5 on every control = the palette as calibrated (exactly).- * energy groove density, drum level, duck depth, section dynamics- * warmth filters darker, tape drive and wow up, bass up a little- * brightness filters and pluck brightness open, hats up- * tension pad detune wider, strings attack shorter, lead decay shorter (the harmony is yours to tense)- * space reverb sends, delay mix and pad release longer- */-export const moodVoice = (slot: Slot, v: Voice, m: Required<MoodControls>): { voice: Voice; dGain: number } => {- const o = { ...(v.opts ?? {}) }, e = m.energy - 0.5, w = m.warmth - 0.5, b = m.brightness - 0.5, t = m.tension - 0.5, s = m.space - 0.5;- const tone = Math.pow(2, b * 1.2 - w * 0.8);- const mul = (k: string, f: number) => { if (typeof o[k] === "number") o[k] = (o[k] as number) * f; };- mul("cut", tone); mul("bright", tone); mul("spread", 1 + t * 1.2); mul("release", 1 + s * 0.8); mul("delayMix", 1 + s * 0.8);- if (v.inst === "strings") mul("attack", 1 - t * 0.8);- if (slot === "lead" || slot === "counter") mul("decay", 1 - t * 0.5);- let dGain = 0;- if (["kick", "snare", "ghost", "hat", "perc"].includes(slot)) dGain += e * 4;- if (slot === "hat" || slot === "perc") dGain += b * 4;- if (slot === "bass") dGain += w * 2;- const send = v.send === undefined ? undefined : Math.min(1.2, v.send * Math.pow(2, s * 2));- return { voice: { ...v, opts: o, send, gainDb: v.gainDb + dGain }, dGain };-};-export const moodFx = (fx: PieceFx, m: Required<MoodControls>): PieceFx => {- const e = m.energy - 0.5, w = m.warmth - 0.5, t = m.tension - 0.5;- return { ...fx, duck: fx.duck && { ...fx.duck, depth: Math.min(0.8, (fx.duck.depth ?? 0.4) * (1 + e * 0.6)) }, tape: fx.tape ? { ...fx.tape, drive: (fx.tape.drive ?? 1.25) + w * 0.3, wowCents: (fx.tape.wowCents ?? 7) * (1 + w + t * 0.5) } : undefined };-};-export const fullMood = (m: MoodControls): Required<MoodControls> => ({ energy: m.energy ?? 0.5, warmth: m.warmth ?? 0.5, brightness: m.brightness ?? 0.5, tension: m.tension ?? 0.5, space: m.space ?? 0.5 });--for (const v of VOCAB_MORE) VOCAB[v.id] = v;diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocabMore.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocabMore.tsdeleted file mode 100644index 0fd49af..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocabMore.ts+++ /dev/null@@ -1,121 +0,0 @@-// The rest of the style vocabularies (vocab.ts has the type, the mood mapping and the first six).-// Same rule: sound, grooves, harmony language, melody rules, arrangement grammar. Never notes.-import type { StyleVocab, Voice, Slot } from "./vocab";--const V = (inst: Voice["inst"], role: Voice["role"], gainDb: number, opts?: Voice["opts"], send?: number): Voice => ({ inst, role, gainDb, ...(opts ? { opts } : {}), ...(send !== undefined ? { send } : {}) });-/** a drum kit at a level offset: soft (acoustic), tight (band), hard (electronic) */-const kit = (o: number, soft: number, extra: Partial<Record<Slot, Voice>> = {}): Partial<Record<Slot, Voice>> => ({- kick: V("kick", "drum", 0 + o, { soft }, 0.15), snare: V("snare", "drum", 3 + o, undefined, 0.3), ghost: V("snare", "drum", 0 + o, { rim: true }, 0.25),- hat: V("hat", "drum", 12 + o, { pan: 0.25 }, 0.1), perc: V("hat", "drum", 10 + o, { pan: -0.3 }, 0.15), ...extra,-});-const T = (x: Partial<Record<string, number>>) => x as Record<string, number>;-const std = T({ kick: -14, snare: -20, ghost: -26, hat: -28, perc: -29, bass: -18, chords: -21, lead: -16.5, counter: -23, arp: -22 });--export const VOCAB_MORE: StyleVocab[] = [- { id: "musicBox", name: "music box", atmosphere: "small, bright, clockwork, innocent; plucked and never sustained", tempo: [100, 132], meters: ["12/8", "3/4", "6/8"], swing: [0.5, 0.5],- palette: { lead: V("musicBox", "melody", 0, { grid: true }), arp: V("musicBox", "accomp", -9, { grid: true }), bass: V("musicBox", "bass", -8, { grid: true }), counter: V("bell", "color", -4), chords: V("celesta", "accomp", -10) },- alternates: { lead: { celesta: V("celesta", "melody", 0), bell: V("fmBell", "melody", -4) } }, fx: {},- stemTargets: T({ lead: -16, arp: -26, bass: -24, counter: -22, chords: -27 }), calibrated: false, grooves: [], moods: ["joy", "curious", "tender", "playful", "wistful", "eerie"],- harmony: { modes: ["major", "lydian", "dorian", "aeolian", "majorPentatonic"], qualities: "triads and sus2; a minor music box is a real (and uncanny) sound", tendencies: "any functional progression you write; plagal and deceptive turns read well; a whole-step lift for the payoff", rhythm: "one chord per bar", voicing: "melody C5-C7, bass C3-G3, arpeggio figures in between (you choose the figure)", tension: "an unresolved 4th or a borrowed iv; release on a clean tonic" },- melody: { range: "C5-C7", contour: "hooky, skipping", density: "more notes, never longer notes (no sustain)", motif: "a 3-5 note hook with a distinctive rhythm; restate it, answer it" },- arrangement: { shape: "melody -> +bass -> +arpeggio -> +octave sparkle -> bell on the final downbeat", transitions: "add a layer each phrase", endings: "a bell or a single plucked tonic" },- avoid: "sustained pads, long reverb tails, slow attacks (the ghost failure); see styles/music-box.md for the old recipe's numbers" },- { id: "nocturne", name: "nocturne / solo piano", atmosphere: "intimate, expressive, late-night: one piano, rubato, pedal", tempo: [50, 76], meters: ["3/4", "6/8", "4/4"], swing: [0.5, 0.5],- palette: { lead: V("piano", "melody", 0), chords: V("piano", "accomp", 0), bass: V("piano", "bass", 0), counter: V("strings", "color", -10, { attack: 0.9, release: 1.4 }) },- alternates: {}, fx: {}, stemTargets: T({ lead: -17, chords: -24, bass: -23, counter: -30 }), calibrated: false, grooves: [], moods: ["tender", "melancholy", "wistful", "romantic", "grief"],- harmony: { modes: ["major", "aeolian", "harmonicMinor", "dorian"], qualities: "triads, 7ths, secondary dominants, borrowed iv, Neapolitan for grief", tendencies: "descending bass lines, circle-of-fifths sequences, deceptive V-vi before the last cadence", rhythm: "one chord per bar, two at cadences", voicing: "left hand broken chords spanning a 10th, no close thirds below C3", tension: "suspensions (4-3, 9-8), appoggiaturas on strong beats" },- melody: { range: "C4-C6", contour: "arch per phrase, peak about 2/3 through", density: "0.5-2 notes per beat", motif: "a leap then stepwise return; transform it (octave up, in the bass) at the climax" },- arrangement: { shape: "intro -> theme (question, answer) -> build -> hush -> coda", transitions: "a breath (caesura) before a sudden hush", endings: "a rolled tonic into the pedal" },- avoid: "octaves in both hands on one downbeat (peaks); a compressor" },- { id: "minimalist", name: "minimalist / pulse", atmosphere: "hypnotic, curious, clean: interlocking ostinatos that change slowly", tempo: [96, 144], meters: ["4/4", "12/8", "5/4", "7/8"], swing: [0.5, 0.5],- palette: { arp: V("marimba", "accomp", -3), lead: V("marimba", "melody", 1), bass: V("marimba", "bass", -1), counter: V("vibes", "color", -8, { trem: 4.5 }), chords: V("piano", "accomp", -8), kick: V("kick", "drum", -6, { soft: 1 }, 0.2), ghost: V("snare", "drum", -6, { rim: true }, 0.2), perc: V("hat", "drum", 0, undefined, 0.2) },- alternates: { arp: { piano: V("piano", "accomp", -4), pluck: V("softPluck", "accomp", 3, { decay: 0.2, bright: 4000 }) } }, fx: {},- stemTargets: T({ arp: -20, lead: -17, bass: -21, counter: -27, chords: -26 }), calibrated: false, grooves: ["pulse"], moods: ["curious", "tension", "awe", "calm"],- harmony: { modes: ["dorian", "lydian", "aeolian", "major", "mixolydian"], qualities: "open 5ths, add9, quartal stacks", tendencies: "a two-chord cycle for 8-16 bars, then one note changes", rhythm: "slow; the ostinato is the rhythm", voicing: "mid-register, interlocking; no doubled roots", tension: "phase shifts, added beats, a new bass note under the same pattern" },- melody: { range: "C4-C6", contour: "cells, not tunes", density: "2-4 onsets per beat in the ostinato", motif: "a 5-8 note cell; change ONE thing every 8-16 bars (add, drop, rotate)" },- arrangement: { shape: "additive: one layer at a time", transitions: "a change at least every 16 bars", endings: "subtractive, or a hard stop" }, avoid: "a big climax; a change more often than every 4 bars" },- { id: "jazz", name: "jazz / swing", atmosphere: "loose, warm, clever: swing ride, walking bass, comping piano", tempo: [80, 200], meters: ["4/4", "3/4"], swing: [0.6, 0.67],- palette: { chords: V("piano", "accomp", -4), lead: V("vibes", "melody", 0, { trem: 4 }), bass: V("bass", "bass", -2, { drive: 1.1 }), counter: V("woodwind", "color", -2, { reed: true }), ...kit(-3, 1) },- alternates: { lead: { piano: V("piano", "melody", 0), clarinet: V("woodwind", "melody", 0, { reed: true }), flute: V("woodwind", "melody", 0), brass: V("brass", "melody", -3, { bright: 0.8 }) } }, fx: {},- stemTargets: T({ ...std, chords: -22, lead: -16, counter: -21, bass: -18, kick: -24, snare: -26, ghost: -28, hat: -26, perc: -30 }), calibrated: false, grooves: ["swing", "brushes", "shuffle"], moods: ["playful", "nostalgic", "romantic", "curious", "sensual", "mischief"],- harmony: { modes: ["major", "dorian", "mixolydian", "melodicMinor", "blues"], qualities: "7ths required; 9ths, 13ths, altered dominants (7b9, 7#11)", tendencies: "ii-V-I, iii-VI-ii-V turnarounds, tritone substitutions, backdoor bVII7-I", rhythm: "two chords a bar at turnarounds", voicing: "rootless shell voicings (3-7, 7-3) in the middle; the walking bass owns roots", tension: "altered dominants, chromatic approach chords; release on a 6/9 or maj7" },- melody: { range: "A3-C6", contour: "bebop lines: chord tones on beats, approach notes between", density: "swung 8ths with rests", motif: "a riff restated over changing chords (the chords change under it)" },- arrangement: { shape: "head (theme) -> solos -> head out", transitions: "a 2-bar break, trading 4s", endings: "a tag (the last 2 bars three times) or a ritard on a 6/9" }, avoid: "straight 8ths, triads only" },- { id: "lullaby", name: "lullaby", atmosphere: "soft, rocking, safe", tempo: [56, 78], meters: ["3/4", "6/8"], swing: [0.5, 0.5],- palette: { lead: V("celesta", "melody", 0), arp: V("harp", "accomp", -8), bass: V("harp", "bass", -6), counter: V("musicBox", "color", -8), chords: V("strings", "accomp", -12, { attack: 1.0, release: 1.4, bright: 0.6 }) },- alternates: { lead: { musicBox: V("musicBox", "melody", 0), piano: V("piano", "melody", 0), flute: V("woodwind", "melody", -2) } }, fx: {},- stemTargets: T({ lead: -17, arp: -24, bass: -25, counter: -27, chords: -28 }), calibrated: false, grooves: [], moods: ["tender", "calm"],- harmony: { modes: ["major", "majorPentatonic", "mixolydian"], qualities: "triads, add9, sus2", tendencies: "I-IV-I rocking, plagal cadences, a gentle ii", rhythm: "one chord per bar", voicing: "close, mid-high", tension: "almost none; a minor lullaby is flagged for the human check (tips into eerie)" },- melody: { range: "C4-C6", contour: "rocking stepwise, falling phrase ends", density: "1-2 notes per beat", motif: "a 2-bar rocking figure repeated with a changed ending" },- arrangement: { shape: "melody + gentle arpeggio, nothing percussive", transitions: "none needed", endings: "the tonic, soft, rolled" }, avoid: "drums, surprise, bright highs" },- { id: "chiptune", name: "chiptune", atmosphere: "8-bit, bright, game-like: two pulses, a triangle, noise drums", tempo: [110, 170], meters: ["4/4", "6/8"], swing: [0.5, 0.56],- palette: { lead: V("pulse", "melody", 0, { duty: 0.25, grid: true }), arp: V("pulse", "accomp", -5, { duty: 0.125, pan: 0.25, grid: true }), bass: V("triangle", "bass", 1, { grid: true }), kick: V("noiseDrum", "drum", -2, { grid: true }), snare: V("noiseDrum", "drum", -4, { grid: true }), hat: V("noiseDrum", "drum", -10, { grid: true }) },- alternates: { lead: { square: V("pulse", "melody", -2, { duty: 0.5, grid: true }) } }, fx: {},- stemTargets: T({ lead: -16, arp: -22, bass: -18, kick: -18, snare: -20, hat: -28 }), calibrated: false, grooves: ["fourFloor", "bounce", "shuffle", "skip"], moods: ["joy", "playful", "drive", "tension", "mischief"],- harmony: { modes: ["major", "aeolian", "dorian", "mixolydian"], qualities: "triads; chords are faked by fast arpeggios", tendencies: "I-vi-IV-V, i-bVI-bVII, key changes up a step", rhythm: "one chord per bar", voicing: "arpeggio 16ths across an octave", tension: "a held dominant arpeggio, a pitch-bend-free chromatic climb" },- melody: { range: "C4-C7", contour: "hooky, leaping", density: "8ths and 16ths", motif: "a 1-bar hook, answered, sequenced" },- arrangement: { shape: "4 voices max: lead, arp, triangle bass, noise", transitions: "a drum fill, a key change", endings: "a fanfare button" }, avoid: "reverb, more than 4 voices, pads" },- { id: "lofi", name: "dusty lo-fi hip-hop", atmosphere: "hazy, nostalgic, crackly: FM e-piano, vinyl, a lazy swung beat (the dusty cousin of lo-fi electronic)", tempo: [68, 90], meters: ["4/4"], swing: [0.55, 0.62],- palette: { chords: V("ePiano", "accomp", -5, { detune: 5 }), lead: V("ePiano", "melody", 4, { detune: 6, width: 0.2 }), bass: V("bass", "bass", -2), counter: V("fmBell", "color", -8), ...kit(-6, 1, { hat: V("hat", "drum", -8, { pan: 0.25 }, 0.2) }) },- alternates: { lead: { guitar: V("guitar", "melody", 2), flute: V("woodwind", "melody", -2) } }, fx: {},- stemTargets: T({ ...std, chords: -20, lead: -17, bass: -19, kick: -17, snare: -22, hat: -30 }), calibrated: false, grooves: ["bounce", "halfTime", "shuffle"], moods: ["nostalgic", "calm", "wistful", "sensual"],- harmony: { modes: ["major", "dorian", "aeolian"], qualities: "maj9, m9, 13, m11", tendencies: "2-4 chord loops, ii-V drifts", rhythm: "1-2 chords a bar", voicing: "e-piano 4-note voicings", tension: "a borrowed iv" },- melody: { range: "C4-C6", contour: "lazy, behind the beat", density: "sparse", motif: "a 2-bar sampled-sounding phrase" },- arrangement: { shape: "4 or 8 bar loop with variations", transitions: "a filter or a drop-out", endings: "fade or tape stop" }, avoid: "using it when the brief says clean or upbeat (then use lofiElectronic)" },- { id: "orchestral", name: "orchestral / epic", atmosphere: "big and heroic: brass theme, string ostinato engine, choir, timpani", tempo: [70, 140], meters: ["4/4", "3/4", "6/8"], swing: [0.5, 0.5],- palette: { lead: V("brass", "melody", 0, { attack: 0.06 }, 0.45), chords: V("strings", "accomp", -4, { attack: 0.5, release: 1.2 }, 0.5), arp: V("strings", "accomp", -3, { attack: 0.01, release: 0.1, bright: 1.2 }, 0.35), bass: V("strings", "bass", -2, { attack: 0.2, release: 0.8, bass: true, bright: 0.6 }, 0.35), counter: V("choir", "color", -2, { vowel: "a" }, 0.6), perc: V("timpani", "drum", 0, { pitch: 38 }, 0.5), kick: V("kick", "drum", 0, { soft: 1 }, 0.5), snare: V("snare", "drum", -3, undefined, 0.6), hat: V("hat", "drum", 4, undefined, 0.4) },- alternates: { lead: { strings: V("strings", "melody", 0, { attack: 0.15, release: 0.9, width: 0.4 }, 0.45), horn: V("brass", "melody", -2, { attack: 0.1, bright: 0.6 }, 0.5), flute: V("woodwind", "melody", -2, undefined, 0.5) }, counter: { flute: V("woodwind", "color", -3, undefined, 0.5), harp: V("harp", "color", 0, undefined, 0.5) } }, fx: {},- stemTargets: T({ lead: -16, chords: -19, arp: -20, bass: -19, counter: -22, perc: -17, kick: -17, snare: -24, hat: -32 }), calibrated: false, grooves: ["epic", "build", "tension", "pulse"], moods: ["heroic", "triumph", "awe", "tension", "grief"],- harmony: { modes: ["major", "aeolian", "dorian", "mixolydian", "harmonicMinor"], qualities: "triads and power 5ths, sus4 resolving, major IV in minor", tendencies: "i-bVI-bIII-bVII, I-bVII-IV-I (mixolydian heroism), chromatic mediants for arrivals, a pedal under the build", rhythm: "one chord per 1-2 bars, faster into cadences", voicing: "brass in the middle in 3rds and 5ths, strings octaves above, bass in octaves", tension: "a long dominant pedal with the ostinato rising, sus4 held; release to the tonic major with everything" },- melody: { range: "brass G3-C5 (heroic), strings up to A6", contour: "a rising 4th or 5th then steps; big arcs", density: "long notes over a busy ostinato", motif: "a fanfare cell (rising 4th/5th + rhythm) developed: fragment it in the build, augment it at the climax" },- arrangement: { shape: "intro (ostinato alone) -> theme (strings) -> theme (brass) -> build -> tutti climax -> quiet coda", transitions: "timpani roll or snare build into downbeats; a bar of silence before the last statement", endings: "a big held chord with timpani, or a hard cut" }, avoid: "all families at once all the time; a brass lead above C6" },- { id: "suspense", name: "suspense / horror", atmosphere: "unsettling, cold, withheld: low drones, heartbeat pulse, high bowed harmonics, stingers", tempo: [50, 110], meters: ["4/4", "5/4", "3/4"], swing: [0.5, 0.5],- palette: { chords: V("strings", "accomp", -6, { attack: 2.0, release: 2.5, bright: 0.5 }, 0.6), bass: V("sub", "bass", -6, { cut: 110 }), lead: V("bowedSolo", "melody", 0, { vibrato: 8 }, 0.6), counter: V("celesta", "color", -4, undefined, 0.7), arp: V("strings", "accomp", -6, { attack: 0.005, release: 0.08, bright: 0.8 }, 0.3), kick: V("kick", "drum", 0, { soft: 1 }, 0.4), ghost: V("snare", "drum", -4, { rim: true }, 0.5), perc: V("timpani", "drum", -2, { pitch: 33 }, 0.6), hat: V("hat", "drum", 0, undefined, 0.5) },- alternates: { counter: { choir: V("choir", "color", -4, { vowel: "u" }, 0.7), bell: V("fmBell", "color", -8, { ratio: 1.41 }, 0.7) }, lead: { choir: V("choir", "melody", -2, { vowel: "o" }, 0.6), cello: V("bowedSolo", "melody", 0, { cello: true, vibrato: 12 }, 0.5) } }, fx: {},- stemTargets: T({ chords: -21, bass: -20, lead: -19, counter: -24, arp: -22, kick: -17, ghost: -27, perc: -18, hat: -32 }), calibrated: false, grooves: ["pulse", "tension", "epic"], moods: ["tension", "dread", "eerie"],- harmony: { modes: ["phrygian", "locrian", "harmonicMinor", "wholeTone", "aeolian"], qualities: "clusters, minor 2nds, tritones, minor-major 7th, augmented triads", tendencies: "a pedal that never resolves, chromatic crawl up or down by semitone, i-bII (phrygian), sudden major chord a tritone away", rhythm: "static: one sound for 4-8 bars, then a jolt", voicing: "very low and very high with an empty middle", tension: "withhold resolution; a stinger (all voices, one hit) on the scare; silence right before it" },- melody: { range: "extremes: below C3 or above C6", contour: "a 2-3 note cell, often a semitone", density: "sparse, irregular", motif: "a semitone sigh or a tritone leap, repeated slower each time" },- arrangement: { shape: "drone -> pulse enters -> rising ostinato -> stinger on the hit -> silence -> aftermath drone", transitions: "cut to silence; a slow crescendo that stops short", endings: "unresolved: a held cluster, or a single low hit" }, avoid: "a major cadence, melody in the middle register, busy drums" },- { id: "rock", name: "rock / band", atmosphere: "live-band energy: driven guitars, bass locked to the kick, a tight kit, maybe organ", tempo: [90, 160], meters: ["4/4", "6/8"], swing: [0.5, 0.52],- palette: { chords: V("strings", "accomp", -6, { attack: 0.005, release: 0.08, bright: 2.0, width: 0.9, grid: true }, 0.2), lead: V("leadSynth", "melody", -2, { cut: 1400, env: 3000, square: 0.8, glide: 0.02 }, 0.25), bass: V("bass", "bass", -2, { drive: 2.2 }), counter: V("organ", "color", -6, { bright: 1.2 }, 0.3), ...kit(0, 0.5) },- alternates: { chords: { organ: V("organ", "accomp", -4, { bright: 1.3 }, 0.25), piano: V("piano", "accomp", -3, undefined, 0.2) }, lead: { guitar: V("guitar", "melody", 2, undefined, 0.2) } }, fx: {},- stemTargets: T({ ...std, chords: -19, lead: -16, bass: -17, counter: -23, kick: -13, snare: -17, hat: -27, perc: -26 }), calibrated: false, grooves: ["rock", "halfTime", "shuffle", "fourFloor"], moods: ["drive", "anger", "triumph", "joy", "heroic"],- harmony: { modes: ["mixolydian", "aeolian", "major", "blues", "dorian"], qualities: "power chords (root-5th-octave), triads, sus4", tendencies: "I-bVII-IV, i-bVI-bVII, riffs on the pentatonic, a chorus a 4th up", rhythm: "one chord per bar in verses, two in choruses", voicing: "power chords low (E2-E4), the bass doubling the root in 8ths", tension: "a riff held on the V, a stop before the chorus" },- melody: { range: "E3-A5", contour: "riff-based, pentatonic, strong beats", density: "8ths", motif: "a 1-2 bar riff that IS the song; the vocal-like lead answers it" },- arrangement: { shape: "riff intro -> verse -> pre -> chorus -> verse -> chorus -> bridge -> chorus x2", transitions: "a drum fill and a crash into every section", endings: "a big held last chord with a fill, or a stop on 1" }, avoid: "swing, soft attacks, long pads; the guitar tone here is an approximation: say so" },- { id: "hipHop", name: "hip-hop / trap", atmosphere: "head-nod or dark trap: heavy 808, crisp clap, rolling hats, a moody loop on top", tempo: [70, 100], meters: ["4/4"], swing: [0.52, 0.6],- palette: { bass: V("sub", "bass", -4, { cut: 180 }), chords: V("piano", "accomp", -6, undefined, 0.3), lead: V("softPluck", "melody", 4, { decay: 0.5, bright: 3000, delay: "beats:0.75", feedback: 0.25, delayMix: 0.2 }, 0.3), counter: V("strings", "color", -8, { attack: 0.6, release: 1.0, bright: 0.7 }, 0.4), ...kit(0, 0.4, { hat: V("hat", "drum", 14, { pan: 0.15 }, 0.05) }) },- alternates: { lead: { bell: V("fmBell", "melody", -2, undefined, 0.3), flute: V("woodwind", "melody", -2, undefined, 0.3), choir: V("choir", "melody", -4, { vowel: "o" }, 0.5) }, chords: { pad: V("warmPad", "accomp", -3, { cut: 2000, attack: 0.4, release: 1.2 }, 0.3) } }, fx: { clean: true, duck: { by: "kick", parts: ["chords", "counter"], depth: 0.3, release: 0.2 } },- stemTargets: T({ ...std, bass: -15, kick: -13, snare: -18, hat: -26, chords: -22, lead: -18, counter: -25 }), calibrated: false, grooves: ["trap", "bounce", "halfTime", "broken"], moods: ["drive", "calm", "nostalgic", "sensual", "anger", "tension"],- harmony: { modes: ["aeolian", "phrygian", "harmonicMinor", "dorian"], qualities: "minor triads, m7, dim, a single dark chord for 2 bars", tendencies: "2-chord minor loops, i-bVI, i-bII (phrygian menace), a melody over one chord", rhythm: "one chord per 1-2 bars", voicing: "piano or bells high, the 808 low with nothing between", tension: "the 808 sliding or dropping out; a switch-up after 8 bars" },- melody: { range: "C4-C6", contour: "short repeated figures", density: "sparse over busy hats", motif: "a 1-2 bar loop that repeats (the loop is the hook); vary it every 8 bars" },- arrangement: { shape: "intro (loop alone) -> 8-bar blocks with drops, switch-ups -> outro loop", transitions: "drop the drums for a bar, a hat roll into the downbeat", endings: "the loop alone, or a cut" }, avoid: "an 808 that owns everything below 150 Hz with no harmonics (phones): check stems" },- { id: "house", name: "house / EDM", atmosphere: "euphoric, dancing, bright: four-on-the-floor, offbeat bass, stabs, a big pad", tempo: [118, 128], meters: ["4/4"], swing: [0.5, 0.54],- palette: { chords: V("organ", "accomp", -6, { bright: 1.4, trem: 0 }, 0.3), bass: V("bass", "bass", -3, { drive: 2.0, grid: true }), lead: V("softPluck", "melody", 5, { decay: 0.25, bright: 7000, delay: "beats:0.75", feedback: 0.3, delayMix: 0.25, grid: true }, 0.25), counter: V("warmPad", "color", -4, { cut: 4000, attack: 0.3, release: 1.0 }, 0.4), arp: V("softPluck", "accomp", 3, { decay: 0.15, bright: 5000, grid: true }, 0.2), ...kit(1, 0.3, { hat: V("hat", "drum", 12, { pan: 0.2, grid: true }, 0.1) }) },- alternates: { chords: { pad: V("warmPad", "accomp", -3, { cut: 3000, attack: 0.2, release: 0.8 }, 0.35), piano: V("piano", "accomp", -3, undefined, 0.25) }, lead: { synth: V("leadSynth", "melody", -2, { cut: 2000, env: 5000 }, 0.3) } }, fx: { clean: true, duck: { by: "kick", parts: ["chords", "counter", "arp"], depth: 0.6, release: 0.18 } },- stemTargets: T({ ...std, kick: -12, snare: -18, hat: -26, perc: -27, bass: -16, chords: -21, lead: -17, counter: -23, arp: -22 }), calibrated: false, grooves: ["fourFloor", "build", "broken"], moods: ["joy", "drive", "sensual", "hopeful"],- harmony: { modes: ["aeolian", "dorian", "major", "mixolydian"], qualities: "m7, m9, maj7 stabs; piano house triads", tendencies: "i-VI-III-VII, vi-IV-I-V, 2-chord dorian vamps; a long pedal in the build", rhythm: "one chord per bar or per 2 bars; stabs on offbeats", voicing: "stabs mid-register, the bass on the offbeat 8th", tension: "filter build + snare build + one beat of silence; release = the drop" },- melody: { range: "C4-C6", contour: "repetitive riffs", density: "8ths and 16ths", motif: "a 1-bar riff repeated 4-8 times with one change" },- arrangement: { shape: "intro (kick + hats) -> groove -> breakdown (pad + motif) -> build -> drop -> outro (kick)", transitions: "16- or 32-bar blocks; builds of 8", endings: "DJ-friendly: strip back to kick and hats" }, avoid: "swing, busy harmony, a quiet drop" },- { id: "synthwave", name: "synthwave / retro", atmosphere: "neon-nostalgic, cinematic 80s: big gated snare, pulsing 8th bass, lush pads, a soaring lead", tempo: [80, 118], meters: ["4/4"], swing: [0.5, 0.5],- palette: { chords: V("strings", "accomp", -6, { attack: 0.4, release: 1.4, bright: 1.1, width: 1 }, 0.5), bass: V("bass", "bass", -3, { drive: 1.8, grid: true }), lead: V("leadSynth", "melody", 0, { glide: 0.06, cut: 2200, env: 4000, square: 0.3 }, 0.4), arp: V("softPluck", "accomp", 3, { decay: 0.18, bright: 4500, delay: "beats:0.75", feedback: 0.35, delayMix: 0.3, grid: true }, 0.3), counter: V("fmBell", "color", -8, undefined, 0.5), ...kit(0, 0.5, { snare: V("snare", "drum", 5, undefined, 0.7) }) },- alternates: { chords: { pad: V("warmPad", "accomp", -2, { cut: 3200, attack: 0.6, release: 1.6, spread: 0.9 }, 0.5) }, lead: { brass: V("brass", "melody", -2, { bright: 1.3 }, 0.4) } }, fx: { clean: true, duck: { by: "kick", parts: ["chords", "arp"], depth: 0.35, release: 0.25 } },- stemTargets: T({ ...std, kick: -13, snare: -17, hat: -28, bass: -17, chords: -21, lead: -16, arp: -22, counter: -25 }), calibrated: false, grooves: ["fourFloor", "halfTime", "rock", "build"], moods: ["nostalgic", "drive", "heroic", "romantic", "tension"],- harmony: { modes: ["aeolian", "dorian", "major", "lydian"], qualities: "minor triads, add9, maj7, sus2", tendencies: "i-bVI-bIII-bVII, vi-IV-I-V, a lydian II for the neon lift", rhythm: "one chord per bar", voicing: "wide pads, bass in driving 8ths on the root", tension: "a long build on the V with the arp rising; release with the gated snare" },- melody: { range: "A3-E6", contour: "soaring, long notes with glide", density: "long lead notes over a busy arp", motif: "a 2-bar singable lead phrase, stated then lifted an octave" },- arrangement: { shape: "pad intro -> bass + drums -> lead theme -> breakdown -> lead an octave up -> outro pad", transitions: "a tom-like fill (build), a drop-out bar", endings: "the pad alone, long tail" }, avoid: "trap hats, acoustic instruments, a dry mix" },- { id: "world", name: "world / modal folk", atmosphere: "rooted, spacious, rhythmic: a drone, a modal melody on plucked strings or a flute, hand percussion cycles (write your own melody; name the tradition you draw on)", tempo: [60, 150], meters: ["7/8", "9/8", "12/8", "6/8", "4/4", "5/4"], swing: [0.5, 0.56],- palette: { lead: V("woodwind", "melody", 0, { breath: 0.1 }, 0.4), counter: V("harp", "color", -2, undefined, 0.35), arp: V("guitar", "accomp", -4, undefined, 0.3), chords: V("warmPad", "accomp", -8, { cut: 1600, attack: 1.2, release: 2.0, spread: 0.4 }, 0.4), bass: V("sub", "bass", -8, { cut: 180 }), kick: V("timpani", "drum", -2, { pitch: 43, decay: 0.5 }, 0.2), ghost: V("snare", "drum", -2, { rim: true }, 0.25), perc: V("hat", "drum", 8, { pan: -0.3 }, 0.2), hat: V("hat", "drum", 6, { pan: 0.3 }, 0.15) },- alternates: { lead: { pluck: V("guitar", "melody", 2, undefined, 0.3), marimba: V("marimba", "melody", 1, undefined, 0.3), reed: V("woodwind", "melody", 0, { reed: true }, 0.4), bowed: V("bowedSolo", "melody", 0, undefined, 0.4) } }, fx: {},- stemTargets: T({ lead: -16, counter: -21, arp: -21, chords: -25, bass: -22, kick: -17, ghost: -24, perc: -28, hat: -30 }), calibrated: false, grooves: ["hand", "pulse", "brushes"], moods: ["calm", "joy", "curious", "mischief", "awe", "sensual"],- harmony: { modes: ["dorian", "phrygian", "mixolydian", "aeolian", "majorPentatonic", "minorPentatonic", "harmonicMinor"], qualities: "a drone (tonic + 5th) more than chords; modal colour chords sparingly", tendencies: "modal: stay on the tonic drone, move the melody through the mode; a second drone a step away for contrast", rhythm: "the percussion cycle carries it; harmony changes rarely", voicing: "open 5ths, the drone low and wide", tension: "the mode's colour note held against the drone; release on the tonic" },- melody: { range: "a 10th around the drone", contour: "ornamented steps (grace notes, turns), phrases that return to the drone note", density: "flowing 8ths and 16ths with long held notes", motif: "a modal phrase that grows by adding ornaments on repeats" },- arrangement: { shape: "drone alone -> melody free -> percussion enters -> faster, denser -> return to the drone", transitions: "an accelerando, a percussion break", endings: "the melody alone on the tonic over the drone" }, avoid: "copying a traditional melody; Western functional cadences everywhere" },- { id: "choral", name: "choral / sacred", atmosphere: "vast, human, reverent: voices in parts, organ, bells, a slow swell", tempo: [50, 90], meters: ["4/4", "3/4"], swing: [0.5, 0.5],- palette: { chords: V("choir", "accomp", -2, { vowel: "a", attack: 0.5 }, 0.7), lead: V("choir", "melody", 0, { vowel: "o", attack: 0.25, width: 0.3 }, 0.6), bass: V("organ", "bass", -4, { bright: 0.5 }, 0.5), counter: V("fmBell", "color", -8, undefined, 0.7), arp: V("harp", "accomp", -6, undefined, 0.6), perc: V("timpani", "drum", -4, { pitch: 38 }, 0.6), kick: V("timpani", "drum", -6, { pitch: 31, decay: 1.2 }, 0.6) },- alternates: { chords: { organ: V("organ", "accomp", -4, { bright: 0.9 }, 0.6), strings: V("strings", "accomp", -4, { attack: 0.8, release: 1.6 }, 0.6) }, lead: { bowed: V("bowedSolo", "melody", 0, undefined, 0.6), flute: V("woodwind", "melody", -2, undefined, 0.6) } }, fx: {},- stemTargets: T({ chords: -19, lead: -17, bass: -21, counter: -26, arp: -24, perc: -20 }), calibrated: false, grooves: ["pulse"], moods: ["awe", "grief", "hopeful", "tender", "heroic"],- harmony: { modes: ["major", "aeolian", "dorian", "lydian"], qualities: "triads in 4 parts, suspensions, the picardy third", tendencies: "chorale motion: I-IV-V-I, vi-IV-I-V, plagal amen (IV-I), deceptive V-vi before the final cadence", rhythm: "one chord per beat or per half bar (chorale), slower in swells", voicing: "SATB spacing: no gaps wider than an octave between upper voices, bass free; avoid parallel 5ths", tension: "4-3 suspensions, a held dominant; release on a plagal amen" },- melody: { range: "C4-G5 (singable)", contour: "stepwise, phrase-shaped like breath", density: "1 note per beat or slower", motif: "a hymn-like phrase whose cadence changes each time" },- arrangement: { shape: "a single voice -> full parts -> a swell -> a hush -> the final chord", transitions: "a fermata (breath) between phrases", endings: "a plagal amen or a picardy third, long tail" }, avoid: "fast rhythms, drums, choir as a lead above G5" },-];diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocabTrim.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocabTrim.tsdeleted file mode 100644index d207919..0000000--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/vocabTrim.ts+++ /dev/null@@ -1,247 +0,0 @@-// GENERATED by `node tools/music.mjs calibrate`: per style, the gain trim (dB) that brings each palette-// voice's stem to its target on a neutral test phrase. Calibrated styles (listened) are never trimmed.-import type { Slot } from "./vocab";-export const VOCAB_TRIM: Record<string, Partial<Record<Slot, number>>> = {- drive: {- chords: 5.3,- lead: 7.4,- counter: 12,- bass: 3.1,- kick: 0.5,- snare: 8.5,- arp: 1.2,- perc: 8.3- },- cinematic: {- chords: 5.2,- lead: 4.5,- counter: 12,- bass: 4.3,- kick: -4.4,- arp: 7.4- },- ambient: {- chords: 2.5,- lead: 1.3,- counter: 0.8,- bass: -0.3,- kick: -2.4,- arp: 3.1- },- folk: {- chords: 12,- lead: 12,- counter: 11.2,- bass: 1.6,- kick: -0.5,- ghost: 9.4,- arp: 12,- perc: 12- },- playful: {- chords: 1.7,- lead: 2.1,- counter: 12,- bass: 1.4,- kick: 0.3,- snare: 5.1,- hat: 10.2,- arp: 12,- perc: 9.7- },- musicBox: {- chords: 4.7,- lead: 3.5,- counter: 4.3,- bass: 5,- arp: 3- },- nocturne: {- chords: 12,- lead: 12,- counter: 12,- bass: 6.3- },- minimalist: {- chords: 12,- lead: 2.1,- counter: 11.7,- bass: -3.9,- arp: 2.5- },- jazz: {- chords: 12,- lead: 3.8,- counter: 10.5,- bass: 0.7,- kick: 2.8,- ghost: 10.5,- hat: 12,- perc: 11- },- lullaby: {- chords: 3.5,- lead: 5.3,- counter: 12,- bass: 12,- arp: 12- },- chiptune: {- lead: 7.4,- bass: -0.8,- kick: 9.6,- snare: 10.7,- arp: 12- },- lofi: {- chords: 10.2,- lead: 3.5,- counter: 12,- bass: -0.1,- kick: 3.4,- snare: 9.2,- ghost: 12,- hat: 12- },- orchestral: {- chords: 3.6,- lead: 9.2,- counter: 0.3,- bass: 2.9,- kick: -3.3,- snare: 8.2,- arp: 7.4,- perc: 4.2- },- suspense: {- chords: 5.2,- lead: 7.3,- counter: 12,- bass: -0.1,- kick: -3.4,- arp: 8.7,- perc: 10.4- },- rock: {- chords: 5.1,- lead: 11.9,- counter: 12,- bass: 1.2,- kick: 1.2,- snare: 8.2,- hat: 8.6,- perc: 7- },- hipHop: {- chords: 12,- lead: -1.3,- counter: 12,- bass: 1.5,- kick: 1.4,- snare: 7.2,- hat: 9.6,- perc: 9.9- },- house: {- chords: 11.2,- lead: -0.7,- counter: 10.9,- bass: 3.3,- kick: 1.6,- snare: 6.7,- arp: 1.5,- perc: 7.3- },- synthwave: {- chords: 3.9,- lead: 11.7,- counter: 12,- bass: 2.7,- kick: 1.4,- snare: 6.7,- arp: 1.1,- perc: 6.2- },- world: {- chords: 4.9,- lead: 8.7,- counter: 12,- bass: -1.6,- kick: 2.3,- ghost: 11.5,- arp: 12- },- choral: {- chords: -7.9,- lead: -3.1,- counter: 12,- bass: 12,- arp: 12,- perc: 9.5- }-};-/** Where a 12 dB trim could not reach the target (long-decaying plucks read low as active RMS), the target moves to where the voice sits. */-export const VOCAB_TARGET_FIX: Record<string, Partial<Record<Slot, number>>> = {- drive: {- counter: -3.3- },- cinematic: {- counter: -14.7- },- ambient: {},- folk: {- chords: -13,- lead: -2.8,- arp: -1.9,- perc: -5.8- },- playful: {- arp: -1.4- },- musicBox: {},- nocturne: {- chords: -6.3- },- minimalist: {- chords: -11.1- },- jazz: {- chords: -10.5- },- lullaby: {- counter: -4.7,- bass: -1,- arp: -4.3- },- chiptune: {- arp: -1.1- },- lofi: {- counter: -7.1,- ghost: -1.1,- hat: -13- },- orchestral: {},- suspense: {- counter: -3- },- rock: {- counter: -7.4- },- hipHop: {- chords: -14.8,- counter: -4.2- },- house: {},- synthwave: {- counter: -4.1- },- world: {- counter: -17.1,- arp: -3.2- },- choral: {- counter: -4.5,- arp: -2.3- }-};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/score.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/score.tsindex 8284a4d..4560b20 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/score.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/score.ts@@ -1,27 +1,39 @@-// The scaffold score: an EMPTY composition. A new film starts with no notes at all, only the shape-// of what you will write: the style vocabulary, the mood, the tempo and key you choose, your own-// chords, motifs and form. Nothing here plays until you compose it (composePiece throws on missing-// material). Workflow: references/music/compose.md. Vocabularies: music/vocab.ts.+// The scaffold score: a two-section MusicPlan on the music module, so every new film starts with the+// breadth visible (spec 08 section 12). Section A: music box, JOY, C major, I-IV-V-I. Section B: the+// same box turns WISTFUL in D dorian (same notes, new home; the B natural is the colour). Notes are+// data; the plan fits ANY film length (tempo, then repeats); pure in (frames, sampleRate).//-// CHANGE NOTE: this file used to hold a full C-major music-box piece. Films copied it, so it has been-// removed. No shipped film imported it. The butterfly film keeps its own score (example/.../alive/score.ts).-import type { Material } from "./music/compose";-import { composePiece } from "./music/compose";+// CHANGE NOTE: until the music module landed, this file was 14 lines of sine plucks on a fixed+// C-major arpeggio plus a bell. Nothing imported it, so no shipped film changes sound. The worked+// butterfly film keeps its own score (example/.../alive/score.ts), untouched: it sounds the same.+import { line, type Piece } from "./music/plan";import { filmAudio } from "./music/render";-/** Fill every field for THIS film. Placeholders are written as <angle brackets> and are rejected. */-export const scoreSkeleton = (): Material => ({- style: "lofiElectronic", // a key of VOCAB, chosen from the brief (node tools/music.mjs vocab)- title: "<this film's score>", seed: 0, mood: "calm", // your seed; a mood row that matches the brief- bpm: 0, key: "<tonic>", mode: "major",- chords: {}, // "<name>": { voicing: "[<notes>]", bass: "<one bar>" }- motifs: {}, // "<motif>": "<bars of notation>"- grooves: {}, // main: { family: "<one of the style's grooves>", density: 0.5, variation: 0.4 }- sections: [], // { kind, bars, harmony: [...], lead: [...] } ... land the home chord on the picture's key beat+const B = 4; // 12/8: four dotted-quarter beats a bar, triplet subdivisions+const arp = (r: string, f: string, t: string) => Array.from({ length: 12 }, (_, i) => `${[r, f, t, f][i % 4]}:1/3`).join(" ");++export const fixturesPiece = (bpm = 120): Piece => ({+ title: "Fixtures: joy, then wistful", seed: 3, tail: 1.6,+ harmony: [[0, "C"], [4, "F"], [8, "G"], [12, "C"], [16, "Dm"], [20, "G/D"], [24, "Dm"], [28, "Dm"]].map(([t, name]) => ({ t: t as number, name: name as string })),+ plan: {+ style: "musicBox", tempo: bpm, meter: "12/8", ritard: 0.85,+ sections: [+ { id: "joy", bars: 4, mood: "joy", key: "C", mode: "major", melody: ["hook", "arpeggio"], dyn: [0.75, 0.8], repeatable: true },+ { id: "wistful", bars: 4, mood: "wistful", key: "D", mode: "dorian", melody: ["themeTransformation"], dyn: [0.7, 0.6], ending: "button", repeatable: true, optional: true },+ ],+ },+ parts: [+ // the hook (E-G-A-G), answered; then the same hook re-seated on D dorian+ { id: "melody", inst: "musicBox", role: "melody", opts: { grid: true }, notes: line(0, [+ "E5:1 G5:2/3 A5:1/3 G5:1 E5:1", "A5:1 C6:2/3 A5:1/3 F5:2", "G5:1 A5:2/3 G5:1/3 D5:1 B5:1", "C6:4",+ "F5:1 A5:2/3 B5:1/3 A5:1 F5:1", "B5:1 D6:2/3 B5:1/3 G5:2", "A5:1 B5:2/3 A5:1/3 E5:1 F5:1", "D5:4"].join(" | "), { role: "melody", v: 0.75, bpb: B }) },+ { id: "arp", inst: "musicBox", role: "accomp", gainDb: -7, opts: { grid: true }, notes: line(0, [+ arp("C5", "G5", "E5"), arp("C5", "A5", "F5"), arp("B4", "G5", "D5"), arp("C5", "G5", "E5"),+ arp("D5", "A5", "F5"), arp("D5", "B5", "G5"), arp("D5", "A5", "F5"), "D5:1/3 A5:1/3 F5:1/3"].join(" | "), { role: "accomp", v: 0.5, bpb: B }) },+ { id: "bass", inst: "musicBox", role: "bass", gainDb: -8, opts: { grid: true }, notes: line(0, "C3:2 G3:2 | F3:2 C3:2 | G3:2 D3:2 | C3:4 | D3:2 A3:2 | G3:2 D3:2 | D3:2 A3:2 | D3:1", { role: "bass", v: 0.62, bpb: B }) },+ { id: "bell", inst: "bell", role: "color", notes: line(28, "D6:1", { role: "color", v: 0.7, bpb: B }) },+ ],});-/** A film's `audio`: your composition, fitted to exactly the film's length (it ends on its phrase). */-export const filmScore = (m: Material, fps: number, frames: number) => {- if (!m.bpm || /<|>/.test(JSON.stringify(m))) throw new Error("score.ts: the score is still a skeleton. Compose it (references/music/compose.md).");- return filmAudio(composePiece(m), frames / fps);-};+/** A film's `audio`: exactly the film's length at any sample rate. The same signature as before. */+export const fixturesScore = (fps: number, bpm: number, frames: number) => filmAudio(fixturesPiece(bpm), frames / fps);diff --git a/plugins/anidoodle/skills/anidoodle/engine/test/launchTemplate.test.ts b/plugins/anidoodle/skills/anidoodle/engine/test/launchTemplate.test.tsindex 69645ec..eca78a1 100644--- a/plugins/anidoodle/skills/anidoodle/engine/test/launchTemplate.test.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/test/launchTemplate.test.ts@@ -1,8 +1,8 @@-// LAUNCH TEMPLATE TESTS. makeLaunchFilm takes a score composed for the product: a Material (what-// compose.md writes) or a Piece. anidoodle's own pieces are refused by identity, by title and by-// content, so a retitled or transposed copy of our launch score cannot ship as a user's film.+// LAUNCH TEMPLATE TESTS. makeLaunchFilm takes a score written for the product (a Piece).+// anidoodle's own pieces are refused by identity, by title and by content, so a retitled or+// transposed copy of our launch score cannot ship as a user's film.import { gridScore, makeLaunchFilm } from "../src/canvas-core/launchTemplate";-import { chiptunePlayful, composePiece, daylightCopy, renderPiece, launchLofi3, launchLofi3Material, loudness, perform, truePeak, type Material } from "../src/canvas-core/music";+import { chiptunePlayful, line, renderPiece, launchLofi3, loudness, perform, truePeak, type Piece, type Role } from "../src/canvas-core/music";import type { Film } from "../src/canvas-core/film";export const name = "launchTemplate";@@ -10,33 +10,43 @@ export const run = (ok: (cond: boolean, label: string) => void) => {const plate: Film = { meta: { title: "plate", W: 1080, H: 1080, fps: 30, bpm: 120, durationFrames: 60 }, assets: { images: {} }, shots: [{ id: "p", start: 0, end: 60, draw: () => {} }] };const base = { title: "Tally", asks: [{ prompt: "draw it", plate, label: "l" }], tagline: "t", install: ["npm i tally"], bpm: 120, askBeats: 8, endBeats: 12 };const refused = (score: unknown, re = /anidoodle's own/) => { try { makeLaunchFilm({ ...base, score } as never); return false; } catch (e) { return re.test(String((e as Error).message)); } };- const mine = (): Material => ({- style: "playful", title: "Tally, counted", seed: 5, mood: "curious", bpm: 120, key: "G", mode: "mixolydian",- chords: { G: { voicing: "[D4 G4 B4]", bass: "G2:1.5 D3:.5 G2:1 F2:1" }, F: { voicing: "[C4 F4 A4]", bass: "F2:1.5 C3:.5 F2:1 E2:1" } },- motifs: { a: "B4:.5 D5:.5 G5:1 r:.5 F5:.25 E5:.25 D5:1", b: "r:1 A4:.5 C5:.5 F5:1 E5:.5 C5:.5" },- grooves: { main: { family: "shuffle", density: 0.45, variation: 0.35 } },- sections: [{ kind: "groove", bars: 4, harmony: ["G", "F"], lead: ["a", "b", "a", "b"], groove: "main", stretch: true }, { kind: "outro", bars: 1, harmony: ["G"], lead: ["a"] }],- });- let film: Film | null = null; try { film = makeLaunchFilm({ ...base, score: mine }); } catch (e) { ok(false, `a composed Material is accepted: ${(e as Error).message}`); }- ok(!!film && typeof film.audio === "function", "a composed Material is accepted as the score");+ // a product's own score, written by hand in the bar-checked notation: G mixolydian, 120 bpm, `bars` long+ const mine = (bars: number, sting = false) => (): Piece => {+ const L = (t: number, src: string, role: Role, v = 0.7) => line(t, src, { role, v, bpb: 4 });+ const cyc = (k: number, a: string, b: string) => Array.from({ length: bars }, (_, i) => (i % 2 ? b : a)).slice(0, k).join(" | ");+ const mel = ["B4:.5 D5:.5 G5:1 r:.5 F5:.25 E5:.25 D5:1", "r:1 A4:.5 C5:.5 F5:1 E5:.5 C5:.5", "D5:.75 E5:.25 G5:.5 A5:.5 G5:1 r:1", "F5:.5 E5:.5 C5:1 D5:2"];+ const last = bars - 1;+ return {+ title: "Tally, counted", seed: 5, tail: 1.5, harmony: Array.from({ length: bars }, (_, b) => ({ t: b * 4, name: b % 2 ? "F" : "G" })),+ plan: { style: "minimalist", tempo: 120, meter: "4/4", ritard: 0.95, sections: [{ id: "a", bars, mood: "curious", key: "G", mode: "mixolydian", melody: ["ostinato", "hook"], dyn: [0.6, 0.75], ending: "button" }] },+ parts: [+ { id: "ost", inst: "marimba", role: "accomp", gainDb: -4, notes: L(0, cyc(bars, "G3:.5 D4:.5 B4:.5 D4:.5 G3:.5 D4:.5 B4:.5 D4:.5", "F3:.5 C4:.5 A4:.5 C4:.5 F3:.5 C4:.5 A4:.5 C4:.5"), "accomp", 0.55) },+ { id: "lead", inst: "marimba", role: "melody", gainDb: 1, notes: Array.from({ length: bars }, (_, b) => L(b * 4, b === last ? "[G4 B4 D5 G5]:1@1 r:3" : mel[b % 4], "melody", 0.8)).flat() },+ { id: "low", inst: "bass", role: "bass", gainDb: -2, notes: L(0, cyc(bars, "G2:1.5 D3:.5 G2:1 F2:1", "F2:1.5 C3:.5 F2:1 E2:1"), "bass", 0.8) },+ // a sting: one loud drum hit on the last downbeat, the kind of peak that stops a dynamic bed short of -14 LUFS+ ...(sting ? [{ id: "sting", inst: "kick" as const, role: "drum" as const, gainDb: 14, notes: L(last * 4, "C4:1@1 r:3", "drum", 1) }] : []),+ ],+ };+ };+ let film: Film | null = null; try { film = makeLaunchFilm({ ...base, askBeats: 16, score: mine(10) }); } catch (e) { ok(false, `a product's own score is accepted: ${(e as Error).message}`); }+ ok(!!film && typeof film.audio === "function", "a product's own score (a Piece) is accepted");ok(refused(launchLofi3), "refuses our launch score by identity");- ok(refused(launchLofi3Material), "refuses our launch score's material by identity");ok(refused(chiptunePlayful), "refuses a demo");ok(refused(() => ({ ...launchLofi3(), title: "Mine" })), "refuses a retitled copy of our launch score");- ok(refused(() => ({ ...launchLofi3Material(), title: "Mine" })), "refuses retitled launch material");- ok(refused(daylightCopy), "refuses the transposed copy of our launch score (the Daylight fixture)");+ const transposed = (): Piece => { const p = launchLofi3(); return { ...p, title: "Mine, in E flat", parts: p.parts.map((pt) => ({ ...pt, notes: pt.notes.map((n) => (pt.role === "drum" ? n : { ...n, p: n.p + 3 })) })) }; };+ ok(refused(transposed), "refuses a transposed, retitled copy of our launch score (by content)");ok(refused(undefined, /required/), "a missing score is an error, never a default");- // Sync wins over length: a 120 bpm film with a score whose stretch section is 4 bars plays the- // score at EXACTLY 120 bpm, and the film is made whole bars of it by the end-card hold. The bed is- // that render at one gain (never cut and faded, never re-tempoed), every downbeat on the grid.- const two = { ...base, asks: [base.asks[0], { prompt: "again", plate, label: "l" }], askBeats: 16, endBeats: 12, score: mine };+ // Sync wins over length: a 120 bpm film with a 10-bar score plays the score at EXACTLY 120 bpm,+ // and the film is made whole bars of it by the end-card hold. The bed is that render at one gain+ // (never cut and faded, never re-tempoed), every downbeat on the grid.+ const two = { ...base, asks: [base.asks[0], { prompt: "again", plate, label: "l" }], askBeats: 16, endBeats: 12, score: mine(10) };const bedFilm = makeLaunchFilm(two), N = bedFilm.meta.durationFrames, secs = N / bedFilm.meta.fps, SR = 16000, sc = bedFilm.meta.score;ok(!!sc && sc.tempo === 120 && sc.grid === true, `the score plays at the film's bpm exactly (${sc?.tempo} bpm, ${sc?.form})`);ok(N % 60 === 0, `the film is whole bars of the score (${N} frames = ${N / 60} bars of 60 frames)`);const endAt = bedFilm.cut.STARTS[bedFilm.cut.SEGS.length - 1];ok(bedFilm.cut.STARTS.every((f) => f % 60 === 0) && endAt === 2 * 16 * 15, `every cut sits on a downbeat (${bedFilm.cut.STARTS.join(", ")}; end card at ${endAt})`);- const played = gridScore(mine, 120, 30, endAt, 12 * 15), perf = perform(played.piece, 120, { expressive: true });+ const played = gridScore(mine(10), 120, 30, endAt, 12 * 15), perf = perform(played.piece, 120, { expressive: true });let worst = 0; for (let b = 0; 4 * b * 0.5 < perf.lastOnset - 3; b++) worst = Math.max(worst, Math.abs(perf.sec(4 * b) - 2 * b));ok(worst < 1e-6, `every downbeat before the final ritard lands on its bar, worst ${(worst * 1000).toFixed(3)} ms`);ok(played.bars * 60 < N && played.piece.plan.sections.length >= 1, `the score (${played.bars} bars) ends inside the film and rings out on its last frame`);@@ -44,13 +54,13 @@ export const run = (ok: (cond: boolean, label: string) => void) => {let k = 0; for (let i = 0; i < r.L.length; i++) if (Math.abs(r.L[i]) > Math.abs(r.L[k])) k = i;const g = L[k] / r.L[k]; let dev = 0; for (let i = 0; i < L.length; i++) dev = Math.max(dev, Math.abs(L[i] - g * r.L[i]));ok(L.length === Math.round(secs * SR) && dev < 1e-5, `the bed is that 120 bpm render at one gain, exactly the film's ${secs} s (max deviation ${dev.toExponential(1)})`);- // no form of a fixed score fits: an error that says what to do, never a tempo change- let msg = ""; try { makeLaunchFilm({ ...two, score: () => composePiece({ ...mine(), sections: mine().sections.map((x) => ({ ...x, stretch: false, kind: x.kind === "groove" ? "intro" : x.kind })) }) }); } catch (e) { msg = (e as Error).message; }- ok(/cannot end on a bar.*1-bar stretch section/.test(msg), `a score that cannot fit throws with the fix: ${msg.slice(0, 90)}...`);+ // a score too short for the film: an error that says which lengths fit, never a tempo change+ let msg = ""; try { makeLaunchFilm({ ...two, score: mine(4) }); } catch (e) { msg = (e as Error).message; }+ ok(/cannot end on a bar.*Write it 10-14 bars long/.test(msg), `a score that cannot fit throws with the fix: ${msg.slice(0, 90)}...${msg.slice(-60)}`);const lu = loudness([L, R], SR).integrated, tp = truePeak([L, R]).dbtp;ok(tp <= -0.99 && (Math.abs(lu + 14) < 0.3 || tp > -1.05), `bed at -14 LUFS or held by the -1 dBTP ceiling (${lu.toFixed(2)} LUFS, ${tp.toFixed(2)} dBTP)`);// a dynamic bed stops at the peak ceiling; limit: true lets the limiter take those peaks instead- const long = { ...two, askBeats: 24, endBeats: 16 }, [cL, cR] = makeLaunchFilm(long).audio!(SR), [lL, lR] = makeLaunchFilm({ ...long, limit: true }).audio!(SR);+ const long = { ...two, askBeats: 24, endBeats: 16, score: mine(16, true) }, [cL, cR] = makeLaunchFilm(long).audio!(SR), [lL, lR] = makeLaunchFilm({ ...long, limit: true }).audio!(SR);const cu = loudness([cL, cR], SR).integrated, lu2 = loudness([lL, lR], SR).integrated, tp2 = truePeak([lL, lR]).dbtp;ok(cu < -14.2 && truePeak([cL, cR]).dbtp > -1.05, `without limit the ceiling wins and says so in the loudness (${cu.toFixed(2)} LUFS)`);ok(Math.abs(lu2 + 14) < 0.3 && tp2 <= -1, `limit: true reaches -14 LUFS under -1 dBTP (${lu2.toFixed(2)} LUFS, ${tp2.toFixed(2)} dBTP)`);diff --git a/plugins/anidoodle/skills/anidoodle/engine/tools/music-unit.mjs b/plugins/anidoodle/skills/anidoodle/engine/tools/music-unit.mjsindex a60c314..db28cca 100644--- a/plugins/anidoodle/skills/anidoodle/engine/tools/music-unit.mjs+++ b/plugins/anidoodle/skills/anidoodle/engine/tools/music-unit.mjs@@ -1,12 +1,10 @@#!/usr/bin/env node-// Music unit test: styles are vocabularies, the composer writes the notes.-// node tools/music-unit.mjs-// Asserts: the approved launch score is bit-identical as composed material (md5); neutral mood is the-// calibrated palette exactly; missing material is an error, never a default; every groove family-// parses in every meter and varies with the seed; every style vocabulary composes, renders (true peak-// <= -1 dBTP, loudness at its master target) and meets its stem targets; the stem meter catches a sub-// 9 dB hot that LUFS alone passes; a seamless loop; a film fit that ends on its phrase; the score-// scaffold is empty; and the novelty gate hears the copy Alex heard (Daylight vs the launch score).+// Music unit test. node tools/music-unit.mjs+// Asserts: the approved launch score is bit-identical (md5); a bar that doesn't add up throws, the+// last one too; the stem meter passes the balanced launch mix and catches a sub 9 dB hot that LUFS+// alone passes; a seamless loop; a film's audio is exactly its length; the key check accepts a+// heard tonic and still flags a wrong key; the guards run; and the novelty gate hears a transposed+// copy of a shipped score and a quoted melody, while the shipped pieces stay apart.import { strict as assert } from "node:assert";import { createHash } from "node:crypto";import { build } from "esbuild";@@ -18,125 +16,72 @@ const M = await import("data:text/javascript;base64," + Buffer.from(js).toStringconst md5 = (r) => { const h = createHash("md5"); h.update(Buffer.from(r.L.buffer, r.L.byteOffset, r.L.byteLength)); h.update(Buffer.from(r.R.buffer, r.R.byteOffset, r.R.byteLength)); return h.digest("hex"); };const ok = []; const t0 = Date.now();const pass = (s) => { ok.push(s); console.log(` ok ${s}`); };+const SR = 24000;-// 1. The approved launch score, now composed material on the lo-fi electronic vocabulary: bit-identical.+// 1. The approved launch score: bit-identical.const LAUNCH3_MD5_48K = "d20789f2344e6fff0d2a380c7c7825d2";const launch = M.renderPiece(M.launchLofi3(), 48000);assert.equal(md5(launch), LAUNCH3_MD5_48K, "launchLofi3 audio changed");{ const tp = M.truePeak([launch.L, launch.R]).dbtp, lu = M.loudness([launch.L, launch.R], 48000).integrated; assert(tp <= -1 && Math.abs(lu + 14) <= 1);pass(`launchLofi3 md5 ${LAUNCH3_MD5_48K} (48 kHz), ${lu.toFixed(2)} LUFS, ${tp.toFixed(2)} dBTP`); }-// 2. Mood controls: all at 0.5 = the calibrated palette exactly; moved, the sound changes.-const SR = 24000, launchMd5_24 = md5(M.renderPiece(M.launchLofi3(), SR));-assert.equal(md5(M.renderPiece(M.composePiece({ ...M.launchLofi3Material(), moodControls: { energy: 0.5, warmth: 0.5, brightness: 0.5, tension: 0.5, space: 0.5 } }), SR)), launchMd5_24, "neutral mood must be identity");-assert.notEqual(md5(M.renderPiece(M.composePiece({ ...M.launchLofi3Material(), moodControls: { warmth: 0.9, space: 0.8 } }), SR)), launchMd5_24);-pass("mood controls: 0.5 on all five = identical audio; warmth/space moved = different audio");--// 3. No defaults: missing material is an error that says what to compose.-const base = M.launchLofi3Material();-for (const [what, m] of [- ["harmony", { ...base, sections: base.sections.map((s, i) => (i === 1 ? { ...s, harmony: [] } : s)) }],- ["melody", { ...base, sections: base.sections.map((s) => ({ ...s, lead: undefined })) }],- ["chord voicing", { ...base, chords: { Dm9: base.chords.Dm9 } }],- ["groove", { ...base, grooves: {} }],- ["form", { ...base, sections: [] }],- ["seed/mood", { ...base, mood: undefined }],-]) assert.throws(() => M.composePiece(m), /compose/, `missing ${what} must throw`);-{ const sjs = (await build({ entryPoints: [join(import.meta.dirname, "../src/canvas-core/score.ts")], bundle: true, write: false, platform: "neutral", format: "esm", logLevel: "error" })).outputFiles[0].text;- const S = await import("data:text/javascript;base64," + Buffer.from(sjs).toString("base64")); assert.throws(() => S.filmScore(S.scoreSkeleton(), 30, 300), /skeleton/); }-pass("missing harmony, melody, voicing, groove, form, mood: each throws; the score scaffold is empty and refuses to play");-// A bar that doesn't add up throws, the last one too: a short final bar is a silent gap nobody wrote.+// 2. A bar that doesn't add up throws, the last one too: a short final bar is a silent gap nobody wrote.{ const o = { role: "bass", bpb: 4 };assert.throws(() => M.line(0, "C2:3", o), /sums to 3 beats.*"C2:3 r:1"/, "a one-bar C2:3 in 4/4 must throw");assert.throws(() => M.line(0, "C2:4 | C2:3", o), /bar 1 sums to 3/);assert.equal(M.line(0, "C2:3 r:1", o).length, 1);assert.equal(M.line(6, "C2:2", o).length, 1, "a line starting off the barline may fill to it");- const base = M.launchLofi3Material(), k = Object.keys(base.chords)[0];- assert.throws(() => M.composePiece({ ...base, chords: { ...base.chords, [k]: { ...base.chords[k], bass: "C2:3" } } }), /sums to 3 beats/, "a short bass bar must fail compose (and so check)"); }-pass("notation: a short final bar throws with the rest to write (C2:3 -> C2:3 r:1); compose refuses it");--// 4. Groove families: every family parses in every meter, deterministic, and the seed varies the bars.-{ const meters = ["2/4", "3/4", "4/4", "5/4", "6/8", "7/8", "9/8", "12/8"]; let n = 0;- for (const family of Object.keys(M.GROOVE_FAMILIES)) for (const meter of meters) for (let b = 0; b < 4; b++) {- const g = { family, density: 0.8, variation: 0.8, fill: true }, bar = M.grooveBar(g, meter, 7, b, b, 4), again = M.grooveBar(g, meter, 7, b, b, 4);- assert.deepEqual(bar, again); for (const x of Object.values(bar)) if (x) { M.line(0, x, { role: "drum", bpb: M.beatsPerBar(meter) }); n++; }- }- const bars = (seed) => Array.from({ length: 8 }, (_, b) => JSON.stringify(M.grooveBar({ family: "bounce", density: 0.7, variation: 0.8 }, "4/4", seed, b, b, 8)));- assert.notDeepEqual(bars(1), bars(2)); assert(new Set(bars(1)).size > 1);- pass(`${Object.keys(M.GROOVE_FAMILIES).length} groove families x ${meters.length} meters: ${n} bars parse, deterministic, seed-varied`); }--// 5. Every style vocabulary: a neutral test signal composes, renders, masters and meets its stem targets.-for (const v of Object.values(M.VOCAB)) {- const p = M.composePiece(M.testMaterial(v, { bars: 4 })), r = M.renderPiece(p, SR), tp = M.truePeak([r.L, r.R]).dbtp, lu = M.loudness([r.L, r.R], SR).integrated;- const target = M.STYLES[v.id].master === "dense" ? -14 : -16, b = M.measureStems(p, SR);- assert(tp <= -1, `${v.id}: ${tp} dBTP`); assert(lu <= target + 1 && lu >= target - 6, `${v.id}: ${lu} LUFS vs ${target}`);- if (!v.calibrated) assert(b.pass, `${v.id}: stems ${b.rows.filter((x) => !x.ok).map((x) => `${x.id} ${x.offDb.toFixed(1)}`).join(", ")}`);- assert(!p.parts.some((x) => ["ePiano", "vinyl"].includes(x.inst)) || v.id === "lofi", `${v.id}: ePiano/vinyl only in the dusty lofi style`);-}-pass(`${Object.keys(M.VOCAB).length} style vocabularies compose, render (true peak <= -1 dBTP), master; uncalibrated palettes meet their stem targets on the test signal`);+ assert.equal(M.line(5, "C5:1", { ...o, hit: true }).length, 1, "a declared hit is one short bar on any beat");+ assert.throws(() => M.line(0, "C5:1 | C5:1", { ...o, hit: true }), /a hit is one bar/);+ for (const [k, f] of Object.entries(M.PIECES)) f(); // every shipped piece still writes its final rests+ pass("notation: a short final bar throws with the rest to write (C2:3 -> C2:3 r:1); hit: true for a sting; every shipped piece parses"); }+// 3. Stems: the balanced launch mix passes; a sub 9 dB hot still masters to -14 LUFS, and only the stem meter sees it.{ const b = M.measureStems(M.launchLofi3(), SR); assert(b.pass); const w = b.rows.filter((x) => x.offDb !== null).reduce((a, x) => (Math.abs(x.offDb) > Math.abs(a.offDb) ? x : a));- pass(`lofiElectronic (calibrated on the listened launch score): stems within +-3 dB, worst ${w.id} ${w.offDb.toFixed(1)} dB`); }+ pass(`stems: the launch mix is within +-3 dB of its targets, worst ${w.id} ${w.offDb.toFixed(1)} dB`);+ const p = M.launchLofi3(), hot = { ...p, parts: p.parts.map((x) => (x.id === "sub" ? { ...x, gainDb: (x.gainDb ?? 0) + 9 } : x)) };+ const r = M.renderPiece(hot, SR), lu = M.loudness([r.L, r.R], SR).integrated, hb = M.measureStems(hot, SR), sub = hb.rows.find((x) => x.id === "sub");+ assert(Math.abs(lu + 14) <= 1 && !hb.pass && sub.offDb > 7, "the stem meter must flag a hot sub that LUFS passes");+ pass(`hot sub: mix ${lu.toFixed(1)} LUFS (passes), stem meter flags sub +${sub.offDb.toFixed(1)} dB`);+ const st = { lead: [new Float32Array([10 ** ((-16.5 + 5) / 20)]), new Float32Array(1)] };+ assert(M.stemBalance(st, { lead: -16.5 }).pass); assert(!M.stemBalance({ lead: [new Float32Array([10 ** ((-16.5 + 7) / 20)]), new Float32Array(1)] }, { lead: -16.5 }).pass);+ pass("stems: the lead may sit +3 dB over tolerance (guards win), not more"); }-// 6. The lesson: a sub 9 dB hot still masters to -14 LUFS; only the stem meter sees it.-{ const hot = M.composePiece({ ...base, levels: { bass: 9 } }), r = M.renderPiece(hot, SR), lu = M.loudness([r.L, r.R], SR).integrated, b = M.measureStems(hot, SR), sub = b.rows.find((x) => x.id === "bass");- assert(Math.abs(lu + 14) <= 1 && !b.pass && sub.offDb > 7, "the stem meter must flag a hot sub that LUFS passes");- pass(`hot sub: mix ${lu.toFixed(1)} LUFS (passes), stem meter flags bass +${sub.offDb.toFixed(1)} dB`); }--// 7. A seamless loop (composer's material, loop: true): the seam is an ordinary sample step.-{ const lp = M.renderLoop(M.composePiece(M.testMaterial(M.VOCAB.lofiElectronic, { loop: true })), SR), n = lp.L.length, steps = [];- for (let i = 1; i < n; i += 3) steps.push(Math.abs(lp.L[i] - lp.L[i - 1])); steps.sort((a, b) => a - b);+// 4. A seamless loop: four bars of the launch groove as a plan.loop piece; the seam is an ordinary sample step.+{ const p = M.launchLofi3(), a = 8 * 4, z = 12 * 4, cut = (ns) => ns.filter((n) => n.t >= a && n.t < z).map((n) => ({ ...n, t: n.t - a, d: Math.min(n.d, z - n.t) }));+ const loop = { ...p, title: "loop", harmony: p.harmony.filter((c) => c.t >= a && c.t < z).map((c) => ({ ...c, t: c.t - a })), plan: { ...p.plan, loop: true, sections: [{ ...p.plan.sections[0], bars: 4 }] }, parts: p.parts.map((x) => ({ ...x, notes: cut(x.notes) })) };+ const lp = M.renderLoop(loop, SR), n = lp.L.length, steps = [];+ for (let i = 1; i < n; i += 3) steps.push(Math.abs(lp.L[i] - lp.L[i - 1])); steps.sort((x, y) => x - y);const p999 = steps[Math.floor(steps.length * 0.999)], seam = Math.max(Math.abs(lp.L[0] - lp.L[n - 1]), Math.abs(lp.R[0] - lp.R[n - 1]));- assert(seam <= p999, `seam ${seam} > ${p999}`); assert.equal(md5(lp), md5(M.renderLoop(M.composePiece(M.testMaterial(M.VOCAB.lofiElectronic, { loop: true })), SR)));+ assert(seam <= p999, `seam ${seam} > ${p999}`); assert.equal(md5(lp), md5(M.renderLoop(loop, SR)));pass(`loop: seam step ${seam.toFixed(4)} <= p99.9 ${p999.toFixed(4)}, deterministic`); }-// 8. Film fit: the composition is re-formed (stretch section repeated or dropped) and ends on its phrase.-for (const secs of [70, 90, 110]) {- const f = M.fitScore(M.launchLofi3(), secs), perf = M.perform(f.piece, f.tempo, { expressive: true }), p = f.piece;- assert.equal(p.harmony[p.harmony.length - 1].name, "Cmaj9"); assert.equal(f.form, "full");- assert(Math.abs(perf.lastOnset - (secs - p.tail)) < 0.05); assert(f.tempo >= 90 * 0.88 && f.tempo <= 90 * 1.12);- pass(`fit ${secs} s: ${p.plan.sections[0].bars} bars at ${f.tempo.toFixed(1)} bpm, last onset ${perf.lastOnset.toFixed(2)} s on Cmaj9`);-}+// 5. A film's audio is exactly the film's length.{ const a = M.filmAudio(M.launchLofi3(), 40)(16000); assert.equal(a[0].length, 40 * 16000); pass("filmAudio: exactly the film's length"); }-// 9. Composer-facing fixes (from the blind composer's report).-{ const t = M.testMaterial(M.VOCAB.playful, { bars: 4 }), sec = t.sections[0];- const once = M.composePiece({ ...t, sections: [{ ...sec, lead: sec.lead.slice(0, 2) }] });- assert(once.warnings.some((w) => /plays once/.test(w)), "a short line must warn");- const looped = M.composePiece({ ...t, sections: [{ ...sec, lead: sec.lead.slice(0, 2), loopLines: true }] });- assert.equal(looped.warnings.length, 0); assert.equal(looped.parts.find((p) => p.id === "lead").notes.length, 2 * once.parts.find((p) => p.id === "lead").notes.length);- pass("lines: a short line warns; loopLines repeats it to fill the section");- const lv = (x) => M.composePiece({ ...t, levels: x }).parts.find((p) => p.id === "lead").gainDb;- assert(Math.abs(lv({ lead: 2 }) - lv({}) - 2) < 1e-9); pass("levels: a dB offset on top of the calibrated gain");- const vsum = (en) => M.composePiece({ ...t, sections: [{ ...sec, energy: en }] }).parts.flatMap((p) => p.notes).reduce((a, n) => a + n.v, 0);- assert(vsum(0.2) < vsum(0.5) && vsum(0.8) > vsum(0.5)); pass("section energy scales the dynamics of every part");- const lit = { main: { kick: ["C4:4", "r:2 C4:2"] } }, mk = (from) => M.composePiece({ ...t, grooves: lit, sections: [{ kind: "hook", bars: from, harmony: ["c0"], lead: sec.lead.slice(0, from) }, { kind: "hook", bars: 2, harmony: ["c0"], lead: sec.lead.slice(0, 2) }] });- const kicks = (p, bar) => p.parts.find((x) => x.id === "kick").notes.filter((n) => n.t >= bar * 4 && n.t < bar * 4 + 4).map((n) => n.t - bar * 4);- assert.deepEqual(kicks(mk(1), 1), [0]); assert.deepEqual(kicks(mk(2), 2), [0]); pass("written grooves cycle from each section's first bar");- const orch = (key, tonic) => M.composePiece(M.testMaterial(M.VOCAB.orchestral, { bars: 2, key, tonic })).parts.find((p) => p.id === "perc").opts.pitch % 12;- assert.equal(orch("C", 0), 0); assert.equal(orch("D", 2), 2); pass("timpani in a drum lane is tuned to the key");- const mod = M.composePiece({ ...t, sections: [sec, { ...sec, key: "D" }] }); assert.deepEqual(mod.plan.sections.map((x) => x.key), ["C", "D"]); pass("per-section key: the key check reads each key region");- // the blind composer's case: Db lydian whose notes lean on Ab (the same pitch set as Ab major), tonic ~12 % of note time- const lp = (key, mode, src) => ({ title: "k", seed: 1, tail: 1, harmony: [], plan: { style: "ambient", tempo: 70, meter: "4/4", sections: [{ id: "a", bars: 5, mood: "awe", key, mode, melody: ["stepwise"], dyn: [0.5, 0.5] }] }, parts: [{ id: "m", inst: "fmBell", role: "melody", notes: M.line(0, src, { role: "melody", bpb: 4 }) }] });+// 6. The key check: Db lydian whose notes lean on Ab (the same pitch set as Ab major), tonic ~12 % of note time, is accepted; a wrong key is flagged.+{ const lp = (key, mode, src) => ({ title: "k", seed: 1, tail: 1, harmony: [], plan: { style: "ambient", tempo: 70, meter: "4/4", sections: [{ id: "a", bars: 5, mood: "awe", key, mode, melody: ["stepwise"], dyn: [0.5, 0.5] }] }, parts: [{ id: "m", inst: "fmBell", role: "melody", notes: M.line(0, src, { role: "melody", bpb: 4 }) }] });const src = "Db4:2 Ab4:2 | Ab4:2 Eb4:2 | Eb4:1 F4:2 G4:1 | G4:1 Bb4:2 C5:1 | C5:1 Eb5:1 r:2";assert(M.detectMode(M.line(0, src, { role: "melody", bpb: 4 }), ["lydian", "major", "aeolian", "dorian", "mixolydian"])[0].tonic !== "Db", "fixture must fool the raw detector");assert.deepEqual(M.planProblems(lp("Db", "lydian", src)), []); assert(M.planProblems(lp("E", "major", src)).length > 0);- pass("Db lydian leaning on Ab is accepted (scale fits, tonic heard); a wrong key is still flagged");- const st = { lead: [new Float32Array([0.3 * 10 ** ((-16.5 + 5) / 20) / 0.3]), new Float32Array(1)] };- assert(M.stemBalance(st, { lead: -16.5 }).pass); assert(!M.stemBalance({ lead: [new Float32Array([10 ** ((-16.5 + 7) / 20)]), new Float32Array(1)] }, { lead: -16.5 }).pass); pass("stems: the lead may sit +3 dB over tolerance (guards win), not more");- const w = M.composePiece(M.testMaterial(M.VOCAB.world, { bars: 4 })), wr = M.renderPiece(w, SR), g = M.guardReport(wr, SR, wr.L.length / SR);- assert(Number.isFinite(g.lufs) && g.ghost.windows > 0); pass(`guards run on a 7/8 score (${g.ghost.windows} windows)`); }+ for (const [k, f] of Object.entries(M.SHIPPED)) assert.deepEqual(M.planProblems(f()), [], `${k}: ${M.planProblems(f()).join("; ")}`);+ pass("key check: Db lydian leaning on Ab is accepted (scale fits, tonic heard); a wrong key is flagged; every shipped piece passes"); }++// 7. The guards run on a shipped piece.+{ const r = M.renderPiece(M.folkCalm(), SR), g = M.guardReport(r, SR, r.L.length / SR);+ assert(Number.isFinite(g.lufs) && g.ghost.windows > 0); pass(`guards run (${g.ghost.windows} ghost windows, ${g.lufs.toFixed(1)} LUFS)`); }-// 10. Novelty: the copy Alex heard scores as a copy; the shipped demos stay apart; a reused fragment fails.-{ const d = M.novelty(M.daylightCopy(), M.DEMOS);- assert(!d.pass && d.worst.name.startsWith("launchLofi") && d.worst.score > 0.6, `daylight copy scored ${d.worst.score} vs ${d.worst.name}`);- pass(`novelty: Daylight vs ${d.worst.name} = ${d.worst.score} (threshold ${d.threshold}): FAIL, as Alex heard it`);+// 8. Novelty: a transposed copy of a shipped score fails; the shipped pieces stay apart; a quoted 6-note line fails.+{ const p = M.launchLofi3(), copy = { ...p, title: "copy", parts: p.parts.map((x) => ({ ...x, notes: x.notes.map((n) => (x.role === "drum" ? n : { ...n, p: n.p + 2 })) })) };+ const d = M.novelty(copy, M.SHIPPED);+ assert(!d.pass && d.worst.name.startsWith("launchLofi") && d.worst.score > 0.6, `transposed copy scored ${d.worst.score} vs ${d.worst.name}`);+ pass(`novelty: a transposed copy vs ${d.worst.name} = ${d.worst.score} (threshold ${d.threshold}): FAIL`);let worst = { score: 0 };- for (const n of Object.keys(M.DEMOS)) { const fam = Object.values(M.DEMO_FAMILIES).find((f) => f.includes(n)) ?? [n], v = M.novelty(M.DEMOS[n](), M.DEMOS, fam); assert(v.pass, `${n} vs ${v.worst.name} ${v.worst.score}`); if (v.worst.score > worst.score) worst = { ...v.worst, of: n }; }- pass(`novelty: every demo vs every other demo passes (closest: ${worst.of} vs ${worst.name} ${worst.score})`);- const quoted = M.composePiece({ ...M.testMaterial(M.VOCAB.playful, { bars: 4 }), sections: [{ kind: "hook", bars: 2, harmony: ["c0"], groove: null, lead: ["G5:1 B5:.5 C6:.5 B5:1 G5:1", "E5:1 G5:.5 A5:.5 G5:1 E5:1"] }] });- const src = M.composePiece({ ...M.testMaterial(M.VOCAB.playful, { bars: 4 }), sections: [{ kind: "hook", bars: 2, harmony: ["c0"], groove: null, lead: ["D5:1 F#5:.5 G5:.5 F#5:1 D5:1", "B4:1 D5:.5 E5:.5 D5:1 B4:1"] }] });- const r = M.novelty(quoted, { src: () => src }); assert(!r.pass && r.rows[0].reusedFragments > 0, "a transposed quote must be caught");+ for (const n of Object.keys(M.SHIPPED)) { const fam = Object.values(M.PIECE_FAMILIES).find((f) => f.includes(n)) ?? [n], v = M.novelty(M.SHIPPED[n](), M.SHIPPED, fam); assert(v.pass, `${n} vs ${v.worst.name} ${v.worst.score}`); if (v.worst.score > worst.score) worst = { ...v.worst, of: n }; }+ pass(`novelty: every shipped piece vs every other passes (closest: ${worst.of} vs ${worst.name} ${worst.score})`);+ const mel = (title, key, src) => ({ title, seed: 1, tail: 1, harmony: [{ t: 0, name: key }], plan: { style: "minimalist", tempo: 110, meter: "4/4", sections: [{ id: "a", bars: 2, mood: "curious", key, mode: "major", melody: ["hook"], dyn: [0.6, 0.6] }] }, parts: [{ id: "m", inst: "marimba", role: "melody", notes: M.line(0, src, { role: "melody", bpb: 4 }) }] });+ const quoted = mel("quote", "C", "G5:1 B5:.5 C6:.5 B5:1 G5:1 | E5:1 G5:.5 A5:.5 G5:1 E5:1"), orig = mel("src", "G", "D5:1 F#5:.5 G5:.5 F#5:1 D5:1 | B4:1 D5:.5 E5:.5 D5:1 B4:1");+ const r = M.novelty(quoted, { src: () => orig }); assert(!r.pass && r.rows[0].reusedFragments > 0, "a transposed quote must be caught");pass(`novelty: a transposed 6-note quote of a shipped line fails (${r.rows[0].reusedFragments} reused fragments)`); }console.log(`music unit: ${ok.length} checks PASS in ${((Date.now() - t0) / 1000).toFixed(0)} s`);diff --git a/plugins/anidoodle/skills/anidoodle/engine/tools/music.mjs b/plugins/anidoodle/skills/anidoodle/engine/tools/music.mjsindex 47f1f14..2ced4df 100644--- a/plugins/anidoodle/skills/anidoodle/engine/tools/music.mjs+++ b/plugins/anidoodle/skills/anidoodle/engine/tools/music.mjs@@ -3,18 +3,16 @@// clipping on the way) and meters the DECODED file: integrated LUFS (BS.1770-4), LRA (EBU 3342),// true peak (4x), onsets/s (spectral flux), spectral centroid; plus note-data numbers.//-// <piece> is YOUR score, a module: path/to/score.ts#exportName (a Material, a Piece, or a function-// returning either); or the name of a shipped demo (listening references, never a film's score).+// <piece> is a shipped piece's name (node tools/music.mjs list), or YOUR score as a module:+// path/to/score.ts#exportName (a Piece, or a function returning one).//-// node tools/music.mjs vocab [style] # the style vocabularies: palette, grooves, harmony, melody, arrangement-// node tools/music.mjs check <piece> [--fit --seconds N] # everything: key/mode, warnings, master, ghost/reverb/masking guards, stems, novelty+// node tools/music.mjs list+// node tools/music.mjs check <piece> [--fit --seconds N] # everything: key/mode, master, ghost/reverb/masking guards, stems, novelty// node tools/music.mjs novelty <piece> [more ...] # vs every shipped piece (and pairwise when several); FAILS above the threshold or on a reused fragment-// node tools/music.mjs list # shipped demos and fixtures// node tools/music.mjs render <piece> <out.wav|out.mp3> [--seconds 45] [--flat] [--tempo 66] [--fit] [--loop] [--stems]-// node tools/music.mjs stems <piece> [--seconds 45] [--fit] # each part's stem RMS vs its target, flags > 3 dB off-// (--fit uses fitScore: the piece's refit, e.g. a composed score repeats its stretch section so it still ends on its outro;-// --loop renders a seamless loop, automatic for a plan.loop piece. LUFS alone once hid a sub 7-10 dB too hot:-// balance a mix by its stems, then master.)+// node tools/music.mjs stems <piece> [--seconds 45] [--fit] # each part's stem RMS vs the piece's stemTargets, flags > 3 dB off+// (--fit uses fitToDuration; --loop renders a seamless loop, automatic for a plan.loop piece. LUFS alone once hid+// a sub 7-10 dB too hot: balance a mix by its stems, then master.)// node tools/music.mjs meter <file.wav|file.mp4> [more files]// node tools/music.mjs samples <outdir> # the whole deliverable set + meters.json + .m4a// node tools/music.mjs score <piece> # the text score, bar by bar@@ -32,20 +30,20 @@ const load = async () => {return import("data:text/javascript;base64," + Buffer.from(r.outputFiles[0].text).toString("base64"));};-/** A piece by demo name, or from a module: "path.ts#export" (default export if no #). Material is composed. */+/** A piece by its shipped name, or from a module: "path.ts#export" (default export if no #). */const getPiece = async (M, ref) => {- if (!ref) throw new Error("name a piece: path/to/score.ts#export, or a demo (node tools/music.mjs list)");- const fromDemo = M.DEMOS[ref] ?? M.FIXTURES[ref];+ if (!ref) throw new Error("name a piece: path/to/score.ts#export, or a shipped piece (node tools/music.mjs list)");+ const fromDemo = M.PIECES[ref];let v;if (fromDemo) v = fromDemo;else {const [file, exp = "default"] = ref.split("#");- if (!existsSync(resolve(file))) throw new Error(`no demo or module "${ref}" (demos: node tools/music.mjs list)`);+ if (!existsSync(resolve(file))) throw new Error(`no piece or module "${ref}" (shipped pieces: node tools/music.mjs list)`);const r = await build({ entryPoints: [resolve(file)], bundle: true, write: false, format: "esm", platform: "neutral", target: "es2022", logLevel: "error" });const mod = await import("data:text/javascript;base64," + Buffer.from(r.outputFiles[0].text).toString("base64"));v = mod[exp]; if (v === undefined) throw new Error(`${file} has no export "${exp}" (exports: ${Object.keys(mod).join(", ")})`);}- const make = () => { const x = typeof v === "function" ? v() : v; return x && x.sections && x.chords ? M.composePiece(x) : x; };+ const make = () => { const x = typeof v === "function" ? v() : v; if (!x || !x.plan || !x.parts) throw new Error(`${ref} is not a Piece (plan, parts, harmony: references/music/README.md)`); return x; };return { make, name: ref, demo: Boolean(fromDemo) };};@@ -84,10 +82,10 @@ const onsetsFromData = (rendered) => {};const renderOne = (M, spec) => {- let piece = spec.make ? spec.make() : (M.DEMOS[spec.piece] ?? M.FIXTURES[spec.piece])();+ let piece = spec.make ? spec.make() : M.PIECES[spec.piece]();let tempo = spec.tempo ?? piece.plan.tempo;let form;- if (spec.fit) { const f = M.fitScore(piece, spec.seconds); piece = f.piece; tempo = f.tempo; form = `${f.form}: ${f.piece.plan.sections.map((x) => x.id).join(", ")}`; }+ if (spec.fit) { const f = M.fitToDuration(piece, spec.seconds); piece = f.piece; tempo = f.tempo; form = `${f.form}: ${f.piece.plan.sections.map((x) => x.id).join(", ")}`; }const opts = { seconds: spec.seconds, tempo };if (spec.flat) Object.assign(opts, { expressive: false, piano: M.PIANO_FLAT, flatVelocity: 0.6 });const loop = spec.loop || piece.plan.loop, go = () => (loop ? M.renderLoop(piece, SR) : M.renderPiece(piece, SR, opts));@@ -115,14 +113,12 @@ const main = async () => {const [cmd, ...args] = process.argv.slice(2);const M = await load();const flag = (k) => args.includes(k), val = (k, d) => { const i = args.indexOf(k); return i >= 0 ? Number(args[i + 1]) : d; };- if (cmd === "list") { console.log("demos (listening references and the novelty corpus, never a film's score):\n " + Object.keys(M.DEMOS).join("\n ") + "\nfixtures (tests):\n " + Object.keys(M.FIXTURES).join("\n ")); return; }- if (cmd === "vocab") { if (args[0] === "--md") vocabMarkdown(M); else printVocab(M, args[0]); return; }- if (cmd === "calibrate") { calibrate(M); return; }+ if (cmd === "list") { console.log(Object.keys(M.PIECES).join("\n")); return; }if (cmd === "novelty") {const refs = args.filter((a) => !a.startsWith("--") && !/^[\d.]+$/.test(a)), pcs = [];for (const ref of refs) pcs.push(await getPiece(M, ref));let fail = false;- for (const pc of pcs) { const fam = Object.values(M.DEMO_FAMILIES).find((f) => f.includes(pc.name)) ?? [pc.name]; fail = !printNovelty(M, pc.name, M.novelty(pc.make(), M.DEMOS, fam, val("--threshold", undefined)), "shipped pieces") || fail; }+ for (const pc of pcs) { const fam = Object.values(M.PIECE_FAMILIES).find((f) => f.includes(pc.name)) ?? [pc.name]; fail = !printNovelty(M, pc.name, M.novelty(pc.make(), M.SHIPPED, fam, val("--threshold", undefined)), "shipped pieces") || fail; }if (pcs.length > 1) { // pairwise: scores meant for different products must not be siblings eitherconst corpus = Object.fromEntries(pcs.map((p) => [p.name, p.make]));for (const pc of pcs) fail = !printNovelty(M, pc.name, M.novelty(pc.make(), corpus, [pc.name], val("--threshold", undefined)), "each other") || fail;@@ -131,10 +127,10 @@ const main = async () => {}if (cmd === "check") {const pc = await getPiece(M, args[0]); let piece = pc.make(), tempo = piece.plan.tempo, seconds = val("--seconds", undefined);- if (flag("--fit")) { const f = M.fitScore(piece, seconds); piece = f.piece; tempo = f.tempo; }+ if (flag("--fit")) { const f = M.fitToDuration(piece, seconds); piece = f.piece; tempo = f.tempo; }const r = piece.plan.loop ? M.renderLoop(piece, SR) : M.renderPiece(piece, SR, { seconds, tempo });const ok = [report(M, r, piece), printStems(M, piece, tempo, seconds)?.ok !== false];- if (!pc.demo) { const fam = [args[0]]; ok.push(printNovelty(M, args[0], M.novelty(piece, M.DEMOS, fam), "shipped pieces")); }+ if (!pc.demo) { const fam = [args[0]]; ok.push(printNovelty(M, args[0], M.novelty(piece, M.SHIPPED, fam), "shipped pieces")); }console.log(ok.every(Boolean) ? "CHECK PASS: now a human listens (an mp3 or wav on a page)" : "CHECK FAIL: fix the items above, then run check again");if (!ok.every(Boolean)) process.exitCode = 1; return;}@@ -153,7 +149,7 @@ const main = async () => {}if (cmd === "stems") {const [name] = args; let piece = (await getPiece(M, name)).make(), tempo = piece.plan.tempo, seconds = val("--seconds", undefined);- if (flag("--fit")) { const f = M.fitScore(piece, seconds); piece = f.piece; tempo = f.tempo; }+ if (flag("--fit")) { const f = M.fitToDuration(piece, seconds); piece = f.piece; tempo = f.tempo; }printStems(M, piece, tempo, seconds); return;}if (cmd === "meter") { for (const f of args) { const m = M.measure(decode(f), SR), ff = ffmpegEbu(f); console.log(basename(f), `LUFS ${fmt(m.lufs)} (ffmpeg ${fmt(ff.I)}) LRA ${fmt(m.lra)} (ffmpeg ${fmt(ff.LRA)}) TP ${fmt(m.dbtp)} dBTP (ffmpeg ${fmt(ff.TP)}) onsets/s ${fmt(m.onsetsPerS, 2)} centroid ${fmt(m.centroidHz, 0)} Hz (energy-wtd ${fmt(m.centroidEnergyHz, 0)}) dur ${fmt(m.durationS, 2)} lastOnset ${fmt(m.lastOnsetS, 2)}`); } return; }@@ -211,80 +207,24 @@ const main = async () => {}};-const calibrate = (M) => {- const trim = {}, fix = {};- for (const v of Object.values(M.VOCAB)) {- if (v.calibrated) continue; trim[v.id] = {}; fix[v.id] = {}; M.VOCAB_TARGET_FIX[v.id] = {};- for (let pass = 0; pass < 3; pass++) {- M.VOCAB_TRIM[v.id] = trim[v.id];- const b = M.measureStems(M.composePiece(M.testMaterial(v)), STEM_SR);- for (const r of b.rows) if (r.offDb !== null && Number.isFinite(r.offDb)) trim[v.id][r.id] = +Math.max(-12, Math.min(12, (trim[v.id][r.id] ?? 0) - r.offDb)).toFixed(1); // capped: past 12 dB the gain is not the problem- if (pass === 2) { for (const r of b.rows) if (r.offDb !== null && Math.abs(r.offDb) > 1) fix[v.id][r.id] = +r.offDb.toFixed(1);- console.log(v.id.padEnd(14), b.rows.filter((r) => r.offDb !== null).map((r) => `${r.id} ${r.offDb >= 0 ? "+" : ""}${r.offDb.toFixed(1)}`).join(" ")); }- }- }- const file = join(here, "../src/canvas-core/music/vocabTrim.ts"), head = readFileSync(file, "utf8").split("export const VOCAB_TRIM")[0], j = (x) => JSON.stringify(x, null, 1).replace(/"(\w+)":/g, "$1:");- writeFileSync(file, `${head}export const VOCAB_TRIM: Record<string, Partial<Record<Slot, number>>> = ${j(trim)};\n/** Where a 12 dB trim could not reach the target (long-decaying plucks read low as active RMS), the target moves to where the voice sits. */\nexport const VOCAB_TARGET_FIX: Record<string, Partial<Record<Slot, number>>> = ${j(fix)};\n`);- console.log(`wrote ${file}`);-};--const printVocab = (M, id) => {- if (!id) { for (const v of Object.values(M.VOCAB)) console.log(`${v.id.padEnd(15)} ${v.name}: ${v.atmosphere}\n${"".padEnd(16)}grooves: ${v.grooves.join(", ") || "none (no drums)"} | moods: ${v.moods.join(", ")} | ${v.tempo.join("-")} bpm ${v.meters.join(" ")}`);- console.log("\ngroove families:"); for (const [k, d] of Object.entries(M.GROOVE_FAMILIES)) console.log(` ${k.padEnd(10)} ${d}`);- console.log("\nsection kinds:"); for (const [k, d] of Object.entries(M.KINDS)) console.log(` ${k.padEnd(10)} ${d.what}`); return; }- const v = M.VOCAB[id]; if (!v) throw new Error(`no style "${id}" (have: ${Object.keys(M.VOCAB).join(", ")})`);- console.log(`${v.name} (${v.id}): ${v.atmosphere}\ntempo ${v.tempo.join("-")} bpm, meters ${v.meters.join(" ")}, swing ${v.swing.join("-")}, moods ${v.moods.join(", ")}`);- const eff = (slot, x) => +(x.gainDb + (M.VOCAB_TRIM[v.id]?.[slot] ?? 0)).toFixed(1), tgt = (slot) => (v.stemTargets[slot] === undefined ? "-" : +(v.stemTargets[slot] + (M.VOCAB_TARGET_FIX[v.id]?.[slot] ?? 0)).toFixed(1));- console.log("palette (slot: instrument, gain dB, stem target dB):"); for (const [slot, x] of Object.entries(v.palette)) console.log(` ${slot.padEnd(8)} ${x.inst.padEnd(10)} ${String(eff(slot, x)).padStart(5)} ${tgt(slot)} dB${Object.keys(v.alternates[slot] ?? {}).length ? ` alternates: ${Object.entries(v.alternates[slot]).map(([n, a]) => `${n} (${a.inst}, ${a.gainDb} dB)`).join(", ")}` : ""}`);- for (const [slot, alts] of Object.entries(v.alternates)) if (!v.palette[slot]) console.log(` ${slot.padEnd(8)} (no default) alternates: ${Object.entries(alts).map(([n, a]) => `${n} (${a.inst}, ${a.gainDb} dB)`).join(", ")}`);- console.log(`stem targets ${v.calibrated ? "calibrated on a listened score" : "are starting numbers (uncalibrated: flags are advisory until a human listens)"}`);- console.log(`grooves: ${v.grooves.map((g) => `${g} (${M.GROOVE_FAMILIES[g]})`).join("\n ") || "none"}`);- for (const [k, x] of Object.entries(v.harmony)) console.log(`harmony.${k}: ${Array.isArray(x) ? x.join(", ") : x}`);- for (const [k, x] of Object.entries(v.melody)) console.log(`melody.${k}: ${x}`);- for (const [k, x] of Object.entries(v.arrangement)) console.log(`arrangement.${k}: ${x}`);- console.log(`avoid: ${v.avoid}`);-};--/** references/music/styles/vocabularies.md, generated from the data so the page never drifts from the code. */-const vocabMarkdown = (M) => {- const o = ["# Style vocabularies", "", "> GENERATED by `node tools/music.mjs vocab --md` from `engine/src/canvas-core/music/vocab.ts` and `vocabMore.ts`. Do not edit by hand.", "> A style is a vocabulary: sound, grooves, harmony language, melody rules, arrangement grammar. It never", "> contains notes. You compose the notes ([../compose.md](../compose.md)).", "",- "| Style | Atmosphere | Tempo, meters | Moods | Grooves |", "|---|---|---|---|---|"];- for (const v of Object.values(M.VOCAB)) o.push(`| \`${v.id}\` | ${v.atmosphere} | ${v.tempo.join("-")} bpm; ${v.meters.join(", ")} | ${v.moods.join(", ")} | ${v.grooves.join(", ") || "none (no drums)"} |`);- o.push("", "## Groove families", "", "Pick a family and its knobs (`density`, `variation`, `fill`, `accent`); the seed varies every bar. Or write the drum bars yourself.", "");- for (const [k, d] of Object.entries(M.GROOVE_FAMILIES)) o.push(`- \`${k}\`: ${d}`);- o.push("", "## Section kinds (the arrangement grammar)", "", "A kind decides which layers may sound; your lines sound only where you write them.", "");- for (const [k, d] of Object.entries(M.KINDS)) o.push(`- \`${k}\` (drums: ${d.drums ?? "none"}, bass: ${d.bass ? "yes" : "no"}): ${d.what}`);- for (const v of Object.values(M.VOCAB)) {- o.push("", `## \`${v.id}\`: ${v.name}`, "", `${v.atmosphere}. Tempo ${v.tempo.join("-")} bpm, meters ${v.meters.join(", ")}, swing ${v.swing.join("-")}.`, "", "| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |", "|---|---|---|---|---|");- for (const [slot, x] of Object.entries(v.palette)) o.push(`| ${slot} | \`${x.inst}\` | ${+(x.gainDb + (M.VOCAB_TRIM[v.id]?.[slot] ?? 0)).toFixed(1)} | ${v.stemTargets[slot] === undefined ? "-" : +(v.stemTargets[slot] + (M.VOCAB_TARGET_FIX[v.id]?.[slot] ?? 0)).toFixed(1)} | ${Object.entries(v.alternates[slot] ?? {}).map(([n, a]) => `${n} (\`${a.inst}\`, ${a.gainDb} dB)`).join(", ") || "-"} |`);- o.push("", `Stem targets: ${v.calibrated ? "calibrated on a listened score." : "starting numbers from a neutral test signal (advisory until a human listens)."}`, "");- o.push(`- **Harmony language.** Modes: ${v.harmony.modes.join(", ")}. Qualities: ${v.harmony.qualities}. Tendencies: ${v.harmony.tendencies}. Harmonic rhythm: ${v.harmony.rhythm}. Voicing: ${v.harmony.voicing}. Tension and release: ${v.harmony.tension}.`);- o.push(`- **Melody.** Range ${v.melody.range}. Contour: ${v.melody.contour}. Density: ${v.melody.density}. Motif: ${v.melody.motif}.`);- o.push(`- **Arrangement.** ${v.arrangement.shape}. Transitions: ${v.arrangement.transitions}. Endings: ${v.arrangement.endings}.`);- o.push(`- **Grooves:** ${v.grooves.join(", ") || "none"}. **Avoid:** ${v.avoid}.`);- }- console.log(o.join("\n"));-};--/** Key/mode problems, composer warnings, the master (did the peak cap stop it short?), and the guards. Returns pass. */+/** Key/mode problems, the master (did the peak cap stop it short?), and the guards. Returns pass. */const report = (M, r, piece) => {- let ok = true; const probs = M.planProblems(piece), warn = piece.warnings ?? [];+ let ok = true; const probs = M.planProblems(piece);for (const p of probs) console.log(`PROBLEM ${p}`); ok = ok && !probs.length;- for (const w of warn) console.log(`WARNING ${w}`);const lu = M.loudness([r.L, r.R], SR).integrated, tp = M.truePeak([r.L, r.R]).dbtp, target = r.masterMode === "dense" ? -14 : r.masterMode === "gentle" ? -16 : NaN;console.log(`master ${r.masterMode}: ${fmt(lu)} LUFS (target ${fmt(target)}), true peak ${fmt(tp, 2)} dBTP`);if (lu < target - 0.5) console.log(`NOTE the master stopped ${fmt(target - lu)} dB short of its target: the true-peak ceiling (-1 dBTP) capped the gain. Peaks are a composing problem: stagger the bass under the loudest downbeat, roll the big chord, don't double the climax note, soften the one loudest hit.`);const g = M.guardReport(r, SR, r.L.length / SR);console.log(`guards ghost ${g.ghost.pass ? "PASS" : "FAIL"} (${g.ghost.failures}/${g.ghost.windows} windows formless) | reverb ${g.reverb.pass ? "PASS" : "FAIL"} (worst tail ${fmt(g.reverb.worstDb)} dB vs dry) | masking ${g.masking ? `${g.masking.pass ? "PASS" : "FAIL"} (melody clear in ${Math.round(g.masking.shareOfBarsClear * 100)} % of bars, worst ${fmt(g.masking.worstMarginDb)} dB)` : "n/a (no melody)"}`);- if (g.masking && !g.masking.pass) console.log(`FIX masking: the melody must beat every other part in 500 Hz-4 kHz by 3 dB in 80 % of its bars. Guards win over stem targets: raise the lead (levels.lead, up to +${M.LEAD_HEADROOM_DB} dB over its target is allowed), thin or lower what sits in its register, or move it.`);+ if (g.masking && !g.masking.pass) console.log(`FIX masking: the melody must beat every other part in 500 Hz-4 kHz by 3 dB in 80 % of its bars. Guards win over stem targets: raise the lead (its part gainDb, up to +${M.LEAD_HEADROOM_DB} dB over its target is allowed), thin or lower what sits in its register, or move it.`);if (!g.ghost.pass) console.log("FIX ghost: sustained sound with too few onsets and no cadence. Add a rhythmic layer or motif, shorten tails, cadence.");- if (!g.reverb.pass) console.log("FIX reverb: the late tail sits too close to the dry sound. Lower sends (voices' send) or the space mood control.");+ if (!g.reverb.pass) console.log("FIX reverb: the late tail sits too close to the dry sound. Lower the parts' send.");return ok && g.ghost.pass && g.reverb.pass && (!g.masking || g.masking.pass);};const printNovelty = (M, name, v, what) => {console.log(`novelty: ${name} vs ${v.rows.length} ${what} (fail above ${v.threshold}, or on any reused 6-note melody fragment)`);for (const r of v.rows.slice(0, 5)) console.log(` ${r.name.padEnd(22)} ${r.score.toFixed(3)} ${r.reusedFragments ? `REUSED ${r.reusedFragments} fragment(s) ` : ""}${Object.entries(r.by).map(([k, x]) => `${k} ${x}`).join(" ")}`);- console.log(v.pass ? "novelty PASS" : `novelty FAIL: too close to ${v.worst.name}. Change what the numbers point at (the lead's rhythm, the contour, the groove, the chord colours, the form), not just the key.`);+ console.log(v.pass ? "novelty PASS" : `novelty FAIL: too close to ${v.worst.name}. Change what the numbers point at (the lead's rhythm, the contour, the groove, the chord colours), not just the key.`);console.log(" (idioms are fine: a ii-V-I, a plagal cadence, a two-chord vamp are vocabulary. What fails is the same music: a multi-bar progression WITH its rhythm, groove, contour and form, or a quoted melody.)");return v.pass;};@@ -293,13 +233,12 @@ const printNovelty = (M, name, v, what) => {const STEM_SR = 24000;const printStems = (M, piece, tempo, seconds) => {const b = M.measureStems(piece, STEM_SR, { tempo, seconds });- console.log(`stem balance: ${piece.title} (unmastered stem RMS over active samples vs target, +-${b.tolDb} dB; the lead may sit up to +${b.headroom.lead ?? 0} dB more for the masking guard; targets already include your mood controls' shifts)`);+ console.log(`stem balance: ${piece.title} (unmastered stem RMS over active samples vs target, +-${b.tolDb} dB; the lead may sit up to +${b.headroom.lead ?? 0} dB more for the masking guard)`);for (const r of b.rows) console.log(` ${r.id.padEnd(9)} ${fmt(r.rmsDb).padStart(6)} dB ${r.targetDb === null ? "(no target)" : `target ${fmt(r.targetDb).padStart(6)} off ${(r.offDb >= 0 ? "+" : "") + fmt(r.offDb)} ${r.ok ? "ok" : `FLAG: ${r.offDb > 0 ? "too hot" : "too quiet"}`}`}`);if (!Object.keys(piece.stemTargets ?? {}).length) console.log(" (this piece declares no stemTargets)");- const cal = M.VOCAB[piece.plan.style]?.calibrated !== false;- console.log(b.pass ? "stems PASS" : `stems ${cal ? "FAIL" : "OFF TARGET (advisory: this style's targets are uncalibrated starting numbers)"}: fix the part gains (Material.levels), then master. LUFS alone once hid a sub 7-10 dB too hot.`);- if (!b.pass && cal) process.exitCode = 1;- return { ...b, ok: b.pass || !cal };+ console.log(b.pass ? "stems PASS" : "stems FAIL: fix the part gains (gainDb), then master. LUFS alone once hid a sub 7-10 dB too hot.");+ if (!b.pass) process.exitCode = 1;+ return { ...b, ok: b.pass };};/** Piano realism probes (ADVISORY 4.1): single notes, matched loudness where it matters. */diff --git a/plugins/anidoodle/skills/anidoodle/engine/tools/render.mjs b/plugins/anidoodle/skills/anidoodle/engine/tools/render.mjsindex 3b2448a..ccbc8d8 100644--- a/plugins/anidoodle/skills/anidoodle/engine/tools/render.mjs+++ b/plugins/anidoodle/skills/anidoodle/engine/tools/render.mjs@@ -87,7 +87,7 @@ if (a) { // the audio report: loudness and true peak, and the score's fit againsif (lu < -14.5 && tp > -1.1) console.log(` NOTE the -1 dBTP ceiling held the gain ${(-14 - lu).toFixed(1)} dB under -14 LUFS (the cross-platform target): peaks are a composing problem (stagger the bass under the loudest downbeat, roll the big chord); a launch template bed takes \`limit: true\``);if (meta.score) { const off = (meta.score.tempo / meta.bpm - 1) * 100;console.log(`score: ${meta.score.tempo.toFixed(2)} bpm (${meta.score.form}); the picture's grid is ${meta.bpm} bpm (${off >= 0 ? "+" : ""}${off.toFixed(2)} %)`);- if (!meta.score.grid && Math.abs(off) > 2) console.log(" NOTE past 2 % the score's downbeats drift from meta.bpm: a 1-bar stretch section, or the Material's `tail`, lets the fit land nearer it"); }+ if (!meta.score.grid && Math.abs(off) > 2) console.log(" NOTE past 2 % the score's downbeats drift from meta.bpm: a repeatable or optional section, or the piece's `tail`, lets the fit land nearer it"); }}mkdirSync(join(out, ".."), { recursive: true });diff --git a/plugins/anidoodle/skills/anidoodle/references/music/README.md b/plugins/anidoodle/skills/anidoodle/references/music/README.mdindex 7ff0b0a..da02f03 100644--- a/plugins/anidoodle/skills/anidoodle/references/music/README.md+++ b/plugins/anidoodle/skills/anidoodle/references/music/README.md@@ -5,25 +5,10 @@ and synthesizes them in code. No samples, no recordings, no licensed audio, everwhat you make, so every choice is a number, every number is measured, and a human hears 8 secondsbefore anything ships.-Code: `engine/src/canvas-core/music/`. Tool: `engine/tools/music.mjs`.--**Start here: [`compose.md`](compose.md).** It takes you from a brief to an original score. A style-is a vocabulary: sound, grooves, harmony language, melody rules, arrangement grammar. It is never-notes. You compose every note, and nothing is filled in for you. There is no default style.--Pages:-- [`compose.md`](compose.md): the workflow, the material format, craft, and the never-reuse rule.-- [`styles/vocabularies.md`](styles/vocabularies.md): all 21 style vocabularies, the 15 groove- families and the section kinds. It is generated from the code.-- [`styles/lofi-electronic.md`](styles/lofi-electronic.md): the lo-fi electronic vocabulary in- depth, and the stem balance meter.-- [`styles/music-box.md`](styles/music-box.md): the original music-box recipe's sound numbers and- the scar story behind the guards.--**Demos are not scores.** The pieces in `pieces/` (samplers, families, nocturne, our launch scores)-were written to prove the synth and the meters, and one of them is our own film's score. They are-listening references and the novelty corpus (`node tools/music.mjs list`). A film never plays them:-`node tools/music.mjs novelty` fails a score that sounds like them or quotes them.+Code: `engine/src/canvas-core/music/`. Tool: `engine/tools/music.mjs`. The old music-box recipe+lives on, verbatim, as the default style preset: [`styles/music-box.md`](styles/music-box.md).+Sound effects on picture (clicks, whooshes, impacts, placed by film frame over the score) are in+[`sound-design.md`](sound-design.md).## The pipeline@@ -36,16 +21,18 @@ MusicPlan + notes (you write) -> perform -> instruments (one stem per part)harmony list.- The plan names:- one **style**;- - a tempo and a meter (2/4, 3/4, 4/4, 5/4, 6/8, 7/8, 9/8, 12/8);+ - a tempo and a meter (3/4, 4/4, 6/8, 12/8);- **sections**, each with a mood (or a blend `[a, b, w]`), a key and mode, the melody types,a dynamic level `[start, end]` 0..1, and an ending;- `repeatable` / `optional` / `pickup` / `variations` flags, which let it fit any length.- - Notes are written in a bar-checked notation. A bar that doesn't add up to the meter throws:+ - Notes are written in a bar-checked notation. A bar that doesn't add up to the meter throws,+ the last one too (a line that ends mid-bar writes its rest: `C2:3 r:1`). A one-bar sting on any+ beat says so with `hit: true`:```ts- line(<start beat>, "<NOTE>:<beats> <NOTE>:<beats> | [<NOTE> <NOTE>]:<beats>@<vel> | r:<beats>", { role, bpb })+ line(3, "C5:2 Bb4:.5 Ab4:.5 | Bb4:2 Eb4:1 | [Ab1 Eb2 Ab2]:[email protected]", { role: "melody", bpb: 3 })```- Roles: `melody`, `inner`, `bass`, `accomp`, `color`, `drum`.- - Nothing generates notes. **You compose** (compose.md):+ - Generators may draft. **You compose**:- real harmony and voice-leading;- a memorable motif and phrases that ask and answer;- cadences.@@ -72,16 +59,6 @@ MusicPlan + notes (you write) -> perform -> instruments (one stem per part)| `fmBell`, `ePiano` | 2-operator FM || `pulse`, `triangle`, `noiseDrum` | NES-style chip voices || `kick`, `snare`, `hat`, `bass`, `vinyl` | Drums, bass and texture |- | `warmPad`, `softPluck`, `sub` | The lo-fi electronic kit (`lofiKit.ts`): detuned-saw pad, filtered pluck with ping-pong delay, sine sub |- | `organ` | Drawbar ranks (harmonics 1 2 3 4 6 8), chorus, tremulant |- | `brass` | PolyBLEP saw, a low-pass that opens with loudness, a pitch scoop, delayed vibrato |- | `woodwind` | Flute (sine + breath noise) or `reed: true` clarinet (odd harmonics) |- | `choir` | Detuned saws through vowel formants (`vowel`: a o u e i). Texture, never a lead |- | `timpani` | Tuned membrane modes, a pitch settle, a mallet thump (`pitch` tunes it in a drum lane) |- | `leadSynth` | Mono saw + square, portamento, a filter envelope, blooming vibrato |- | `bowedSolo` | One bowed voice (violin, or `cello: true`): vibrato, bow noise, body resonances |-- The acoustic voices are procedural approximations. A human listens before one carries a film.4. **Room.** The style chooses it:- music box: one reflection, no tail;- nocturne and lullaby: a small room;@@ -90,20 +67,13 @@ MusicPlan + notes (you write) -> perform -> instruments (one stem per part)5. **Master.**- **Gentle styles:** one static gain to **-16 LUFS**, true peak <= -1 dBTP, never a compressor.If the peak blocks the gain, the loudness goes down. The cure is musical (see "Peaks" below).- - **Dense styles** (lofiElectronic, lofi, drive, house, synthwave, hipHop, rock, chiptune): **-14 LUFS** through a look-ahead true-peak limiter, then a static trim if an inter-sample peak still passes -1 dBTP.+ - **Dense styles** (chiptune, lo-fi, drive): **-14 LUFS** through a look-ahead true-peak limiter.A film's `audio` is `filmAudio(piece, seconds)`, which returns `(sampleRate) => [L, R]` at exactly-the film's length. It fits the score first (`fitScore`, below), so the music ends on its phrase at-the last frame and is never chopped. Any film mix that renders a score (sound effects included) must-fit it the same way. `engine/src/canvas-core/score.ts` is an empty skeleton: `filmScore(material,-fps, frames)` composes your material and fits it.+the film's length. `engine/src/canvas-core/score.ts` is the scaffold example.## Any length, never hard-coded-`fitScore(piece, seconds)` first calls the piece's own `refit(seconds)` if it has one. A composed-piece repeats or drops its `stretch` section, so it still lands on its outro. Then it runs-`fitToDuration`.-`fitToDuration(piece, seconds)` tries every form:- with some `optional` sections dropped (dropping music costs more than nudging the tempo);- with the `repeatable` group restated 0..n times, as "A B A B" or "A A B" (restatements take the@@ -114,42 +84,34 @@ It picks the form whose tempo is closest to the written one. If no full form fitthe piece's `shortForm`. A section's `pickup` travels with it: wherever a section lands, its ownupbeat leads into it.-A hand-written piece with a short form, repeatable sections and optional sections can fit anything-from a quarter of its length to many times it, and it still ends on its cadence.+Example: the nocturne "Window Light" gives+- the short form (the 8-second phrase, restated) at 15 s;+- the full piece at 45 s;+- intro, theme, theme (in octaves), build, coda at 60 s;+- six theme/climax cycles with rotating variations at 180 s.-## Styles (21) and moods (21)+## Styles (11) and moods (15)-Both are rows of numbers in `tables.ts`. The vocabularies are in `vocab.ts` and `vocabMore.ts`, and-[`styles/vocabularies.md`](styles/vocabularies.md) is generated from them. A brief names rows,-never adjectives. Each row stays `unconfirmed` until a human has listened to 8 seconds of it; the-listener's words then go into `confirmedBy`.+Both are rows of numbers in `tables.ts`. A brief names rows, never adjectives. Each row stays+`unconfirmed` until a human has listened to 8 seconds of it; the listener's words then go into+`confirmedBy`.-| Style | Atmosphere | Master |-|---|---|---|-| lofiElectronic | chill, upbeat, clean electronic | dense |-| lofi | dusty lo-fi hip-hop (e-piano, vinyl) | dense |-| drive | driving electronic, four-on-the-floor | dense |-| house | euphoric house / EDM | dense |-| synthwave | neon-retro, gated snare, soaring lead | dense |-| hipHop | head-nod or dark trap, heavy 808 | dense |-| rock | band energy, driven guitars, tight kit | dense |-| chiptune | 8-bit, two pulses, triangle, noise | dense |-| cinematic | string swells, ostinatos, harp and bell colour | gentle |-| orchestral | heroic/epic: brass theme, string engine, choir, timpani | gentle |-| suspense | drones, heartbeat pulse, bowed harmonics, stingers | gentle |-| ambient | airy, spacious, bells and pads | gentle |-| choral | voices in parts, organ, bells | gentle |-| folk | tender acoustic: guitar, piano, harp, brushes | gentle |-| world | drone, modal melody, hand percussion, odd meters | gentle |-| playful | bouncy mallets, skipping kit | gentle |-| jazz | swing ride, walking bass, comping | gentle |-| nocturne | solo piano, rubato | gentle |-| minimalist | interlocking ostinatos | gentle |-| lullaby | soft, rocking, nothing percussive | gentle |-| musicBox | clockwork plucks, no sustain | gentle |+| Style | Tempo, meter | Natural moods | Master |+|---|---|---|---|+| musicBox (default) | 110-130, 12/8 | joy, curious, tender, playful, wistful | gentle |+| nocturne (piano) | 50-72, 3/4 or 6/8 | tender, melancholy, wistful, romantic | gentle |+| cinematic | 60-120 | awe, triumph, melancholy, tension, hopeful | gentle |+| lullaby | 60-75, 3/4 or 6/8 | tender, calm | gentle |+| folk | 80-120, 6/8, 3/4, 4/4 | calm, wistful, joy, nostalgic | gentle |+| minimalist | 100-140 | curious, tension, awe | gentle |+| jazz | 90-180, swing | playful, nostalgic, romantic, curious | gentle |+| ambient | 50-80 | awe, calm, dread (highest ghost risk) | gentle |+| chiptune | 120-160 | joy, playful, drive, tension | dense |+| lofi | 70-90, swing 55-62 % | nostalgic, calm, wistful | dense |+| drive | 110-140 | drive, triumph, tension, awe | dense |Moods: joy, playful, tender, wistful, melancholy, hopeful, curious, tension, dread, awe, triumph,-drive, calm, nostalgic, romantic, anger, eerie, mischief, heroic, sensual, grief.+drive, calm, nostalgic, romantic.- Each row has columns for:- modes and tempo;- harmonic rhythm and lead register;@@ -174,18 +136,34 @@ per-mode guards are in `theory.ts`.Melody types (9): arpeggio, stepwise, hook, ostinato, drone, call and response, counter-melody,sequence, theme transformation.-## How to write a score--Follow [`compose.md`](compose.md). In short:-1. brief -> numbers (length, picture beats, feeling);-2. one style + one mood + five mood controls;-3. compose YOUR harmony, bass lines, motif(s), groove choice and form as `Material`;-4. `node tools/music.mjs check <file>.ts#<export>` must PASS (key, master, ghost/reverb/masking guards, stems, novelty);-5. `node tools/music.mjs render <file>.ts#<export> out.wav` (use wav for loops: mp3 is not gapless);-6. 8 seconds (then the whole piece) to a human, as an mp3 on a page.--Hand-written `Piece`s (the nocturne, the samplers) are still valid for styles without a vocabulary-builder. Write them with `line()` and render them with `renderPiece`.+## How to plan a score++1. **Spot the film.** Find its 3-5 true sync points, and an arc per section (for example tender, then+ swelling, then a sudden hush at about 2/3, then a soft close).+2. **Pick one style.** Give each section a mood, a key and a mode.+3. **Write the motif first.** A 2-5 note cell with its own rhythm. Then build the harmony under it,+ with voice-leading by step. Then the phrases:+ - the question ends off the tonic;+ - the answer ends on it, straight away;+ - the high point falls in the second half of the phrase.+4. **Arrange.** Add density, not length (more notes, never longer notes). Let the motif return:+ transformed, at the climax, and at the close.+5. **Print the score and check it.** `<piece>` is a shipped piece's name or your own module,+ `path/to/score.ts#export` (a `Piece`, or a function returning one):+ ```+ node tools/music.mjs score <piece>+ node tools/music.mjs check <piece> --fit --seconds 45 # key/mode, master, guards, stems, novelty: must PASS+ node tools/music.mjs render <piece> out.wav --seconds 45 --fit+ ```+ - **Stems.** Give the piece `stemTargets` (each part's RMS in dBFS over the samples where it+ plays) and `node tools/music.mjs stems <piece>` flags any part more than 3 dB off. Balance by+ stems, then master: integrated LUFS once looked right while a sub sat 7-10 dB too hot.+ - **Novelty.** Your score must not sound like one we shipped. `node tools/music.mjs novelty+ <piece>` compares its rhythm, contour, intervals, drums and chord colours with every shipped+ piece and fails above 0.5, or on any reused 6-note melody fragment, transposed or not.+ - **Loops.** A `plan.loop` piece renders as a seamless loop (`--loop`): its tail folds back onto+ the start. Ship loops as wav; mp3 padding clicks at the seam.+6. **8 seconds to a human.** Include the most important mood change.**Peaks are a composing problem.** Octaves in both hands landing on one downbeat make a true peakthat caps a gentle master. Fix it in the notes:diff --git a/plugins/anidoodle/skills/anidoodle/references/music/compose.md b/plugins/anidoodle/skills/anidoodle/references/music/compose.mddeleted file mode 100644index 454e570..0000000--- a/plugins/anidoodle/skills/anidoodle/references/music/compose.md+++ /dev/null@@ -1,238 +0,0 @@-# Compose: from a brief to an original score--A style is a **vocabulary**. It gives you:-- sound: voices, levels and fx;-- groove families;-- a harmony language;-- melody rules;-- an arrangement grammar.--It never gives you notes. **You write every note**:-- the chords and their voicings;-- the bass lines;-- the motifs and lines;-- the form.--The engine refuses to fill gaps. Missing harmony, melody, grooves or form is an error that tells you-what to compose. The engine then performs, synthesizes, mixes and masters, deterministically, in code.--> **Never reuse shipped material.** The demos (`node tools/music.mjs list`) and our own film scores-> are listening references and the novelty corpus. They are never a film's score or a template. Don't-> copy them, transpose them or re-rhythm them. `node tools/music.mjs novelty` fails a score that-> sounds like any shipped piece, or that quotes a 6-note fragment of one (transposed or not).->-> **Idioms are fine.** A ii-V-I, a plagal amen, a two-chord vamp, a I-bVII-IV are vocabulary. The-> style pages name them so you can use them. What is not fine is reusing the same music: a-> multi-bar progression together with its rhythm, groove, contour and form, or a quoted melody.->-> Why this rule exists: a "new" example once changed the key, chords and pitches of the launch-> score but kept its rhythms, contour, drums and form. It was heard at once as the same song. The-> novelty fingerprint weighs exactly those things.--## The workflow--1. **Read the brief as numbers.** Write down:- - the use case (launch film, explainer, loop for a site, game, ad);- - the length in seconds, and whether it must loop;- - 3-5 picture beats with their times (the reveal, the claim, the cut to the end card);- - the words the person used for the feeling.-2. **Pick one style and one mood.** Styles:- ```- node tools/music.mjs vocab- node tools/music.mjs vocab <style>- ```- For the details, see [styles/vocabularies.md](styles/vocabularies.md). The mood is a row in- `tables.ts` (see the README's mood list). Then set the five **mood controls**, each 0..1, where- 0.5 = the calibrated palette:-- | Control | What it moves |- |---|---|- | `energy` | groove density, drum level, sidechain depth, dynamics |- | `warmth` | filters darker, tape drive and wow, a little more bass |- | `brightness` | filters and pluck brightness open, hats up |- | `tension` | pad detune wider, string attacks shorter, lead decays shorter |- | `space` | reverb sends, delay mix, pad release |-- Controls change the sound only. Harmonic tension is yours to write (step 3).-3. **Compose the harmony.** Work inside the style's harmony language: its modes, chord qualities,- tendencies and voicing rule. Decide the key and mode from the mood, not from habit.- - Write a progression **for this brief**. Choose its length (2, 3, 4, 5, 6 or 8 bars) and its- harmonic rhythm (one chord per bar, two per bar, or one per two bars) on purpose.- - Voice each chord yourself. Move the voices by step and hold common tones. The bass owns the- root.- - Write each chord's bass line (one bar) in the style's bass idiom: held root, root and fifth,- walking, offbeat 8ths, a syncopated 808 figure. Make the rhythm YOURS.- - **Tension and release as a curve.** Stable (tonic), moving away (subdominant, relative,- borrowed), leaning (dominant, suspension, pedal), home. Put home on the picture's key beat.-4. **Compose the motif(s).** A motif is 2-5 notes with its own rhythm. Invent the rhythm first:- - Which beats does it avoid?- - Does it start on an upbeat?- - Where is the long note?-- Then the pitches: the contour, one leap, then steps back.-- Develop the motif. Don't photocopy it:- - **repeat**, then **vary**: change the last interval, displace it by an eighth, extend it;- - **sequence**: the same shape a step or a third higher;- - **call and response**: the question ends off the tonic, the answer lands on it, or another- instrument answers;- - **fragment** it in a build, **augment** it (slower, longer notes) at the climax;- - put it in the bass for menace, or high and quiet at the close.-- The phrase's high point goes in its second half. A phrase is 2 or 4 bars; a period is two phrases- (question, answer). The line must respect the style's range and density.-5. **Choose or write the groove.** Pick a family from the style's list (`bounce`, `trap`,- `brushes`, `hand`, ...). Set `density` 0..1, `variation` 0..1 and `fill` (a fill on a section's- last bar). The seed varies every bar, so no two pieces share a loop. You can also write the drum- bars yourself as notation, one or more bars per lane: `kick`, `snare`, `ghost`, `hat`, `perc`.- Use a second groove for contrast (`half`, `build`).-6. **Write the form.** Sections are `{ kind, bars, harmony, lead, counter, arp, groove, bass,- chordVel, energy, repeat, stretch }`.- - The **kind** sets which layers may sound: intro, verse, groove, hook, build, half, breakdown,- drop, bridge, swell, breath, outro. See the arrangement grammar in vocabularies.md.- - Lines sound only where you write them.- - Land each section change on a picture beat. At `bpm`, a bar lasts `beatsPerBar x 60 / bpm`- seconds, and at 30 fps a beat is `1800 / bpm` frames.- - Mark one section `stretch: true`: a film fit repeats or drops it to reach the exact length and- still end on your outro.-7. **Check, render, listen:**- ```- node tools/music.mjs check <file>.ts#<export> [--fit --seconds 62] # EVERYTHING, must PASS (below)- node tools/music.mjs render <file>.ts#<export> out.mp3 --stems # the file, plus the same report- node tools/music.mjs novelty <a>.ts#x <b>.ts#y # several scores: vs shipped AND pairwise- node tools/music.mjs score <file>.ts#<export> # the text score, bar by bar- ```- `check` runs everything:- - key/mode problems and composer warnings (for example, a line shorter than its section);- - the master: loudness vs target, true peak, and a note when the -1 dBTP ceiling stopped the- gain short;- - the **ghost, reverb and masking guards**;- - the stems;- - novelty.-- It exits non-zero on any failure. `render` prints the same report (stems with `--stems`), except- novelty.- - **Stems:** fix any part flagged more than 3 dB off with `levels`. `levels` is a **dB offset** per- slot (+2 = two dB louder), added on top of the calibrated gain, the trims and the mood controls'- shifts. LUFS alone once hid a sub 7-10 dB too hot.- - **When the guards and the stems disagree, the guards win.** If masking fails (the melody isn't- heard), raise the lead. The stem meter lets the lead sit up to +3 dB above its tolerance for- this. You can also lower or thin what sits in the melody's register. Mood controls shift the- stem targets with the sound (for example, brightness lifts the hats and their target); the- printed targets already include that.- - **Master short of target:** a gentle master (-16 LUFS) never compresses. If one peak blocks the- gain, the whole piece stays quieter, and `check` says by how much. Fix it in the notes: stagger- the bass under the loudest downbeat, roll the big chord, don't double the climax note.- - **Novelty:** if it fails, change what the numbers point at. The per-feature scores name it:- the lead's rhythm, the contour, the groove, the chord colours, the form. Changing the key fixes- nothing.- - **Listen:** the person hears it before it is used. Meters prove you aren't obviously wrong.- Only an ear says right. For a **loop**, deliver a `.wav`: mp3 adds encoder padding, so it clicks- or gaps at the loop point.--## The material format--Write the score in the film's own file, next to the film module: `src/canvas-core/<film>Score.ts`-in a scaffolded project (`engine/src/canvas-core/<film>Score.ts` inside the skill), and export it:--```ts-import type { Material } from "./music";-export const score = (): Material => ({- style: "<style id>", title: "<this film's score>", seed: <any integer>, mood: "<mood id>",- bpm: <tempo in the style's range>, key: "<tonic>", mode: "<mode id>", meter: "<meter>",- moodControls: { energy: <0..1>, warmth: <0..1>, brightness: <0..1>, tension: <0..1>, space: <0..1> },- swing: <0.5 straight .. 0.67 hard>, dyn: [<start 0..1>, <end 0..1>], tail: <seconds of ring-out>,- chords: { "<name>": { voicing: "[<note> <note> <note>]", bass: "<one bar of notation>" }, /* ... */ },- motifs: { "<motif>": "<one or more bars of notation>", /* your variations are motifs too */ },- grooves: { main: { family: "<family>", density: <0..1>, variation: <0..1> }, half: { family: "<family>" } },- sections: [- { kind: "intro", bars: <n>, harmony: ["<chord>", /* per bar, cycled */], chordVel: <0..1> },- { kind: "hook", bars: <n>, harmony: [/* ... */], lead: ["<motif>", "<motif variant>", "r:<beats>"], stretch: true, energy: <0..1> },- { kind: "groove", bars: <n>, harmony: [/* ... */], lead: ["<2-bar motif>"], loopLines: true },- { kind: "bridge", bars: <n>, key: "<new tonic>", mode: "<mode>", harmony: [/* in the new key */], lead: [/* ... */] },- /* ... */- { kind: "outro", bars: <n>, harmony: ["<home chord>"], lead: ["<the motif's last word>"] },- ],-});-```--A film plays it with `filmScore(score(), fps, frames)` from `canvas-core/score.ts`. That fits your-form to the exact length. `score.ts` is an empty skeleton to copy.--- **Voices:** `voices: { lead: "<alternate name>" }` swaps a slot for one of the style's- alternates. Or give your own `{ inst, role, gainDb, opts }` (instruments: README table).-- **Loops:** `loop: true`, and the form length is the loop. `render` makes it seamless.-- **Split bars:** `harmony: ["<chord> <chord>"]` splits a bar in two. Give that section a `bass`- override for it.-- **Lines play once.** `lead`, `counter` and `arp` start at the section's first bar and play ONCE,- even though `harmony` cycles. A shorter line leaves rests, and `check` warns. Set- `loopLines: true` to repeat the line until the section is full. `repeat: n` replays the whole- section, lines included.-- **Section `energy`** (0..1, 0.5 = as written) sets the section's dynamics for every part,- hand-written lines included. It scales velocity from 0.55x to 1.45x, roughly -5 to +3 dB. It- also sets the density of generated grooves.-- **`dyn`** is the whole piece's dynamic level `[start, end]`, ramped (default `[0.62, 0.66]`).- `swing` and `tail` default to the style's lower swing bound and 3.2 s.-- **Modulation:** give a section its own `key` and `mode`. The key check then reads each key region- on its own. A lift of a step for the last chorus is fine when that section declares the new key.-- **The key check weighs the tonic.** It accepts your declared tonic and mode when the mode's scale- explains the notes as well as any other reading, and the tonic is heard (at least 8 % of note- time). A lydian or dorian passage whose notes lean on another degree gets read as that degree's- major. Put the bass on the tonic at section starts and cadences, and state the mode's colour note.-- **Written drums:**- - A `LiteralGroove` gives notation bars per lane (`kick`, `snare`, `ghost`, `hat`, `perc`).- - The bars cycle from each section's first bar; `cycle: "piece"` cycles on the piece's bar count- instead.- - Unpitched drums ignore the written pitch: write `C4`.- - A timpani in a drum lane (orchestral, choral, suspense, world) is tuned to the tonic of `key`,- generated grooves included (`epic`).--**Notation** (bar-checked; a bar that doesn't add up throws, the last bar too: a line that ends-mid-bar writes its rest, `C2:3 r:1`, never a silent gap):-- A token is `NOTE:DUR[@VEL]` (a pitch name with an octave, e.g. `F#4`), `[NOTE NOTE ...]:DUR` (a- chord) or `r:DUR` (a rest).-- Bars are separated by `|`, or given as array items.-- Durations are in beats. In 6/8, 9/8 and 12/8 a beat is a dotted quarter, so an eighth is `1/3`.- In 7/8 a beat is a quarter, so an eighth is `.5` and a bar is 3.5.-- `@VEL` scales the line's velocity (0..1).-- In a hand-written piece, a one-bar sting on any beat says so: `line(t, "G6:1", { ..., hit: true })`.--## Craft notes (what makes it good, not just valid)--- **One idea, developed.** Most memorable scores have one motif, heard 6-12 times, never the same- way twice. Two motifs at most; the second answers or contrasts the first.-- **Contrast by section:**- - change the density (layers in and out);- - change the register (the motif up an octave);- - change the harmonic rhythm (twice as fast into a cadence);- - change the groove (half-time).-- A section that only repeats the previous one is dead air.-- **Cadences on picture beats.** The strongest arrival (home chord, full layers, the motif's peak)- goes on the most important frame. The claim, the reveal and the logo each get a structural- downbeat. Use a breakdown or a breath (drums out, one bar of silence) right before it.-- **Tension curve.** Plan energy 0..1 per section before writing notes: rise, a dip before the peak,- then release. Match it with density, register and harmony (leaning chords before home).-- **Endings.** End on a phrase, never on the last frame by accident:- - a held home chord with the motif's last word;- - a button (a short tutti hit);- - an unresolved hold (suspense only).-- **Mood fit.** Match the mode, tempo and brightness to the words. If the listener names a different- emotion from the one you declared, the choice was wrong, not the listener.-- **Breadth.** Across projects, vary the meter, the harmonic rhythm, the groove family and the form- length. Two scores for two products should not be siblings.--## What checks what--| Check | Runs in | Fails when |-|---|---|---|-| key/mode (`planProblems`) | `check`, `render` | a key region's notes don't support its declared tonic and mode |-| composer warnings | `check`, `render` | (warns only) a line is shorter than its section, ... |-| master | `check`, `render` | (notes only) the peak ceiling stopped the gain short of the target |-| ghost guard | `check`, `render` | 4-bar windows are formless (few onsets, sustained, wet, no cadence) |-| reverb guard | `check`, `render` | the late tail sits within 10 dB of the dry sound |-| masking guard | `check`, `render` | the melody doesn't clear the other parts in 500 Hz-4 kHz |-| stems | `check`, `render --stems`, `stems` | a part is more than 3 dB off target (lead: up to +6 dB allowed); advisory for uncalibrated styles |-| novelty | `check`, `novelty` | similarity above 0.5 to a shipped piece (or to each other), or a reused 6-note melody fragment |--`tools/music-unit.mjs` keeps the engine honest: determinism, no defaults, every vocabulary renders.diff --git a/plugins/anidoodle/skills/anidoodle/references/music/sound-design.md b/plugins/anidoodle/skills/anidoodle/references/music/sound-design.mdindex 27f1def..ffee6ac 100644--- a/plugins/anidoodle/skills/anidoodle/references/music/sound-design.md+++ b/plugins/anidoodle/skills/anidoodle/references/music/sound-design.md@@ -56,9 +56,9 @@ approach, a riser's build) is rendered before the frame. If it would start beforthe plan throws and names the earliest legal frame.```ts-import { filmSfx, filmAudio, composePiece, type SfxPlan } from "./music";-import { myScore } from "./myScore"; // the Material YOU composed for this film (compose.md)-const score = composePiece(myScore);+import { filmSfx, filmAudio, type SfxPlan } from "./music";+import { myScore } from "./myScore"; // the Piece YOU wrote for this film (README.md)+const score = myScore();const plan: SfxPlan = {fps: 30, frames: 450, score: { piece: score }, beatZeroS: 0, seed: 7, // key, bpm, bar from the scorecues: [diff --git a/plugins/anidoodle/skills/anidoodle/references/music/styles/lofi-electronic.md b/plugins/anidoodle/skills/anidoodle/references/music/styles/lofi-electronic.mddeleted file mode 100644index 9a5763f..0000000--- a/plugins/anidoodle/skills/anidoodle/references/music/styles/lofi-electronic.md+++ /dev/null@@ -1,109 +0,0 @@-# Style: lo-fi electronic (chill, upbeat, clean)--> A vocabulary, not a song. The data is `VOCAB.lofiElectronic` in `engine/src/canvas-core/music/vocab.ts`-> (print it: `node tools/music.mjs vocab lofiElectronic`). You compose the notes with-> [../compose.md](../compose.md). Our launch film was scored in this style (`launchLofi3`). That-> score is ours and is in the novelty corpus. Never reuse its progression, hook, rhythms, drums or-> form.--## The sound--Chill but **upbeat**, **clear**, **not noisy**:-- a warm pad that breathes with the kick;-- a plucked lead through a dotted-eighth ping-pong delay;-- a high counter-line;-- a round sine sub;-- a bouncy, clean kit.--**Never:**-- synth electric piano;-- vinyl crackle;-- bit-crush;-- a dark master low-pass;-- heavy tape.--Those read as dusty lo-fi hip-hop (the `lofi` style), not clean electronic.--| Slot | Voice | How it's made | Stem RMS target |-|---|---|---|---|-| chords | `warmPad` | 7 PolyBLEP saws, spread 0.55 x +-14 cents, slow per-voice drift, 12 dB low-pass at 2.6 kHz, 0.5 s attack, 1.4 s release | -21 dB |-| lead | `softPluck` | triangle + square an octave down, filter snaps open, 0.42 s decay, dotted-eighth ping-pong (feedback 0.28, mix 0.24) | -16.5 dB |-| counter | `softPluck` | brighter, panned 0.35, more delay and room | -24 dB |-| bass | `sub` | sine + a whisper of the 2nd harmonic, low-passed at 150 Hz | -18 dB |-| kick / snare / ghost / hat | kit | a bouncy kick, a snare, rim ghosts about 11 dB under, 16th hats | -14 / -20 / - / -28 dB |-| arp, perc | `softPluck`, `hat` | optional extra layers | - |--Alternates:-- lead: `bell`, `mallet`, `guitar`;-- chords: `strings`, `piano`;-- bass: `warm`.--Bus:-- the kick ducks the chords and the counter (depth 0.38, release 0.24 s);-- tape is barely there (2.5 cents of wow);-- clean master at **-14 LUFS**, true peak **<= -1 dBTP**.--The stem targets were calibrated on a listened score, and they are the only calibrated targets.--## Grooves--`bounce`, `halfTime`, `broken`, `skip`, `pulse`, `build`. Pick one per section role (`main`,-`half`, `build`) and set `density` and `variation`. The seed varies every bar. Swing 0.52-0.56.--## Harmony language (write your own progression)--- **Modes:** major, dorian, lydian, aeolian, mixolydian.-- **Qualities:** 7ths, 9ths, 11ths, 13ths, add9, sus2 and sus4. Keep bare triads for the landing.-- **Tendencies:**- - loops of 2, 4 or 8 bars;- - ii-V motion;- - drifting IV-iii-vi motion;- - modal vamps (i-IV in dorian, I-II in lydian);- - a borrowed iv or bVII for a wistful turn.-- **Harmonic rhythm:** one chord per bar or two. A change may anticipate the bar by an eighth.-- **Voicing:** rootless 3-4 note voicings between about E3 and E4, moving by step. The sub owns the- root.-- **Tension:** sus4 and 13ths lean, maj7#11 floats, 7b9 or a borrowed iv aches. Release by stepping- the leaning voice down.--## Melody rules (write your own motif)--- Lead in C4-A5, counter an octave above.-- Short arches, with the high point late in the phrase.-- 1-3 notes per beat, with rests so the echo can answer.-- A 2-5 note cell with its own rhythm: repeat it, then vary it (a step up, the last interval- inverted, displaced by an eighth).-- Call and response between the lead and the counter.--## Arrangement grammar--A typical shape: intro -> groove -> hook -> (half-time or breakdown) -> drop on home -> outro. Add-or remove one layer at a time. Put the drop (everything back, home chord) on the picture's strongest-beat.--**Transitions:**-- a fill bar;-- a half-time bar;-- drums out for a breakdown.--**Endings:**-- the home chord held, with the motif's last note;-- a clean button.--## Mixing: balance by stem RMS, then master--```-node tools/music.mjs check <file>.ts#<export> # the whole gate, stems included-node tools/music.mjs stems <file>.ts#<export> # the stem table alone, while you balance-node tools/music.mjs render <file>.ts#<export> out.mp3 --stems-```--A stem is a part's own signal:-- unmastered, pre-room, after its gain and the duck;-- measured as RMS over its **active** samples (|x| > 1e-4), left channel, at 24 kHz.--Fix a flagged part with `levels`, never with the master.--**The lesson:** integrated LUFS only says how loud the whole mix is. On the launch score the mix read-a healthy -14 LUFS while the sub sat **7-10 dB too hot**. `tools/music-unit.mjs` keeps this as a-regression: a sub 9 dB hot still masters to -14.0 LUFS, and only the stem meter flags it.diff --git a/plugins/anidoodle/skills/anidoodle/references/music/styles/music-box.md b/plugins/anidoodle/skills/anidoodle/references/music/styles/music-box.mdindex cfe571f..8bfba70 100644--- a/plugins/anidoodle/skills/anidoodle/references/music/styles/music-box.md+++ b/plugins/anidoodle/skills/anidoodle/references/music/styles/music-box.md@@ -1,11 +1,10 @@-# Style: music box+# Style preset: music-box (the default)-> The original anidoodle music recipe, kept below for its SOUND numbers (the `musicBox` and `bell`-> instruments implement them) and its scar story (why the guards exist). It is one style among the-> vocabularies in `engine/src/canvas-core/music/vocab.ts` (`VOCAB.musicBox`), not a default: there is-> no default style. Its fixed composing choices (one progression, one scale, one accompaniment-> figure) were rewritten below as ranges: the composer writes the notes ([../compose.md](../compose.md)).-> Its ban list is the rule for THIS style only; for other styles the bans became measured guards.+> The original anidoodle music recipe, kept **verbatim** below as one style preset among the eleven+> in `engine/src/canvas-core/music/tables.ts` (`STYLES.musicBox`). Its numbers are what the+> `musicBox` and `bell` instruments implement. Its ban list is now the rule for THIS preset only;+> for every other style the bans became measured guards (see `../README.md`, "Guards"). The scar+> story is kept because it is why the guards exist.---@@ -28,11 +27,11 @@- bass: same pluck one to two octaves down with only the first two partials, gain 0.5. It is still a pluck. It never sustains.- "room": ONE early reflection, 30 ms late, 14 dB down. No tail.-**Key, register, harmony.** Any major, lydian, dorian or minor key you choose for the mood (a minor music box is a real, uncanny sound). Melody between C5 and C7, bass C3 to G3. Harmonic rhythm one chord per bar; the progression is yours (plagal and deceptive turns read well; the original film used the plainest possible one and said "nothing cleverer", which is a choice, not a rule). For a lift at the payoff, move the key up a step.+**Key, register, harmony.** C, G or D major. Melody between C5 and C7, bass C3 to G3. One chord per bar, **I, IV, V, I**, and nothing cleverer. If you want a lift for the payoff, go up a whole step and play the same thing.-**Melody.** Chord tones plus the mode's scale, mostly steps, leaps onto chord tones. Four-bar phrases in pairs: the QUESTION ends off the tonic, the ANSWER lands on it, **and the answer follows immediately.** Your own motif, with its own rhythm.+**Melody.** Chord tones and the major pentatonic (1 2 3 5 6). Mostly steps, leaps only onto chord tones. Four-bar phrases in pairs: the QUESTION ends on the 5th over V, the ANSWER ends on the root over I, **and the answer follows immediately.** The story may hold its resolution back for a minute; the tune may not. What you hold back is the ARRANGEMENT: the octave doubling, the full arpeggio and the bell arrive with the payoff.-**Rhythm.** At 120 bpm and 30 fps a beat is 15 frames and a straight eighth is 7.5 frames, which does not exist. Use triplet eighths, 5 frames: 12/8, which is what a music box plays anyway. Accompaniment is an arpeggio figure you design on the triplets (choose its order of chord tones and its cycle length; a 4-note cell over 3-note groups makes a gentle hemiola); melody mostly on beats. Every onset is a row in a cue table with its FRAME, and the module asserts at load that each sample index equals `round(frame / fps * sampleRate)`.+**Rhythm.** At 120 bpm and 30 fps a beat is 15 frames and a straight eighth is 7.5 frames, which does not exist. Use triplet eighths, 5 frames: 12/8, which is what a music box plays anyway. Accompaniment is a rolling 1-5-3-5 arpeggio on the triplets; melody mostly on beats. Every onset is a row in a cue table with its FRAME, and the module asserts at load that each sample index equals `round(frame / fps * sampleRate)`.**Sound events ride on top, quietly:** a tick is a 2 ms noise burst through a band-pass at 3 kHz, the tock at 2 kHz, 20 dB under the melody. A landing is one soft pluck on its beat. The DING is a bell on the tonic (partials 1, 2, 3, 4.2, tau 1.2 s, doubled an octave down) on the final downbeat, with at least four beats of film after it.diff --git a/plugins/anidoodle/skills/anidoodle/references/music/styles/vocabularies.md b/plugins/anidoodle/skills/anidoodle/references/music/styles/vocabularies.mddeleted file mode 100644index 6f24f48..0000000--- a/plugins/anidoodle/skills/anidoodle/references/music/styles/vocabularies.md+++ /dev/null@@ -1,537 +0,0 @@-# Style vocabularies--> GENERATED by `node tools/music.mjs vocab --md` from `engine/src/canvas-core/music/vocab.ts` and `vocabMore.ts`. Do not edit by hand.-> A style is a vocabulary: sound, grooves, harmony language, melody rules, arrangement grammar. It never-> contains notes. You compose the notes ([../compose.md](../compose.md)).--| Style | Atmosphere | Tempo, meters | Moods | Grooves |-|---|---|---|---|---|-| `lofiElectronic` | warm, chill but upbeat, clean: a breathing pad, a plucked hook through ping-pong echoes, a round sub, a bouncy kit | 80-100 bpm; 4/4 | calm, joy, hopeful, nostalgic, wistful, curious | bounce, halfTime, broken, skip, pulse, build |-| `drive` | forward, bright, confident: four-on-the-floor, a pumping supersaw bed, a gritty bass line, a plucked arp | 110-140 bpm; 4/4 | drive, triumph, tension, joy, awe | fourFloor, broken, build, halfTime, tension |-| `cinematic` | wide and emotional: string swells, low ostinatos for tension, harp and bell colour, a low boom on the arrival | 60-120 bpm; 4/4, 3/4, 6/8 | awe, triumph, tension, melancholy, hopeful, dread | pulse, tension, build, halfTime |-| `ambient` | floating, spacious, luminous: long pads, bells and plucks with space around them, a soft heartbeat at most | 50-80 bpm; 4/4, 3/4 | awe, calm, hopeful, tender, dread | pulse, brushes |-| `folk` | intimate and warm: fingerpicked guitar, soft piano, a harp or celesta line, brushes | 60-110 bpm; 6/8, 3/4, 4/4 | tender, calm, wistful, nostalgic, hopeful, romantic | brushes, pulse, shuffle |-| `playful` | light, cheeky, springy: marimba and pizzicato-like plucks, a bouncy bass, a skipping kit | 100-150 bpm; 4/4, 6/8 | playful, joy, curious | skip, shuffle, bounce, fourFloor |-| `musicBox` | small, bright, clockwork, innocent; plucked and never sustained | 100-132 bpm; 12/8, 3/4, 6/8 | joy, curious, tender, playful, wistful, eerie | none (no drums) |-| `nocturne` | intimate, expressive, late-night: one piano, rubato, pedal | 50-76 bpm; 3/4, 6/8, 4/4 | tender, melancholy, wistful, romantic, grief | none (no drums) |-| `minimalist` | hypnotic, curious, clean: interlocking ostinatos that change slowly | 96-144 bpm; 4/4, 12/8, 5/4, 7/8 | curious, tension, awe, calm | pulse |-| `jazz` | loose, warm, clever: swing ride, walking bass, comping piano | 80-200 bpm; 4/4, 3/4 | playful, nostalgic, romantic, curious, sensual, mischief | swing, brushes, shuffle |-| `lullaby` | soft, rocking, safe | 56-78 bpm; 3/4, 6/8 | tender, calm | none (no drums) |-| `chiptune` | 8-bit, bright, game-like: two pulses, a triangle, noise drums | 110-170 bpm; 4/4, 6/8 | joy, playful, drive, tension, mischief | fourFloor, bounce, shuffle, skip |-| `lofi` | hazy, nostalgic, crackly: FM e-piano, vinyl, a lazy swung beat (the dusty cousin of lo-fi electronic) | 68-90 bpm; 4/4 | nostalgic, calm, wistful, sensual | bounce, halfTime, shuffle |-| `orchestral` | big and heroic: brass theme, string ostinato engine, choir, timpani | 70-140 bpm; 4/4, 3/4, 6/8 | heroic, triumph, awe, tension, grief | epic, build, tension, pulse |-| `suspense` | unsettling, cold, withheld: low drones, heartbeat pulse, high bowed harmonics, stingers | 50-110 bpm; 4/4, 5/4, 3/4 | tension, dread, eerie | pulse, tension, epic |-| `rock` | live-band energy: driven guitars, bass locked to the kick, a tight kit, maybe organ | 90-160 bpm; 4/4, 6/8 | drive, anger, triumph, joy, heroic | rock, halfTime, shuffle, fourFloor |-| `hipHop` | head-nod or dark trap: heavy 808, crisp clap, rolling hats, a moody loop on top | 70-100 bpm; 4/4 | drive, calm, nostalgic, sensual, anger, tension | trap, bounce, halfTime, broken |-| `house` | euphoric, dancing, bright: four-on-the-floor, offbeat bass, stabs, a big pad | 118-128 bpm; 4/4 | joy, drive, sensual, hopeful | fourFloor, build, broken |-| `synthwave` | neon-nostalgic, cinematic 80s: big gated snare, pulsing 8th bass, lush pads, a soaring lead | 80-118 bpm; 4/4 | nostalgic, drive, heroic, romantic, tension | fourFloor, halfTime, rock, build |-| `world` | rooted, spacious, rhythmic: a drone, a modal melody on plucked strings or a flute, hand percussion cycles (write your own melody; name the tradition you draw on) | 60-150 bpm; 7/8, 9/8, 12/8, 6/8, 4/4, 5/4 | calm, joy, curious, mischief, awe, sensual | hand, pulse, brushes |-| `choral` | vast, human, reverent: voices in parts, organ, bells, a slow swell | 50-90 bpm; 4/4, 3/4 | awe, grief, hopeful, tender, heroic | pulse |--## Groove families--Pick a family and its knobs (`density`, `variation`, `fill`, `accent`); the seed varies every bar. Or write the drum bars yourself.--- `bounce`: lo-fi / hip-hop bounce: kick on 1 plus syncopated pickups, backbeat on 2 and 4, ghost notes, 8th or 16th hats with accents-- `fourFloor`: house / drive: kick on every beat, clap on 2 and 4, off-beat open hats, 16ths when dense-- `halfTime`: half-time: kick on 1 (and a pickup), snare on 3; the same tempo feels twice as slow (a breath, a scene change)-- `broken`: broken beat / garage: kicks displaced off the grid, backbeat kept, ghosted 16ths; restless, modern-- `shuffle`: shuffle: triplet grid, swung hats, kick on 1 and 3 with a skip; playful, bouncy-- `pulse`: pulse: a soft heartbeat kick, no backbeat, sparse shaker; ambient and cinematic under-scoring-- `brushes`: brushes: soft rim on 2 and 4, shaker swishes, a gentle kick; tender, acoustic-- `build`: build: snare 8ths then 16ths rising in velocity across the section, kick on quarters; ends on the next downbeat-- `tension`: tension: 3-3-2 kick ostinato, accent on 4, quiet 16th hats; cinematic urgency, chases-- `skip`: skip: kick on 1 and the and-of-2, clap on 2 and 4, a skipping 16th perc; playful, light-- `trap`: trap: sparse syncopated kicks (the 808 bass follows them), clap on 3, 16th hats with velocity ramps and bursts, an open hat now and then-- `epic`: epic: big low hits (kick / timpani in perc) in a 3-3-2 or 1-and-3 figure, a snare accent on 4; orchestral and trailer weight-- `hand`: hand percussion: dum (low) on each group start, tek (rim) inside, ka (perc) fills; groups follow the meter (7/8 = 2+2+3, 9/8 = 2+2+2+3, 5/4 = 3+2)-- `rock`: rock: kick on 1 and 3 with an 8th pickup, snare backbeat, 8th hats, a crash (perc) on section starts-- `swing`: jazz swing: ride on the beats and the swung skip of 2 and 4, foot hi-hat (perc) on 2 and 4, feathered kick, snare comping ghosts--## Section kinds (the arrangement grammar)--A kind decides which layers may sound; your lines sound only where you write them.--- `intro` (drums: none, bass: no): chords (and any line you write) without drums or bass: set the colour, state the key-- `verse` (drums: main, bass: yes): the groove under a lighter line: room for picture and words-- `groove` (drums: main, bass: yes): chords, bass, drums: the bed, no lead unless you write one-- `hook` (drums: main, bass: yes): full groove under the motif: the memorable part-- `build` (drums: build, bass: yes): rising density (snare 8ths to 16ths), rising line, lands on the next downbeat-- `half` (drums: half, bass: yes): half-time drums: the same tempo feels slower (a scene change, a breath with pulse)-- `breakdown` (drums: none, bass: no): drums and bass out, chords and a thin line: the held breath before a landing-- `drop` (drums: main, bass: yes): everything back on a strong chord: the landing, put it on the picture's key beat-- `bridge` (drums: main, bass: yes): new harmony away from home (a borrowed or relative area) before the return-- `swell` (drums: none, bass: yes): long notes crescendo over 2-8 bars (orchestral swell), peaks on the downbeat after-- `breath` (drums: none, bass: no): near silence: one held chord or nothing, authored (max 2 bars)-- `outro` (drums: none, bass: yes): home chord held, the motif's last word, then the tail--## `lofiElectronic`: lo-fi electronic--warm, chill but upbeat, clean: a breathing pad, a plucked hook through ping-pong echoes, a round sub, a bouncy kit. Tempo 80-100 bpm, meters 4/4, swing 0.52-0.56.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `warmPad` | -3 | -21 | strings (`strings`, -6 dB), piano (`piano`, -4 dB) |-| lead | `softPluck` | 6 | -16.5 | bell (`fmBell`, 0 dB), mallet (`marimba`, 2 dB), guitar (`guitar`, 2 dB) |-| counter | `softPluck` | 8 | -24 | - |-| bass | `sub` | -6 | -18 | warm (`bass`, -2 dB) |-| kick | `kick` | 0.5 | -14 | - |-| snare | `snare` | 8 | -20 | - |-| ghost | `snare` | 4 | - | - |-| hat | `hat` | 20 | -28 | - |-| arp | `softPluck` | 4 | - | - |-| perc | `hat` | 14 | - | - |--Stem targets: calibrated on a listened score.--- **Harmony language.** Modes: major, dorian, lydian, aeolian, mixolydian. Qualities: 7ths, 9ths, 11ths and 13ths; add9; sus2/sus4 for air; avoid bare triads except on the landing. Tendencies: loops of 2, 4 or 8 bars; ii-V motion, IV-iii-vi drifts, modal vamps (i-IV in dorian, I-II in lydian), borrowed iv or bVII for a wistful turn; the home chord arrives on a structural beat. Harmonic rhythm: one chord per bar or two per bar; the change can anticipate the bar by an eighth. Voicing: rootless 3-4 note voicings between E3 and E4 moving by step (common tones held); the bass owns the root. Tension and release: sus4 and 13ths lean, maj7#11 floats, a dominant 7b9 or a borrowed iv aches; release by resolving the lean voice down a step.-- **Melody.** Range C4-A5 for the lead, the octave above for counter lines. Contour: short arches; the high point in the second half of a phrase; answer phrases end lower. Density: 1-3 notes per beat; leave rests so the echo answers. Motif: a 2-5 note cell with its own rhythm; repeat it, then vary it (shift it up a step, invert the last interval, displace it by an eighth); call and response between lead and counter.-- **Arrangement.** intro -> groove -> hook -> (half-time or breakdown) -> drop on home -> outro; add or remove one layer at a time. Transitions: a fill bar, a half-time bar, drums out for a breakdown, then everything back on a downbeat. Endings: home chord held with the motif's last note, or a clean button on 1.-- **Grooves:** bounce, halfTime, broken, skip, pulse, build. **Avoid:** synth ePiano, vinyl crackle, bit-crush, a dark master low-pass: that is dusty lo-fi hip-hop, not clean electronic.--## `drive`: driving electronic--forward, bright, confident: four-on-the-floor, a pumping supersaw bed, a gritty bass line, a plucked arp. Tempo 110-140 bpm, meters 4/4, swing 0.5-0.52.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `strings` | -2.7 | -22 | - |-| lead | `strings` | 5.4 | -16 | pluck (`softPluck`, 5 dB) |-| counter | `fmBell` | 6 | -27.3 | - |-| bass | `bass` | 0.1 | -16 | sub (`sub`, -5 dB) |-| kick | `kick` | 2.5 | -12 | - |-| snare | `snare` | 10.5 | -18 | - |-| ghost | `snare` | -2 | - | - |-| hat | `hat` | 12 | -26 | - |-| arp | `softPluck` | 4.2 | -21 | - |-| perc | `hat` | 18.3 | -27 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: aeolian, dorian, mixolydian, major. Qualities: triads and power voicings, sus2, add9; minor with a major IV (dorian) for lift. Tendencies: i-VI-III-VII, i-v-VI-IV, bVI-bVII-i climbs; long pedal tones under changing chords; a key lift of a step for the last chorus. Harmonic rhythm: one chord per bar or per two bars; stabs on off-beats. Voicing: wide: root-fifth-octave low, tight triads above C4; the bass line is 8ths or offbeat. Tension and release: a pedal under a moving chord, a build that withholds the kick, a riser into a drop; release on the downbeat with everything.-- **Melody.** Range A3-E6. Contour: repeated cells climbing by step; big leaps at the drop. Density: 8ths and 16ths; arps in 3-note cells across 4/4 (hemiola). Motif: a rhythmic riff of 3-6 notes, repeated with the last note changed; sequence it up the scale in the build.-- **Arrangement.** intro (filtered) -> build -> drop -> breakdown -> build -> bigger drop -> outro. Transitions: builds of 4-8 bars, a one-beat breath before the drop. Endings: a button on 1 or a filtered fade of the groove.-- **Grooves:** fourFloor, broken, build, halfTime, tension. **Avoid:** swing, soft attacks on the lead, more than 4 layers in the breakdown.--## `cinematic`: cinematic / orchestral--wide and emotional: string swells, low ostinatos for tension, harp and bell colour, a low boom on the arrival. Tempo 60-120 bpm, meters 4/4, 3/4, 6/8, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `strings` | 1.2 | -18 | - |-| lead | `strings` | 4.5 | -17 | piano (`piano`, 0 dB), bell (`fmBell`, -4 dB), celesta (`celesta`, 0 dB) |-| counter | `harp` | 12 | -36.7 | piano (`piano`, -3 dB) |-| bass | `strings` | 1.3 | -19 | - |-| arp | `strings` | 3.4 | -21 | - |-| kick | `kick` | -2.4 | -16 | - |-| snare | `snare` | -2 | -24 | - |-| ghost | `snare` | -4 | - | - |-| hat | `hat` | 6 | -32 | - |-| perc | `fmBell` | -8 | - | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: aeolian, harmonicMinor, lydian, major, phrygian, dorian. Qualities: open fifths, add9, sus2/sus4, minor with a major IV; chromatic mediants (C to E, C to Ab) for awe. Tendencies: slow harmonic rhythm (1-2 bars per chord); i-bVI-bVII-i for epic, i-iv-V for drama, lydian II for wonder, a pedal bass under moving chords for tension; big arrivals on chromatic mediants. Harmonic rhythm: one chord per 1-2 bars; tension sections hold one chord over an ostinato. Voicing: spread wide: bass octaves below C3, open fifths, the melody doubled an octave on the climax (stagger the bass to keep peaks musical). Tension and release: minor seconds against a pedal, a b6 leaning to 5, suspended 4ths held long, harmonic minor's raised 7th; release to a major chord or a picardy third.-- **Melody.** Range G3-C6 (strings), harp and bell above. Contour: long arcs over 4-8 bars, a big leap (6th, octave) then stepwise fall. Density: 0.5-2 notes per beat; tension ostinatos 2-4 per beat. Motif: a 3-4 note idea that returns transformed: augmented (slower) at the climax, in the bass for menace, in the harp for tenderness.-- **Arrangement.** intro (a colour, a drone) -> theme -> swell/build -> climax on the key picture beat -> release -> quiet coda. Transitions: crescendo over 4-8 bars; a breath of silence before the arrival; a low boom on the downbeat. Endings: a held chord ringing into the tail, or a hard-out on the cut.-- **Grooves:** pulse, tension, build, halfTime. **Avoid:** more than four families at once outside the climax; fast drums under a tender theme.--## `ambient`: airy ambient--floating, spacious, luminous: long pads, bells and plucks with space around them, a soft heartbeat at most. Tempo 50-80 bpm, meters 4/4, 3/4, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `warmPad` | 1.5 | -19 | - |-| lead | `fmBell` | 1.3 | -20 | pluck (`softPluck`, 5 dB), vibes (`vibes`, 0 dB) |-| counter | `softPluck` | 6.8 | -25 | - |-| bass | `sub` | -8.3 | -22 | - |-| arp | `celesta` | -0.9 | -24 | - |-| kick | `kick` | -6.4 | -20 | - |-| ghost | `snare` | -6 | - | - |-| hat | `hat` | 6 | -32 | - |-| perc | `hat` | 4 | - | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: lydian, major, dorian, majorPentatonic, aeolian. Qualities: maj7, add9, maj7#11, sus2, quartal stacks (4ths). Tendencies: two-chord oscillations (I-II lydian, i-IV dorian), planing (the same shape moved by step), a pedal note held through changes. Harmonic rhythm: slow: one chord per 2-4 bars. Voicing: wide and open, high register, no thirds low; let voices ring. Tension and release: a #11 or a 9 against the root; release by the melody settling on the fifth or the root.-- **Melody.** Range C5-C7 bells, pluck echoes above. Contour: sparse, falling phrases of 2-5 notes; rests as long as the notes. Density: 0.25-1 note per beat, but a motif at least every 8 bars (the ghost guard). Motif: a 3-note bell figure that returns, echoed by the pluck at a new register.-- **Arrangement.** slow evolution: add one layer every 4-8 bars, take one away before the end. Transitions: crossfades; a pad change on a bar line. Endings: the motif once more, alone, into the tail.-- **Grooves:** pulse, brushes. **Avoid:** formlessness: sustained pads with no onsets and no cadence (the ghost failure); run the guards.--## `folk`: tender acoustic--intimate and warm: fingerpicked guitar, soft piano, a harp or celesta line, brushes. Tempo 60-110 bpm, meters 6/8, 3/4, 4/4, swing 0.5-0.54.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `piano` | 7 | -33 | strings (`strings`, -8 dB) |-| arp | `guitar` | 8 | -22.9 | - |-| lead | `harp` | 14 | -18.8 | piano (`piano`, 0 dB), guitar (`guitar`, 2 dB), strings (`strings`, -2 dB) |-| counter | `celesta` | 8.2 | -24 | - |-| bass | `bass` | -4.4 | -21 | - |-| kick | `kick` | -4.5 | -20 | - |-| snare | `snare` | -6 | -26 | - |-| ghost | `snare` | 3.4 | -28 | - |-| hat | `hat` | 2 | -30 | - |-| perc | `hat` | 14 | -35.8 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, mixolydian, dorian, majorPentatonic, aeolian. Qualities: triads, add9, sus2, slash chords with a walking bass (I - V/7 - vi). Tendencies: I-V/7-vi-IV descents, bVII-IV-I (mixolydian), plagal IV-I endings, a relative minor detour. Harmonic rhythm: one chord per bar in 6/8 or 3/4; two per bar in 4/4. Voicing: guitar-shaped: root-fifth-tenth, open strings ringing; piano in the middle, melody on top. Tension and release: a suspended 4th resolving, a IV minor (iv) borrowed for the ache; release plagal (IV-I).-- **Melody.** Range D4-G5, singable (a 10th at most). Contour: stepwise with one leap per phrase, rising question, falling answer. Density: 1-2 notes per beat, a held note at each phrase end. Motif: a singable 4-bar phrase; the answer repeats its start and changes its end.-- **Arrangement.** guitar alone -> + melody -> + piano and bass -> + counter line -> thin to guitar and melody for the end. Transitions: a pickup note into each phrase; a bar of guitar alone between verses. Endings: plagal cadence, a rolled final chord.-- **Grooves:** brushes, pulse, shuffle. **Avoid:** four-on-the-floor, heavy drums, synth pads, fast arpeggios that bury the melody.--## `playful`: playful / bouncy--light, cheeky, springy: marimba and pizzicato-like plucks, a bouncy bass, a skipping kit. Tempo 100-150 bpm, meters 4/4, 6/8, swing 0.5-0.6.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| lead | `marimba` | 4.1 | -16 | chip (`pulse`, -4 dB), pluck (`softPluck`, 5 dB), bell (`fmBell`, -2 dB) |-| chords | `vibes` | -4.3 | -22 | - |-| arp | `harp` | 8 | -22.4 | - |-| counter | `celesta` | 10 | -23 | - |-| bass | `bass` | -1.6 | -18 | tuba (`sub`, -4 dB) |-| kick | `kick` | 0.3 | -15 | - |-| snare | `snare` | 8.1 | -21 | - |-| ghost | `snare` | 0 | -26 | - |-| hat | `hat` | 22.2 | -28 | - |-| perc | `hat` | 19.7 | -29 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, mixolydian, majorPentatonic, lydian, blues. Qualities: triads and 6ths, dominant 7ths, chromatic passing chords (a diminished between I and ii). Tendencies: fast harmonic rhythm (2 chords a bar), I-vi-ii-V turnarounds, secondary dominants (V/V), a surprise bVI. Harmonic rhythm: two chords per bar, on-beat stabs. Voicing: close, mid-high; the bass bounces root-fifth (oom-pah) or walks. Tension and release: a chromatic approach note, a held dominant with a pause; release with a cheeky button.-- **Melody.** Range C4-C7 (mallets love the top). Contour: leaps and staccato repeated notes; zig-zags; grace-note slides. Density: 2-4 notes per beat, with sudden rests (comic timing). Motif: a 3-note staccato cell with a leap; answer it lower, then sequence it.-- **Arrangement.** short sections (4-8 bars), stop-time breaks, call and response between lead and counter. Transitions: a stop (all out for a beat), a drum fill, a key lift. Endings: a button: a short tutti hit on 1, sometimes after a comic pause.-- **Grooves:** skip, shuffle, bounce, fourFloor. **Avoid:** long pads, slow tempo, minor-key sustained melodies.--## `musicBox`: music box--small, bright, clockwork, innocent; plucked and never sustained. Tempo 100-132 bpm, meters 12/8, 3/4, 6/8, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| lead | `musicBox` | 3.5 | -16 | celesta (`celesta`, 0 dB), bell (`fmBell`, -4 dB) |-| arp | `musicBox` | -6 | -26 | - |-| bass | `musicBox` | -3 | -24 | - |-| counter | `bell` | 0.3 | -22 | - |-| chords | `celesta` | -5.3 | -27 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, lydian, dorian, aeolian, majorPentatonic. Qualities: triads and sus2; a minor music box is a real (and uncanny) sound. Tendencies: any functional progression you write; plagal and deceptive turns read well; a whole-step lift for the payoff. Harmonic rhythm: one chord per bar. Voicing: melody C5-C7, bass C3-G3, arpeggio figures in between (you choose the figure). Tension and release: an unresolved 4th or a borrowed iv; release on a clean tonic.-- **Melody.** Range C5-C7. Contour: hooky, skipping. Density: more notes, never longer notes (no sustain). Motif: a 3-5 note hook with a distinctive rhythm; restate it, answer it.-- **Arrangement.** melody -> +bass -> +arpeggio -> +octave sparkle -> bell on the final downbeat. Transitions: add a layer each phrase. Endings: a bell or a single plucked tonic.-- **Grooves:** none. **Avoid:** sustained pads, long reverb tails, slow attacks (the ghost failure); see styles/music-box.md for the old recipe's numbers.--## `nocturne`: nocturne / solo piano--intimate, expressive, late-night: one piano, rubato, pedal. Tempo 50-76 bpm, meters 3/4, 6/8, 4/4, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| lead | `piano` | 12 | -17 | - |-| chords | `piano` | 12 | -30.3 | - |-| bass | `piano` | 6.3 | -23 | - |-| counter | `strings` | 2 | -30 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, aeolian, harmonicMinor, dorian. Qualities: triads, 7ths, secondary dominants, borrowed iv, Neapolitan for grief. Tendencies: descending bass lines, circle-of-fifths sequences, deceptive V-vi before the last cadence. Harmonic rhythm: one chord per bar, two at cadences. Voicing: left hand broken chords spanning a 10th, no close thirds below C3. Tension and release: suspensions (4-3, 9-8), appoggiaturas on strong beats.-- **Melody.** Range C4-C6. Contour: arch per phrase, peak about 2/3 through. Density: 0.5-2 notes per beat. Motif: a leap then stepwise return; transform it (octave up, in the bass) at the climax.-- **Arrangement.** intro -> theme (question, answer) -> build -> hush -> coda. Transitions: a breath (caesura) before a sudden hush. Endings: a rolled tonic into the pedal.-- **Grooves:** none. **Avoid:** octaves in both hands on one downbeat (peaks); a compressor.--## `minimalist`: minimalist / pulse--hypnotic, curious, clean: interlocking ostinatos that change slowly. Tempo 96-144 bpm, meters 4/4, 12/8, 5/4, 7/8, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| arp | `marimba` | -0.5 | -20 | piano (`piano`, -4 dB), pluck (`softPluck`, 3 dB) |-| lead | `marimba` | 3.1 | -17 | - |-| bass | `marimba` | -4.9 | -21 | - |-| counter | `vibes` | 3.7 | -27 | - |-| chords | `piano` | 4 | -37.1 | - |-| kick | `kick` | -6 | - | - |-| ghost | `snare` | -6 | - | - |-| perc | `hat` | 0 | - | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: dorian, lydian, aeolian, major, mixolydian. Qualities: open 5ths, add9, quartal stacks. Tendencies: a two-chord cycle for 8-16 bars, then one note changes. Harmonic rhythm: slow; the ostinato is the rhythm. Voicing: mid-register, interlocking; no doubled roots. Tension and release: phase shifts, added beats, a new bass note under the same pattern.-- **Melody.** Range C4-C6. Contour: cells, not tunes. Density: 2-4 onsets per beat in the ostinato. Motif: a 5-8 note cell; change ONE thing every 8-16 bars (add, drop, rotate).-- **Arrangement.** additive: one layer at a time. Transitions: a change at least every 16 bars. Endings: subtractive, or a hard stop.-- **Grooves:** pulse. **Avoid:** a big climax; a change more often than every 4 bars.--## `jazz`: jazz / swing--loose, warm, clever: swing ride, walking bass, comping piano. Tempo 80-200 bpm, meters 4/4, 3/4, swing 0.6-0.67.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `piano` | 8 | -32.5 | - |-| lead | `vibes` | 3.8 | -16 | piano (`piano`, 0 dB), clarinet (`woodwind`, 0 dB), flute (`woodwind`, 0 dB), brass (`brass`, -3 dB) |-| bass | `bass` | -1.3 | -18 | - |-| counter | `woodwind` | 8.5 | -21 | - |-| kick | `kick` | -0.2 | -24 | - |-| snare | `snare` | 0 | -26 | - |-| ghost | `snare` | 7.5 | -28 | - |-| hat | `hat` | 21 | -26 | - |-| perc | `hat` | 18 | -30 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, dorian, mixolydian, melodicMinor, blues. Qualities: 7ths required; 9ths, 13ths, altered dominants (7b9, 7#11). Tendencies: ii-V-I, iii-VI-ii-V turnarounds, tritone substitutions, backdoor bVII7-I. Harmonic rhythm: two chords a bar at turnarounds. Voicing: rootless shell voicings (3-7, 7-3) in the middle; the walking bass owns roots. Tension and release: altered dominants, chromatic approach chords; release on a 6/9 or maj7.-- **Melody.** Range A3-C6. Contour: bebop lines: chord tones on beats, approach notes between. Density: swung 8ths with rests. Motif: a riff restated over changing chords (the chords change under it).-- **Arrangement.** head (theme) -> solos -> head out. Transitions: a 2-bar break, trading 4s. Endings: a tag (the last 2 bars three times) or a ritard on a 6/9.-- **Grooves:** swing, brushes, shuffle. **Avoid:** straight 8ths, triads only.--## `lullaby`: lullaby--soft, rocking, safe. Tempo 56-78 bpm, meters 3/4, 6/8, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| lead | `celesta` | 5.3 | -17 | musicBox (`musicBox`, 0 dB), piano (`piano`, 0 dB), flute (`woodwind`, -2 dB) |-| arp | `harp` | 4 | -28.3 | - |-| bass | `harp` | 6 | -26 | - |-| counter | `musicBox` | 4 | -31.7 | - |-| chords | `strings` | -8.5 | -28 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, majorPentatonic, mixolydian. Qualities: triads, add9, sus2. Tendencies: I-IV-I rocking, plagal cadences, a gentle ii. Harmonic rhythm: one chord per bar. Voicing: close, mid-high. Tension and release: almost none; a minor lullaby is flagged for the human check (tips into eerie).-- **Melody.** Range C4-C6. Contour: rocking stepwise, falling phrase ends. Density: 1-2 notes per beat. Motif: a 2-bar rocking figure repeated with a changed ending.-- **Arrangement.** melody + gentle arpeggio, nothing percussive. Transitions: none needed. Endings: the tonic, soft, rolled.-- **Grooves:** none. **Avoid:** drums, surprise, bright highs.--## `chiptune`: chiptune--8-bit, bright, game-like: two pulses, a triangle, noise drums. Tempo 110-170 bpm, meters 4/4, 6/8, swing 0.5-0.56.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| lead | `pulse` | 7.4 | -16 | square (`pulse`, -2 dB) |-| arp | `pulse` | 7 | -23.1 | - |-| bass | `triangle` | 0.2 | -18 | - |-| kick | `noiseDrum` | 7.6 | -18 | - |-| snare | `noiseDrum` | 6.7 | -20 | - |-| hat | `noiseDrum` | -10 | -28 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, aeolian, dorian, mixolydian. Qualities: triads; chords are faked by fast arpeggios. Tendencies: I-vi-IV-V, i-bVI-bVII, key changes up a step. Harmonic rhythm: one chord per bar. Voicing: arpeggio 16ths across an octave. Tension and release: a held dominant arpeggio, a pitch-bend-free chromatic climb.-- **Melody.** Range C4-C7. Contour: hooky, leaping. Density: 8ths and 16ths. Motif: a 1-bar hook, answered, sequenced.-- **Arrangement.** 4 voices max: lead, arp, triangle bass, noise. Transitions: a drum fill, a key change. Endings: a fanfare button.-- **Grooves:** fourFloor, bounce, shuffle, skip. **Avoid:** reverb, more than 4 voices, pads.--## `lofi`: dusty lo-fi hip-hop--hazy, nostalgic, crackly: FM e-piano, vinyl, a lazy swung beat (the dusty cousin of lo-fi electronic). Tempo 68-90 bpm, meters 4/4, swing 0.55-0.62.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `ePiano` | 5.2 | -20 | - |-| lead | `ePiano` | 7.5 | -17 | guitar (`guitar`, 2 dB), flute (`woodwind`, -2 dB) |-| bass | `bass` | -2.1 | -19 | - |-| counter | `fmBell` | 4 | -30.1 | - |-| kick | `kick` | -2.6 | -17 | - |-| snare | `snare` | 6.2 | -22 | - |-| ghost | `snare` | 6 | -27.1 | - |-| hat | `hat` | 4 | -43 | - |-| perc | `hat` | 4 | -29 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, dorian, aeolian. Qualities: maj9, m9, 13, m11. Tendencies: 2-4 chord loops, ii-V drifts. Harmonic rhythm: 1-2 chords a bar. Voicing: e-piano 4-note voicings. Tension and release: a borrowed iv.-- **Melody.** Range C4-C6. Contour: lazy, behind the beat. Density: sparse. Motif: a 2-bar sampled-sounding phrase.-- **Arrangement.** 4 or 8 bar loop with variations. Transitions: a filter or a drop-out. Endings: fade or tape stop.-- **Grooves:** bounce, halfTime, shuffle. **Avoid:** using it when the brief says clean or upbeat (then use lofiElectronic).--## `orchestral`: orchestral / epic--big and heroic: brass theme, string ostinato engine, choir, timpani. Tempo 70-140 bpm, meters 4/4, 3/4, 6/8, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| lead | `brass` | 9.2 | -16 | strings (`strings`, 0 dB), horn (`brass`, -2 dB), flute (`woodwind`, -2 dB) |-| chords | `strings` | -0.4 | -19 | - |-| arp | `strings` | 4.4 | -20 | - |-| bass | `strings` | 0.9 | -19 | - |-| counter | `choir` | -1.7 | -22 | flute (`woodwind`, -3 dB), harp (`harp`, 0 dB) |-| perc | `timpani` | 4.2 | -17 | - |-| kick | `kick` | -3.3 | -17 | - |-| snare | `snare` | 5.2 | -24 | - |-| hat | `hat` | 4 | -32 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, aeolian, dorian, mixolydian, harmonicMinor. Qualities: triads and power 5ths, sus4 resolving, major IV in minor. Tendencies: i-bVI-bIII-bVII, I-bVII-IV-I (mixolydian heroism), chromatic mediants for arrivals, a pedal under the build. Harmonic rhythm: one chord per 1-2 bars, faster into cadences. Voicing: brass in the middle in 3rds and 5ths, strings octaves above, bass in octaves. Tension and release: a long dominant pedal with the ostinato rising, sus4 held; release to the tonic major with everything.-- **Melody.** Range brass G3-C5 (heroic), strings up to A6. Contour: a rising 4th or 5th then steps; big arcs. Density: long notes over a busy ostinato. Motif: a fanfare cell (rising 4th/5th + rhythm) developed: fragment it in the build, augment it at the climax.-- **Arrangement.** intro (ostinato alone) -> theme (strings) -> theme (brass) -> build -> tutti climax -> quiet coda. Transitions: timpani roll or snare build into downbeats; a bar of silence before the last statement. Endings: a big held chord with timpani, or a hard cut.-- **Grooves:** epic, build, tension, pulse. **Avoid:** all families at once all the time; a brass lead above C6.--## `suspense`: suspense / horror--unsettling, cold, withheld: low drones, heartbeat pulse, high bowed harmonics, stingers. Tempo 50-110 bpm, meters 4/4, 5/4, 3/4, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `strings` | -0.8 | -21 | - |-| bass | `sub` | -6.1 | -20 | - |-| lead | `bowedSolo` | 7.3 | -19 | choir (`choir`, -2 dB), cello (`bowedSolo`, 0 dB) |-| counter | `celesta` | 8 | -27 | choir (`choir`, -4 dB), bell (`fmBell`, -8 dB) |-| arp | `strings` | 2.7 | -22 | - |-| kick | `kick` | -3.4 | -17 | - |-| ghost | `snare` | -4 | -27 | - |-| perc | `timpani` | 8.4 | -18 | - |-| hat | `hat` | 0 | -32 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: phrygian, locrian, harmonicMinor, wholeTone, aeolian. Qualities: clusters, minor 2nds, tritones, minor-major 7th, augmented triads. Tendencies: a pedal that never resolves, chromatic crawl up or down by semitone, i-bII (phrygian), sudden major chord a tritone away. Harmonic rhythm: static: one sound for 4-8 bars, then a jolt. Voicing: very low and very high with an empty middle. Tension and release: withhold resolution; a stinger (all voices, one hit) on the scare; silence right before it.-- **Melody.** Range extremes: below C3 or above C6. Contour: a 2-3 note cell, often a semitone. Density: sparse, irregular. Motif: a semitone sigh or a tritone leap, repeated slower each time.-- **Arrangement.** drone -> pulse enters -> rising ostinato -> stinger on the hit -> silence -> aftermath drone. Transitions: cut to silence; a slow crescendo that stops short. Endings: unresolved: a held cluster, or a single low hit.-- **Grooves:** pulse, tension, epic. **Avoid:** a major cadence, melody in the middle register, busy drums.--## `rock`: rock / band--live-band energy: driven guitars, bass locked to the kick, a tight kit, maybe organ. Tempo 90-160 bpm, meters 4/4, 6/8, swing 0.5-0.52.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `strings` | -0.9 | -19 | organ (`organ`, -4 dB), piano (`piano`, -3 dB) |-| lead | `leadSynth` | 9.9 | -16 | guitar (`guitar`, 2 dB) |-| bass | `bass` | -0.8 | -17 | - |-| counter | `organ` | 6 | -30.4 | - |-| kick | `kick` | 1.2 | -13 | - |-| snare | `snare` | 11.2 | -17 | - |-| ghost | `snare` | 0 | -26 | - |-| hat | `hat` | 20.6 | -27 | - |-| perc | `hat` | 17 | -26 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: mixolydian, aeolian, major, blues, dorian. Qualities: power chords (root-5th-octave), triads, sus4. Tendencies: I-bVII-IV, i-bVI-bVII, riffs on the pentatonic, a chorus a 4th up. Harmonic rhythm: one chord per bar in verses, two in choruses. Voicing: power chords low (E2-E4), the bass doubling the root in 8ths. Tension and release: a riff held on the V, a stop before the chorus.-- **Melody.** Range E3-A5. Contour: riff-based, pentatonic, strong beats. Density: 8ths. Motif: a 1-2 bar riff that IS the song; the vocal-like lead answers it.-- **Arrangement.** riff intro -> verse -> pre -> chorus -> verse -> chorus -> bridge -> chorus x2. Transitions: a drum fill and a crash into every section. Endings: a big held last chord with a fill, or a stop on 1.-- **Grooves:** rock, halfTime, shuffle, fourFloor. **Avoid:** swing, soft attacks, long pads; the guitar tone here is an approximation: say so.--## `hipHop`: hip-hop / trap--head-nod or dark trap: heavy 808, crisp clap, rolling hats, a moody loop on top. Tempo 70-100 bpm, meters 4/4, swing 0.52-0.6.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| bass | `sub` | -2.5 | -15 | - |-| chords | `piano` | 6 | -36.8 | pad (`warmPad`, -3 dB) |-| lead | `softPluck` | 2.7 | -18 | bell (`fmBell`, -2 dB), flute (`woodwind`, -2 dB), choir (`choir`, -4 dB) |-| counter | `strings` | 4 | -29.2 | - |-| kick | `kick` | 1.4 | -13 | - |-| snare | `snare` | 10.2 | -18 | - |-| ghost | `snare` | 0 | -26 | - |-| hat | `hat` | 23.6 | -26 | - |-| perc | `hat` | 19.9 | -29 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: aeolian, phrygian, harmonicMinor, dorian. Qualities: minor triads, m7, dim, a single dark chord for 2 bars. Tendencies: 2-chord minor loops, i-bVI, i-bII (phrygian menace), a melody over one chord. Harmonic rhythm: one chord per 1-2 bars. Voicing: piano or bells high, the 808 low with nothing between. Tension and release: the 808 sliding or dropping out; a switch-up after 8 bars.-- **Melody.** Range C4-C6. Contour: short repeated figures. Density: sparse over busy hats. Motif: a 1-2 bar loop that repeats (the loop is the hook); vary it every 8 bars.-- **Arrangement.** intro (loop alone) -> 8-bar blocks with drops, switch-ups -> outro loop. Transitions: drop the drums for a bar, a hat roll into the downbeat. Endings: the loop alone, or a cut.-- **Grooves:** trap, bounce, halfTime, broken. **Avoid:** an 808 that owns everything below 150 Hz with no harmonics (phones): check stems.--## `house`: house / EDM--euphoric, dancing, bright: four-on-the-floor, offbeat bass, stabs, a big pad. Tempo 118-128 bpm, meters 4/4, swing 0.5-0.54.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `organ` | 5.2 | -21 | pad (`warmPad`, -3 dB), piano (`piano`, -3 dB) |-| bass | `bass` | 0.3 | -16 | - |-| lead | `softPluck` | 4.3 | -17 | synth (`leadSynth`, -2 dB) |-| counter | `warmPad` | 6.9 | -23 | - |-| arp | `softPluck` | 4.5 | -22 | - |-| kick | `kick` | 2.6 | -12 | - |-| snare | `snare` | 10.7 | -18 | - |-| ghost | `snare` | 1 | -26 | - |-| hat | `hat` | 12 | -26 | - |-| perc | `hat` | 18.3 | -27 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: aeolian, dorian, major, mixolydian. Qualities: m7, m9, maj7 stabs; piano house triads. Tendencies: i-VI-III-VII, vi-IV-I-V, 2-chord dorian vamps; a long pedal in the build. Harmonic rhythm: one chord per bar or per 2 bars; stabs on offbeats. Voicing: stabs mid-register, the bass on the offbeat 8th. Tension and release: filter build + snare build + one beat of silence; release = the drop.-- **Melody.** Range C4-C6. Contour: repetitive riffs. Density: 8ths and 16ths. Motif: a 1-bar riff repeated 4-8 times with one change.-- **Arrangement.** intro (kick + hats) -> groove -> breakdown (pad + motif) -> build -> drop -> outro (kick). Transitions: 16- or 32-bar blocks; builds of 8. Endings: DJ-friendly: strip back to kick and hats.-- **Grooves:** fourFloor, build, broken. **Avoid:** swing, busy harmony, a quiet drop.--## `synthwave`: synthwave / retro--neon-nostalgic, cinematic 80s: big gated snare, pulsing 8th bass, lush pads, a soaring lead. Tempo 80-118 bpm, meters 4/4, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `strings` | -2.1 | -21 | pad (`warmPad`, -2 dB) |-| bass | `bass` | -0.3 | -17 | - |-| lead | `leadSynth` | 11.7 | -16 | brass (`brass`, -2 dB) |-| arp | `softPluck` | 4.1 | -22 | - |-| counter | `fmBell` | 4 | -29.1 | - |-| kick | `kick` | 1.4 | -13 | - |-| snare | `snare` | 11.7 | -17 | - |-| ghost | `snare` | 0 | -26 | - |-| hat | `hat` | 12 | -28 | - |-| perc | `hat` | 16.2 | -29 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: aeolian, dorian, major, lydian. Qualities: minor triads, add9, maj7, sus2. Tendencies: i-bVI-bIII-bVII, vi-IV-I-V, a lydian II for the neon lift. Harmonic rhythm: one chord per bar. Voicing: wide pads, bass in driving 8ths on the root. Tension and release: a long build on the V with the arp rising; release with the gated snare.-- **Melody.** Range A3-E6. Contour: soaring, long notes with glide. Density: long lead notes over a busy arp. Motif: a 2-bar singable lead phrase, stated then lifted an octave.-- **Arrangement.** pad intro -> bass + drums -> lead theme -> breakdown -> lead an octave up -> outro pad. Transitions: a tom-like fill (build), a drop-out bar. Endings: the pad alone, long tail.-- **Grooves:** fourFloor, halfTime, rock, build. **Avoid:** trap hats, acoustic instruments, a dry mix.--## `world`: world / modal folk--rooted, spacious, rhythmic: a drone, a modal melody on plucked strings or a flute, hand percussion cycles (write your own melody; name the tradition you draw on). Tempo 60-150 bpm, meters 7/8, 9/8, 12/8, 6/8, 4/4, 5/4, swing 0.5-0.56.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| lead | `woodwind` | 8.7 | -16 | pluck (`guitar`, 2 dB), marimba (`marimba`, 1 dB), reed (`woodwind`, 0 dB), bowed (`bowedSolo`, 0 dB) |-| counter | `harp` | 10 | -38.1 | - |-| arp | `guitar` | 8 | -24.2 | - |-| chords | `warmPad` | -3.1 | -25 | - |-| bass | `sub` | -9.6 | -22 | - |-| kick | `timpani` | 0.3 | -17 | - |-| ghost | `snare` | 9.5 | -24 | - |-| perc | `hat` | 8 | -28 | - |-| hat | `hat` | 6 | -30 | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: dorian, phrygian, mixolydian, aeolian, majorPentatonic, minorPentatonic, harmonicMinor. Qualities: a drone (tonic + 5th) more than chords; modal colour chords sparingly. Tendencies: modal: stay on the tonic drone, move the melody through the mode; a second drone a step away for contrast. Harmonic rhythm: the percussion cycle carries it; harmony changes rarely. Voicing: open 5ths, the drone low and wide. Tension and release: the mode's colour note held against the drone; release on the tonic.-- **Melody.** Range a 10th around the drone. Contour: ornamented steps (grace notes, turns), phrases that return to the drone note. Density: flowing 8ths and 16ths with long held notes. Motif: a modal phrase that grows by adding ornaments on repeats.-- **Arrangement.** drone alone -> melody free -> percussion enters -> faster, denser -> return to the drone. Transitions: an accelerando, a percussion break. Endings: the melody alone on the tonic over the drone.-- **Grooves:** hand, pulse, brushes. **Avoid:** copying a traditional melody; Western functional cadences everywhere.--## `choral`: choral / sacred--vast, human, reverent: voices in parts, organ, bells, a slow swell. Tempo 50-90 bpm, meters 4/4, 3/4, swing 0.5-0.5.--| Slot | Voice | Gain dB | Stem target dB | Alternates (voice, gain dB, uncalibrated) |-|---|---|---|---|---|-| chords | `choir` | -9.9 | -19 | organ (`organ`, -4 dB), strings (`strings`, -4 dB) |-| lead | `choir` | -3.1 | -17 | bowed (`bowedSolo`, 0 dB), flute (`woodwind`, -2 dB) |-| bass | `organ` | 8 | -21 | - |-| counter | `fmBell` | 4 | -30.5 | - |-| arp | `harp` | 6 | -26.3 | - |-| perc | `timpani` | 5.5 | -20 | - |-| kick | `timpani` | -6 | - | - |--Stem targets: starting numbers from a neutral test signal (advisory until a human listens).--- **Harmony language.** Modes: major, aeolian, dorian, lydian. Qualities: triads in 4 parts, suspensions, the picardy third. Tendencies: chorale motion: I-IV-V-I, vi-IV-I-V, plagal amen (IV-I), deceptive V-vi before the final cadence. Harmonic rhythm: one chord per beat or per half bar (chorale), slower in swells. Voicing: SATB spacing: no gaps wider than an octave between upper voices, bass free; avoid parallel 5ths. Tension and release: 4-3 suspensions, a held dominant; release on a plagal amen.-- **Melody.** Range C4-G5 (singable). Contour: stepwise, phrase-shaped like breath. Density: 1 note per beat or slower. Motif: a hymn-like phrase whose cadence changes each time.-- **Arrangement.** a single voice -> full parts -> a swell -> a hush -> the final chord. Transitions: a fermata (breath) between phrases. Endings: a plagal amen or a picardy third, long tail.-- **Grooves:** pulse. **Avoid:** fast rhythms, drums, choir as a lead above G5.diff --git a/plugins/anidoodle/skills/anidoodle/references/workflows/launch-video-kit.md b/plugins/anidoodle/skills/anidoodle/references/workflows/launch-video-kit.mdindex 76552b0..da62e37 100644--- a/plugins/anidoodle/skills/anidoodle/references/workflows/launch-video-kit.md+++ b/plugins/anidoodle/skills/anidoodle/references/workflows/launch-video-kit.md@@ -3,9 +3,10 @@The pieces anidoodle's own launch film is made of, in `engine/src/canvas-core/`, usable for anyproduct. The rules they serve are in `launch-video.md`.-## Start from the template (16 s, one file)+## Start from the template (16 s, 16:9, one file)-`launchTemplate.ts` turns data into a film: two or three prompts answered by plates drawing+`launchTemplate.ts` turns data into a film, 1920x1080 (16:9; square, 4:5 and 9:16 from the+template are coming): two or three prompts answered by plates drawingthemselves in a chat thread, a type frame between them, and an end card with your install lines.`launchExample.ts` is a complete one for a made-up product. Copy its shape, not its contents:the plates and the score are the product's own, made for its brief.@@ -14,7 +15,7 @@ the plates and the score are the product's own, made for its brief.import { C } from "./launchKit";import { makeLaunchFilm } from "./launchTemplate";import { dashboardSketch, onboardingSketch } from "./myProductPlates"; // drawn for YOUR subject-import { myProductScore } from "./myProductScore"; // composed for YOUR brief+import { myProductScore } from "./myProductScore"; // a Piece written for YOUR briefexport const myLaunch = makeLaunchFilm({title: "Your Product", subtitle: "the one line it lives by",@@ -25,7 +26,7 @@ export const myLaunch = makeLaunchFilm({words: [[{ text: "IDEA IN.", style: "ink", color: C.ink }, { text: "ART OUT.", style: "ink", color: C.accent }]],tagline: "One sentence that says what it is",install: ["npm install your-product", "your-product init"],- bpm: 96, // the tempo of the score you composed; the brief sets it, there is no default+ bpm: 96, // the tempo of the score you wrote; the brief sets it, there is no defaultaskBeats: 6, typeBeats: 4, endBeats: 8, claimBar: 4,score: myProductScore, // or null for a silent film});@@ -48,10 +49,10 @@ answers and scrolling, a gentle lean onto each new card, full-frame word pages band the end card blooming open and holding. The corner mark (your name, hand-lettered) stepsaside before any lean. Real holds are declared, so the gate passes. Sync wins over length: thescore plays at the film's bpm exactly, so every cut sits on its downbeats, and the film is made-whole bars of the score (`gridScore`: the stretch section repeated or dropped, then the end-card-hold, which is a hold, grows or shrinks to the bar; the tail rings out in whole bars). A score in-4/4 with no pickup, starting on frame 0. If no form fits, the build throws: compose a 1-bar-stretch section or change askBeats/endBeats. Render refuses a beat-grid film whose score is more+whole bars of the score (`gridScore`: the end-card hold, which is a hold, grows or shrinks to the+bar; the tail rings out in whole bars). A score in 4/4 with no pickup, starting on frame 0. If it+does not fit, the build throws and names the score lengths in bars that would, or change+askBeats/endBeats/claimBar. Render refuses a beat-grid film whose score is morethan 0.5 % off its bpm. The bed is set to -14 LUFS with the true peak at or under -1 dBTP(`musicBed`); a dynamic piece stops at the peak ceiling first and render says how far short;`limit: true` lets a look-ahead limiter take those peaks instead.@@ -60,7 +61,7 @@ than 0.5 % off its bpm. The bed is set to -14 LUFS with the true peak at or undeto the user's subject (`references/styles.md`): draw their dashboard, their mascot, theirproduct's world in the chosen hand, as a still plus its `*Draw` film. anidoodle's own plates(the lighthouse and fox in `launchExample.ts`) are placeholders, never a user's film. The score-is composed for the brief's style, mood and length (`references/music/compose.md`); `score` is+is written for the brief's style, mood and length (`references/music/README.md`); `score` isrequired (`null` means silent), `bpm` has no default, and the template refuses anidoodle's ownpieces, by identity, by title and by content (the same novelty gate `music.mjs check` runs).@@ -72,12 +73,17 @@ pieces, by identity, by title and by content (the same novelty gate `music.mjs c| `tagline`, `install[]`, `footer` | the end card; install lines are shown exactly as given || `bpm` (required), `fps`, `askBeats`, `typeBeats`, `endBeats` | the beat grid (a beat is 60 x fps / bpm frames) and each part's length in beats || `claimBar` | land the end card on this bar's downbeat, counting from bar 0 (`claimBar: 4` = frame 4 x bar); throws if it cannot. A longer last ask is really longer, never slowed |-| `score` (required) or `audio` | the score composed for this product (the `Material` function compose.md writes, or a `Piece`), as a bed; `null` for silence; or your own finished mix (not checked) |+| `score` (required) or `audio` | the score written for this product (a function returning a `Piece`), as a bed; `null` for silence; or your own finished mix (not checked) |The template refuses a feature list (more than 3 asks) and an end card too short to read.## The parts, for a film of your own shape+A film built from the parts can be any size today: set its `meta.W` and `meta.H` (1080x1920 for+9:16) and pass the same `W` and `H` to `bloomFrame` and `typeFrame`, which default to 1920x1080.+`writeOn` and `useCam` follow the film's frame. `drawChatFrame` and the template's layout are+drawn for 1920x1080, so frame them with the camera; never crop a wide render.+**`launchKit.ts`**: timing and UI.- Easing: `ramp`, `inOut`, `out3`, `in3`, `expo`, a closed-form `spring`, `press` (a buttonpress that dips and springs back). Camera: `Cam`, `camLerp` (zoom travels in log space),diff --git a/plugins/anidoodle/skills/anidoodle/references/workflows/launch-video.md b/plugins/anidoodle/skills/anidoodle/references/workflows/launch-video.mdindex 42bb1e1..a2679ec 100644--- a/plugins/anidoodle/skills/anidoodle/references/workflows/launch-video.md+++ b/plugins/anidoodle/skills/anidoodle/references/workflows/launch-video.md@@ -32,7 +32,7 @@ that invents its subject draws a mascot of a product, not the product.## Made for this product, every frame and every noteThe film's pictures are drawn for this product's subject in the style recipe the brief picked-(`references/styles.md`); its score is composed for this brief. anidoodle's own plates and+(`references/styles.md`); its score is written for this brief. anidoodle's own plates andpieces are examples of the craft, never material for someone else's film.## The story@@ -84,10 +84,9 @@ pieces are examples of the craft, never material for someone else's film.## Sound- **Music first, heard as an mp3 by a human** before it scores anything (you cannot hear it).- Compose it for THIS brand: pick the style and a mood per section from the brief (energy,- audience, where it runs), then write the notes (`references/music/compose.md`). anidoodle's own- launch chose chill lo-fi electronic, one example (`references/music/styles/lofi-electronic.md`);- never reuse our score or a stock piece.+ Write it for THIS brand: pick the style and a mood per section from the brief (energy,+ audience, where it runs), then write the notes (`references/music/README.md`); `music.mjs check`+ must pass. Never reuse our score or a stock piece.- **Balance by stem RMS, not only LUFS**: an integrated -14 LUFS hid a sub 7-10 dB too hot.- **Cut on downbeats, not every beat.** Land the claim on a chord (launch3's lands on bar 26,the home chord); `beatGrid().solve()` fits a flexible segment so it does.@@ -101,7 +100,9 @@ pieces are examples of the craft, never material for someone else's film.a platform version rather than pushing one master everywhere. Cut whole beats; never speedthe whole film up (it breaks the beat grid and reads rushed).- **Shapes**: `16x9` for YouTube and the site, `1x1` or `4x5` for feeds, `9x16` for Reels and- Shorts. Reframe per shape from one timeline; never crop a wide render.+ Shorts. Reframe per shape; never crop a wide render. The template renders 16:9 today, and the+ other shapes from it are coming. A film built from the parts can target any size now: set+ `meta.W`/`meta.H` and lay it out for that frame (`launch-video-kit.md`).- **The first frame is the thumbnail.** Platforms and players show frame 1 before play. Makeit legible and on brand (anidoodle's is the wall of styles; the template's is the prompt, big,mid-sentence); never a blank, a fade from black, or a whole chat window too small to read.