Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

music: a style is a vocabulary, the composer writes every note - compose(material) with no default notes, 21 style vocabularies, 15 groove families, mood controls, novelty fingerprint; launchLofi3 is composed material (bit-identical); Daylight kept only as the copy fixture; demos out of PIECES; score.ts an empty skeleton

Alex Greenshpune6c2e5180a13
diff --git a/skills/anidoodle/engine/src/canvas-core/music/calibration.ts b/skills/anidoodle/engine/src/canvas-core/music/calibration.ts
new file mode 100644
index 0000000..9189c89
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/music/calibration.ts
@@ -0,0 +1,21 @@
+// 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 } from "./theory";
+import type { Material } from "./compose";
+import type { StyleVocab } from "./vocab";
+
+export const testMaterial = (v: StyleVocab, o: { loop?: boolean; bars?: number } = {}): Material => {
+ const 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) + 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: "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/skills/anidoodle/engine/src/canvas-core/music/compose.ts b/skills/anidoodle/engine/src/canvas-core/music/compose.ts
new file mode 100644
index 0000000..6ba61fd
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/music/compose.ts
@@ -0,0 +1,152 @@
+// 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 } from "./tables";
+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[];
+ lead?: LineSpec; counter?: LineSpec; arp?: LineSpec;
+ /** 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, scales generated groove density in this section */ 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>>;
+ /** gainDb per slot, after measuring stems */ levels?: Partial<Record<Slot, number>>;
+ moodControls?: MoodControls; swing?: number; dyn?: [number, number]; tail?: number; loop?: boolean;
+};
+
+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(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) => m.motifs?.[x] ?? 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", line(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", line(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, line(b * bpb, bar[ln]!, { role: "drum", v: vel[ln], bpb }));
+ }
+ }
+ 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;
+ const ns = line(x.from * bpb, lineOf(spec), { 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);
+ }
+
+ // ---- 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, gainDb = lv !== undefined ? lv : trim ? v.gainDb + trim : v.gainDb;
+ 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, dyn = m.dyn ?? [0.62, 0.66];
+ 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: [{ id: "a", bars: B, mood: m.mood, key: m.key, mode: m.mode, melody: ["stepwise", "hook"], dyn: mood ? [dyn[0] + e * 0.2, dyn[1] + e * 0.2] : dyn, ending: "tail", repeatable: false }] },
+ 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 })),
+ 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.
+ */
+export const refitMaterial = (m: Material, seconds: number): Material => {
+ const secs = m.sections, want = seconds - (m.tail ?? 3.2);
+ 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; });
+ if (si < 0 || want <= 0) return m;
+ let best: { m: Material; cost: number } | null = null;
+ for (let r = 0; r <= 64; r++) {
+ const m2: Material = { ...m, sections: secs.map((s, i) => (i === si ? { ...s, repeat: r } : s)).filter((s) => (s.repeat ?? 1) > 0) };
+ 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/skills/anidoodle/engine/src/canvas-core/music/grooves.ts b/skills/anidoodle/engine/src/canvas-core/music/grooves.ts
new file mode 100644
index 0000000..66b597a
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/music/grooves.ts
@@ -0,0 +1,184 @@
+// 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. */
+export type LiteralGroove = { kick?: string[]; snare?: string[]; ghost?: string[]; hat?: string[]; perc?: string[] };
+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 pick = (xs?: string[]) => (xs && xs.length ? xs[abs % 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/skills/anidoodle/engine/src/canvas-core/music/index.ts b/skills/anidoodle/engine/src/canvas-core/music/index.ts
index 688f30c..4dbb53e 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/index.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/index.ts
@@ -8,16 +8,28 @@ export * from "./render";
export * from "./meter";
export * from "./guards";
export * from "./score-text";
-export * from "./lofiElectronic";
+export * from "./grooves";
+export * from "./vocab";
+export * from "./vocabTrim";
+export * from "./compose";
+export * from "./novelty";
+export * from "./calibration";
export * as instruments from "./instruments";
+export * as orchestra from "./orchestra";
import { nocturne, pianoPhrase8 } from "./pieces/nocturne";
-import { launchLofi, launchLofi2, launchLofi3 } from "./pieces/launch";
-import { lofiDaylight, lofiDaylightLoop } from "./pieces/lofi";
-export { lofiDaylightSpec, lofiDaylightLoopSpec, DAYLIGHT_PROGRESSION } from "./pieces/lofi";
-export { launchLofi3Spec, LAUNCH_PROGRESSION } from "./pieces/launch";
+import { launchLofi, launchLofi2, launchLofi3, launchLofi3Material } 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";
-export { lofiDaylight, lofiDaylightLoop, 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 = { lofiDaylight, lofiDaylightLoop, launchLofi, launchLofi2, launchLofi3, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm, ghostFixture };
+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 };
diff --git a/skills/anidoodle/engine/src/canvas-core/music/novelty.ts b/skills/anidoodle/engine/src/canvas-core/music/novelty.ts
new file mode 100644
index 0000000..611d8b9
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/music/novelty.ts
@@ -0,0 +1,72 @@
+// 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:
+// 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.
+// 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.
+import type { Piece, Note } from "./plan";
+import { beatsPerBar } from "./plan";
+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 };
+/** 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;
+
+const add = (b: Bag, k: string, w = 1) => b.set(k, (b.get(k) ?? 0) + w);
+const q = (x: number) => Math.round(x * 12); // 1/12 beat: 16ths and triplets both land
+const grams = <T>(xs: T[], n: number, f: (g: T[]) => string, b: Bag, prefix = "") => { for (let i = 0; i + n <= xs.length; i++) add(b, prefix + f(xs.slice(i, i + n))); };
+/** One voice per role: the top note of each onset (bass: the bottom). */
+const voice = (notes: Note[], low = false) => { const by = new Map<number, Note>(); for (const n of notes) { const k = Math.round(n.t * 96), o = by.get(k); if (!o || (low ? n.p < o.p : n.p > o.p)) by.set(k, n); } return [...by.values()].sort((a, b) => a.t - b.t); };
+const quality = (name: string) => { const s = name.replace(/^[A-G][#b]?/, "").split("/")[0]; return /^(maj|M|Δ)/.test(s) ? "maj7" : /^(m|min|-)(?!aj)/.test(s) ? (/b5|ø/.test(s) ? "hdim" : "min") : /dim|°/.test(s) ? "dim" : /aug|\+/.test(s) ? "aug" : /sus/.test(s) ? "sus" : /\d/.test(s) ? "dom" : "maj"; };
+
+export const fingerprint = (p: Piece): Fingerprint => {
+ const bpb = beatsPerBar(p.plan.meter), F = Object.fromEntries(Object.keys(NOVELTY_WEIGHTS).map((k) => [k, new Map()])) as Fingerprint;
+ const role = (r: string) => p.parts.flatMap((pt) => pt.notes.filter((n) => n.role === r));
+ const rhythm = (ns: Note[], b: Bag, pre: string) => {
+ const bars = new Map<number, number[]>(); for (const n of ns) { const bar = Math.floor(n.t / bpb + 1e-9); (bars.get(bar) ?? bars.set(bar, []).get(bar)!).push(q(n.t - bar * bpb)); }
+ for (const pos of bars.values()) add(b, `${pre}bar:${pos.join(",")}`);
+ const ioi = ns.slice(1).map((n, i) => q(n.t - ns[i].t)); grams(ioi, 3, (g) => g.join(","), b, `${pre}ioi:`);
+ };
+ const mel = voice(role("melody"));
+ rhythm(mel, F.melodyRhythm, "");
+ const iv = mel.slice(1).map((n, i) => n.p - mel[i].p);
+ grams(iv.map((x) => (x > 0 ? "u" : x < 0 ? "d" : "s")), 4, (g) => g.join(""), F.melodyContour);
+ grams(iv, 3, (g) => g.join(","), F.melodyIntervals);
+ rhythm(voice(role("color")), F.lineRhythm, "color:"); rhythm(voice(role("bass"), true), F.lineRhythm, "bass:");
+ for (const pt of p.parts) if (pt.role === "drum") { const bars = new Map<number, number[]>(); for (const n of pt.notes) { const bar = Math.floor(n.t / bpb + 1e-9); (bars.get(bar) ?? bars.set(bar, []).get(bar)!).push(q(n.t - bar * bpb)); } for (const pos of bars.values()) add(F.drums, `${pt.inst}${pt.opts?.rim ? "rim" : ""}:${[...new Set(pos)].sort((a, b) => a - b).join(",")}`); }
+ 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;
+};
+
+const cosine = (a: Bag, b: Bag) => { let d = 0, na = 0, nb = 0; for (const [k, v] of a) { na += v * v; const w = b.get(k); if (w) d += v * w; } for (const v of b.values()) nb += v * v; return na && nb ? d / Math.sqrt(na * nb) : 0; };
+/** 0 = nothing in common, 1 = the same music. Features empty in both pieces are left out of the mean. */
+export const similarity = (a: Fingerprint, b: Fingerprint) => {
+ let s = 0, w = 0; const by: Partial<Record<Feature, number>> = {};
+ for (const f of Object.keys(NOVELTY_WEIGHTS) as Feature[]) { if (!a[f].size && !b[f].size) continue; const c = cosine(a[f], b[f]); by[f] = +c.toFixed(3); s += c * NOVELTY_WEIGHTS[f]; w += NOVELTY_WEIGHTS[f]; }
+ return { score: w ? s / w : 0, by };
+};
+
+/** Every melody 6-note fragment as (interval, duration) pairs: transposition-free. */
+const fragments = (p: Piece) => { const mel = voice(p.parts.flatMap((pt) => pt.notes.filter((n) => n.role === "melody" || n.role === "color"))); const out = new Set<string>(); for (let i = 0; i + 6 <= mel.length; i++) { const g = mel.slice(i, i + 6); out.add(g.slice(1).map((n, j) => `${n.p - g[j].p}/${q(n.t - g[j].t)}`).join(" ")); } return out; };
+
+/** Score a piece against a corpus. `family` names the pieces that ARE this piece (its own cuts) and are skipped. */
+export const novelty = (p: Piece, corpus: Record<string, () => Piece>, skip: string[] = [], threshold = NOVELTY_THRESHOLD) => {
+ const fp = fingerprint(p), mine = fragments(p);
+ const rows = Object.entries(corpus).filter(([name]) => !skip.includes(name)).map(([name, mk]) => {
+ const other = mk(), sim = similarity(fp, fingerprint(other)), theirs = fragments(other);
+ let reused = 0; for (const f of mine) if (theirs.has(f)) reused++;
+ return { name, score: +sim.score.toFixed(3), by: sim.by, reusedFragments: reused };
+ }).sort((a, b) => b.score - a.score);
+ const worst = rows[0];
+ return { rows, threshold, pass: rows.every((r) => r.score <= threshold && r.reusedFragments === 0), worst };
+};
diff --git a/skills/anidoodle/engine/src/canvas-core/music/pieces/copyFixture.ts b/skills/anidoodle/engine/src/canvas-core/music/pieces/copyFixture.ts
index caf6ceb..4f08574 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/pieces/copyFixture.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/pieces/copyFixture.ts
@@ -1,32 +1,34 @@
-// LO-FI ELECTRONIC EXAMPLES, written on the style API (lofiElectronic.ts). "Daylight": D major, 96
-// bpm, the I-vi-IV-V loop Dmaj9 Bm9 Gmaj9 A13 with rootless pads that move by step
-// (F#-A-C#-E, F#-A-C#-D, F#-A-B-D, G-B-C#-F#). The hook asks on the A13 (ends off the tonic) and the
-// loop answers on Dmaj9; its second pass lifts the G and A bars. No ePiano, no vinyl: clean.
-// lofiDaylightLoop 12 bars, 30 s, seamless: render with renderLoop (tools/music.mjs picks it).
-// lofiDaylight the arranged form: intro (IV V into home), hook, hook + sparkle, half-time,
-// breakdown, the drop landing on Dmaj9, outro. refit() stretches it for a film.
+// 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 { lofiElectronic, type LofiChord, type LofiSpec } from "../lofiElectronic";
+import { composePiece, type Material } from "../compose";
-export const DAYLIGHT_PROGRESSION: LofiChord[] = [
- { name: "Dmaj9", pad: "[F#3 A3 C#4 E4]", root: "D2", walk: "A1", hook: "r:.5 F#4:.5 A4:.5 D5:1 C#5:.5 A4:1", sparkle: "r:1 A5:.5 C#6:.5 E6:2" },
- { name: "Bm9", pad: "[F#3 A3 C#4 D4]", root: "B1", walk: "F#1", hook: "r:.5 F#4:.5 B4:.5 C#5:.5 D5:1 B4:1", sparkle: "r:1 F#5:.5 A5:.5 C#6:2" },
- { name: "Gmaj9", pad: "[F#3 A3 B3 D4]", root: "G1", walk: "D2", hook: ["r:.5 D5:.5 E5:.5 F#5:1 E5:.5 D5:1", "r:.5 D5:.5 E5:.5 F#5:.5 A5:1 F#5:1"], sparkle: "r:1 F#6:.5 D6:.5 B5:2" },
- { name: "A13", pad: "[G3 B3 C#4 F#4]", root: "A1", walk: "E2", hook: ["C#5:1.5 B4:.5 A4:1 r:1", "E5:1.5 C#5:.5 E5:1 r:1"], sparkle: "C#6:1 B5:1 A5:2" },
-];
-// levels: set by measuring the stems against LOFI_STEM_TARGETS (node tools/music.mjs stems lofiDaylightLoop)
-const LEVELS = { pad: -3, lead: 6, sparkle: 8, sub: -6, kick: 0.5, snare: 8, ghost: 4, hat: 20 };
-
-export const lofiDaylightLoopSpec = (): LofiSpec => ({
- title: "Daylight (loop)", seed: 96, bpm: 96, key: "D", progression: DAYLIGHT_PROGRESSION, loop: true, tail: 3.5, mood: "joy", levels: LEVELS,
- sections: [{ kind: "hook", bars: 4 }, { kind: "hook", bars: 4, sparkle: true }, { kind: "half", bars: 2, sparkle: true }, { kind: "hook", bars: 2 }],
-});
-export const lofiDaylightSpec = (): LofiSpec => ({
- title: "Daylight", seed: 96, bpm: 96, key: "D", progression: DAYLIGHT_PROGRESSION, home: 0, mood: "joy", levels: LEVELS,
+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] },
+ half: { kick: ["C4:2 r:2"], snare: ["r:2 C4:2"], hat: ["C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected]"] },
+ },
sections: [
- { kind: "intro", bars: 2 }, { kind: "hook", bars: 4 }, { kind: "hook", bars: 4, sparkle: true, stretch: true }, { kind: "half", bars: 2, sparkle: true },
- { kind: "breakdown", bars: 2 }, { kind: "drop", bars: 1 }, { kind: "outro", bars: 2 },
+ { 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 lofiDaylightLoop = (): Piece => lofiElectronic(lofiDaylightLoopSpec());
-export const lofiDaylight = (): Piece => lofiElectronic(lofiDaylightSpec());
+export const daylightCopy = (): Piece => composePiece(daylightCopyMaterial());
diff --git a/skills/anidoodle/engine/src/canvas-core/music/pieces/launch.ts b/skills/anidoodle/engine/src/canvas-core/music/pieces/launch.ts
index 83b4be5..acbacd5 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/pieces/launch.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/pieces/launch.ts
@@ -14,7 +14,7 @@
// [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 { lofiElectronic, type LofiChord, type LofiSpec } from "../lofiElectronic";
+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,26 +67,39 @@ 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 on the lo-fi electronic style API (lofiElectronic.ts); its audio is bit-identical to the
-// hand-written v6 (md5 of renderPiece at 48 kHz d20789f2344e6fff0d2a380c7c7825d2, guarded by tools/music-unit.mjs).
+// 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;
-/** The launch loop ii-V-I-vi in C: Dm9 G13 Cmaj9 Am9, rootless pads, a 4-bar hook and sparkle answer. */
-export const LAUNCH_PROGRESSION: LofiChord[] = [
- { name: "Dm9", pad: PAD[0], root: "D2", walk: "A1", hook: HOOK[0], sparkle: SPARK[0] },
- { name: "G13", pad: PAD[1], root: "G1", walk: "D2", hook: HOOK[1], sparkle: SPARK[1] },
- { name: "Cmaj9", pad: PAD[2], root: "C2", walk: "G1", hook: HOOK[2], sparkle: SPARK[2] },
- { name: "Am9", pad: PAD[3], root: "A1", walk: "E2", hook: HOOK[3], sparkle: SPARK[3] },
-];
-export const launchLofi3Spec = (): LofiSpec => ({
- title: "anidoodle launch, cut 3", seed: 2027, bpm: LAUNCH_BPM, key: "C", progression: LAUNCH_PROGRESSION, home: 2, land: "claim",
- intro: [{ name: "Cmaj9", pad: PAD_INTRO[0] }, { name: "Am9", pad: PAD_INTRO[1] }], outroNote: "C5",
- sections: [
- { kind: "intro", bars: 2 }, { kind: "groove", bars: 4 }, { kind: "hook", bars: 2 }, { kind: "hook", bars: 3, sparkle: true }, { kind: "hook", bars: 3 },
- { kind: "half", bars: 2 }, { kind: "groove", bars: 1, sparkle: true }, { kind: "groove", bars: 2 }, { kind: "hook", bars: 3 },
- { kind: "groove", bars: 2, sparkle: true }, { kind: "breakdown", bars: 2, sparkle: true }, { kind: "drop", bars: 1, id: "claim" }, { kind: "outro", bars: 2 },
- ],
-});
-export const launchLofi3 = (): Piece => lofiElectronic(launchLofi3Spec());
+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] },
+ half: { kick: ["C4:2 r:2"], snare: ["r:2 C4:2"], hat: ["C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected]"] },
+ },
+ 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 => 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;
diff --git a/skills/anidoodle/engine/src/canvas-core/music/vocab.ts b/skills/anidoodle/engine/src/canvas-core/music/vocab.ts
new file mode 100644
index 0000000..21563ab
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/music/vocab.ts
@@ -0,0 +1,247 @@
+// 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/skills/anidoodle/engine/src/canvas-core/music/vocabMore.ts b/skills/anidoodle/engine/src/canvas-core/music/vocabMore.ts
new file mode 100644
index 0000000..0fd49af
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/music/vocabMore.ts
@@ -0,0 +1,121 @@
+// 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/skills/anidoodle/engine/src/canvas-core/music/vocabTrim.ts b/skills/anidoodle/engine/src/canvas-core/music/vocabTrim.ts
new file mode 100644
index 0000000..d207919
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/music/vocabTrim.ts
@@ -0,0 +1,247 @@
+// 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/skills/anidoodle/engine/src/canvas-core/score.ts b/skills/anidoodle/engine/src/canvas-core/score.ts
index 4560b20..8284a4d 100644
--- a/skills/anidoodle/engine/src/canvas-core/score.ts
+++ b/skills/anidoodle/engine/src/canvas-core/score.ts
@@ -1,39 +1,27 @@
-// 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).
+// 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.
//
-// 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";
+// 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";
import { filmAudio } from "./music/render";
-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 }) },
- ],
+/** 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
});
-/** 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);
+/** 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);
+};