Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.
TypeScript agent-skillsanimationcanvasclaude-codeclaude-pluginclaude-skillscodex-plugincreative-codecreative-codingcreative-toolsdeterministicgenerative-arthand-drawnillustrationlaunch-videomotion-designmotion-graphicspluginprocedural-generationskill
stem meter v2 + recalibration: stemRms reads the MID ((L+R)/2 after pan, 30 Hz high-passed) over 20 ms blocks gated like BS.1770 (-70 dBFS absolute, -20 dB relative), not the left channel sample by sample above -80 dB. A hard-left part now reads as hard-right; tails, pedal rings and a harp's DC offset (which swung one stem 4.8 dB between a 4- and 8-bar render) no longer move it. Targets converted on the renders they were set on (legacy render of each style's test piece; launchLofi3 for the listened lofiElectronic): centred sustained parts unchanged (bass -0.1), decaying/sparse parts +3..+14 dB. calibrate now trims calibrated styles' v2 voices to their listened targets (never moving the targets), legacy material never takes a trim, cap 12 -> 18 dB. All 21 test pieces within 1.4 dB of every stem target at 4 and 8 bars (lofiElectronic worst 0.4). Struck stems for the gentle transient gain now include mallets/bells and timpani (suspense -16.70 -> -16.00)
Alex Greenshpun6a5b090f6259
diff --git a/skills/anidoodle/engine/src/canvas-core/music/compose.ts b/skills/anidoodle/engine/src/canvas-core/music/compose.tsindex 9e10439..086a8bb 100644--- a/skills/anidoodle/engine/src/canvas-core/music/compose.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/compose.ts@@ -131,7 +131,8 @@ export const composePiece = (m: Material): Piece => {v = resolveVoice(v, m.bpm);let dGain = 0; if (mood) { const r = moodVoice(slot, v, mood); v = r.voice; dGain = r.dGain; }const lv = m.levels?.[slot];- const trim = pick !== undefined ? 0 : VOCAB_TRIM[vocab.id]?.[slot] ?? 0; let gainDb = trim ? v.gainDb + trim : v.gainDb; if (lv) gainDb += lv;+ // a legacy (shipped) score keeps the gains it was listened at: no trim+ const trim = pick !== undefined || m.legacy ? 0 : VOCAB_TRIM[vocab.id]?.[slot] ?? 0; let gainDb = trim ? v.gainDb + trim : v.gainDb; if (lv) gainDb += lv;// a timpani (or any pitched drum voice) playing a drum lane is tuned to the key: the tonic in its low registerif (v.inst === "timpani" && role(slot) === "drum" && typeof pick !== "object") { const tp = pcOf(m.key.replace(/m$/, "")), lo = typeof v.opts?.pitch === "number" ? (v.opts.pitch as number) - 5 : slot === "kick" ? 31 : 38; /* the tonic nearest the voice's own register */ v = { ...v, opts: { ...(v.opts ?? {}), pitch: lo + ((tp - (lo % 12) + 12) % 12) } }; }if (vocab.stemTargets[slot] !== undefined) targets[slot] = vocab.stemTargets[slot] + dGain + (pick === undefined ? VOCAB_TARGET_FIX[vocab.id]?.[slot] ?? 0 : 0); // a mood that lifts the hats lifts their target toodiff --git a/skills/anidoodle/engine/src/canvas-core/music/meter.ts b/skills/anidoodle/engine/src/canvas-core/music/meter.tsindex 9581955..5dfed0a 100644--- a/skills/anidoodle/engine/src/canvas-core/music/meter.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/meter.ts@@ -104,8 +104,26 @@ export const measure = (chans: Float32Array[], sr: number): Meters => {return { durationS: dur, lufs: l.integrated, lra: l.lra, shortMax: l.shortMax, dbtp: tp.dbtp, samplePeakDb: tp.samplePeakDb, onsetsPerS: on.length / dur, onsetCount: on.length, centroidHz: c.mean, centroidEnergyHz: c.energyWeighted, lastOnsetS: on.length ? on[on.length - 1] : 0, shortTerm: l.shortTerm };};-/** RMS of a stem over its active samples (|x| > 1e-4), left channel, dBFS: the level a part plays at when it plays. */-export const stemRms = (x: Float32Array, floor = 1e-4) => { let s = 0, c = 0; for (let i = 0; i < x.length; i++) { const v = x[i]; if (Math.abs(v) > floor) { s += v * v; c++; } } return c ? 10 * Math.log10(s / c + 1e-12) : -Infinity; };+/**+ * The level a part plays at when it plays, dBFS: the RMS of its MID ((L + R) / 2, after its pan: what a phone's one+ * speaker plays, and a centred mono part reads exactly its own level), high-passed at 30 Hz, over the 20 ms blocks where it+ * is really playing.+ * Gated like BS.1770 loudness: blocks under -70 dBFS never count, then blocks more than 20 dB under the part's own+ * level drop out, so a reverb tail, a pedal ring or a noise floor does not dilute it. (v1 read the LEFT channel only,+ * sample by sample above a -80 dB floor: a hat panned right read low, a ride panned left read high, and every long+ * tail pulled a part down; the targets were converted at the sound-v2 merge on the renders they were set on.)+ */+export const stemRms = (L: Float32Array, R: Float32Array = L, sr = 48000) => {+ const B = Math.max(1, Math.round(0.02 * sr)), n = Math.min(L.length, R.length), pw: number[] = [];+ // audible band only (a 30 Hz high-pass, like loudness's RLB stage): a voice's DC or subsonic drift is not level (a harp's DC offset swung it 4.8 dB)+ const w = Math.tan(Math.PI * Math.min(30, 0.45 * sr) / sr), k = 1 / (1 + Math.SQRT2 * w + w * w), b0 = k, a1 = 2 * (w * w - 1) * k, a2 = (1 - Math.SQRT2 * w + w * w) * k;+ let x1 = 0, x2 = 0, y1 = 0, y2 = 0;+ const mid = new Float64Array(n); for (let i = 0; i < n; i++) { const x = (L[i] + R[i]) * 0.5, y = b0 * (x - 2 * x1 + x2) - a1 * y1 - a2 * y2; x2 = x1; x1 = x; y2 = y1; y1 = y; mid[i] = y; }+ for (let a = 0; a < n; a += B) { const e = Math.min(n, a + B); let s = 0; for (let i = a; i < e; i++) s += mid[i] * mid[i]; pw.push(s / (e - a)); }+ const abs = pw.filter((p) => p > 1e-7); if (!abs.length) return -Infinity;+ const rel = (abs.reduce((a, p) => a + p, 0) / abs.length) * 0.01, gated = abs.filter((p) => p >= rel);+ return 10 * Math.log10(gated.reduce((a, p) => a + p, 0) / gated.length);+};export type StemRow = { id: string; rmsDb: number; targetDb: number | null; offDb: number | null; ok: boolean };/*** Stem balance: each part's active RMS against its target; a part more than `tolDb` off is flagged.@@ -114,7 +132,7 @@ export type StemRow = { id: string; rmsDb: number; targetDb: number | null; offD*//** Guards win over stem targets: the melody must clear the masking guard, so the lead may sit up to `LEAD_HEADROOM_DB` above its target before it is flagged. */export const LEAD_HEADROOM_DB = 3;-export const stemBalance = (stems: Record<string, [Float32Array, Float32Array]>, targets: Record<string, number>, tolDb = 3, headroom: Record<string, number> = { lead: LEAD_HEADROOM_DB }) => {- const rows: StemRow[] = Object.entries(stems).map(([id, [L]]) => { const rmsDb = stemRms(L), t = targets[id] ?? null, off = t === null ? null : rmsDb - t; return { id, rmsDb, targetDb: t, offDb: off, ok: off === null || (off >= -tolDb && off <= tolDb + (headroom[id] ?? 0)) }; });+export const stemBalance = (stems: Record<string, [Float32Array, Float32Array]>, targets: Record<string, number>, tolDb = 3, headroom: Record<string, number> = { lead: LEAD_HEADROOM_DB }, sr = 48000) => {+ const rows: StemRow[] = Object.entries(stems).map(([id, [L, R]]) => { const rmsDb = stemRms(L, R, sr), t = targets[id] ?? null, off = t === null ? null : rmsDb - t; return { id, rmsDb, targetDb: t, offDb: off, ok: off === null || (off >= -tolDb && off <= tolDb + (headroom[id] ?? 0)) }; });return { rows, pass: rows.every((r) => r.ok), tolDb, headroom };};diff --git a/skills/anidoodle/engine/src/canvas-core/music/mixProfiles.ts b/skills/anidoodle/engine/src/canvas-core/music/mixProfiles.tsindex a7b8ddf..d9f5145 100644--- a/skills/anidoodle/engine/src/canvas-core/music/mixProfiles.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/mixProfiles.ts@@ -82,8 +82,8 @@ export type MixProfile = {/** default sends per role for parts that name none (over ROLE_SEND) */ sends?: Partial<Record<Role, number>>;/** gentle masters only: the transient-aware gain on plucked stems (mixDsp.transientGain; null = off) */ transient?: { maxDb: number; thrDb: number; ratio: number } | null;};-/** The stems whose attacks pin a static gentle master at the true-peak ceiling: plucks, plucked basses, piano. */-export const isStruck = (inst: InstId, opts?: Record<string, number | boolean | string>) => EQ_CLASS[inst] === "pluck" || EQ_CLASS[inst] === "piano" || (inst === "bass" && opts?.kind !== "synth");+/** The struck stems whose attacks pin a static gentle master at the true-peak ceiling: plucks, plucked basses, piano, mallets and bells, timpani. */+export const isStruck = (inst: InstId, opts?: Record<string, number | boolean | string>) => ["pluck", "piano", "bell", "boom"].includes(EQ_CLASS[inst]) || (inst === "bass" && opts?.kind !== "synth");export const TRANSIENT_DEFAULT = { maxDb: 6, thrDb: 4, ratio: 3 };const conv = (rt60: number, predelayMs: number, o: Partial<Space> = {}): Space => ({ kind: "conv", rt60, predelayMs, hp: 220, lp: 8000, er: 0.45, late: 0.32, size: 0.55, highMult: 0.5, lowMult: 1.1, ...o });const fdn = (rt60: number, predelayMs: number, o: Partial<Space> = {}): Space => ({ kind: "fdn", rt60, predelayMs, hp: 250, lp: 7500, er: 0.4, late: 0.3, size: 0.5, highMult: 0.45, lowMult: 1.1, mod: 1, ...o });diff --git a/skills/anidoodle/engine/src/canvas-core/music/render.ts b/skills/anidoodle/engine/src/canvas-core/music/render.tsindex 00fad63..df06efb 100644--- a/skills/anidoodle/engine/src/canvas-core/music/render.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/render.ts@@ -151,8 +151,7 @@ const renderV2 = (piece: Piece, sr: number, o: RenderOpts = {}): Rendered => {if (style.master === "gentle" && tg && isStruck(pt.inst, pt.opts)) report.transientGr = Math.max(report.transientGr ?? 0, transientGain(sL, sR, sr, tg));if (pump && dk!.parts.includes(pt.id)) for (let i = 0; i < n; i++) { sL[i] *= pump[i]; sR[i] *= pump[i]; }// corrective EQ, then match the stem's RMS back (+-3 dB cap): EQ shapes the tone, the fader keeps the calibrated balance- // the stem meter reads the part as the fader set it (pre-EQ): the EQ is energy-neutral in the audible band, while stemRms- // (left channel, -80 dB floor) also counts subsonic residue the high-pass removes, which read one harp 6.8 dB "hotter"+ // the stem meter reads the part as the fader set it (pre-EQ, after its pan): the EQ is energy-neutral in the audible bandconst pre = o.stems ? [Float32Array.from(sL), Float32Array.from(sR)] as [Float32Array, Float32Array] : null;const before = audible(sL, sR, sr), e = partEq(prof, pt.inst, pt.role); runEq(sL, eqChain(sr, e)); runEq(sR, eqChain(sr, e));const after = audible(sL, sR, sr), mk = after > 0 && before > 0 ? Math.min(db(3), Math.max(db(-3), Math.sqrt(before / after))) : 1;@@ -249,7 +248,7 @@ export const fitScore = (piece: Piece, seconds: number) => fitToDuration(piece.r/** Each part's stem level against the piece's targets (unmastered, pre-room: the mix as the parts were set). */export const measureStems = (piece: Piece, sr: number, o: RenderOpts = {}, tolDb = 3) => {const r = renderPiece(piece, sr, { ...o, stems: true, master: "none" });- return stemBalance(r.stems, piece.stemTargets ?? {}, tolDb);+ return stemBalance(r.stems, piece.stemTargets ?? {}, tolDb, undefined, sr);};/** Look-ahead peak limiter (1.5 ms look-ahead, 120 ms release), used by dense styles only; `ceil` is linear. */diff --git a/skills/anidoodle/engine/src/canvas-core/music/vocab.ts b/skills/anidoodle/engine/src/canvas-core/music/vocab.tsindex a22d748..3c90c73 100644--- a/skills/anidoodle/engine/src/canvas-core/music/vocab.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/vocab.ts@@ -69,7 +69,7 @@ export const VOCAB: Partial<Record<StyleId, StyleVocab>> = {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,+ stemTargets: { kick: -14.5, snare: -19, hat: -24.5, bass: -18.5, chords: -22, lead: -15.5, counter: -20 }, 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",@@ -97,7 +97,7 @@ export const VOCAB: Partial<Record<StyleId, StyleVocab>> = {},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,+ stemTargets: { kick: -12.5, snare: -17, hat: -26, perc: -26, bass: -16, chords: -23, lead: -16, arp: -20.5, counter: -19.5 }, 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" },@@ -122,7 +122,7 @@ export const VOCAB: Partial<Record<StyleId, StyleVocab>> = {},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,+ stemTargets: { chords: -18.5, bass: -19.5, lead: -17, counter: -7.5, arp: -21.5, kick: -16.5, 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",@@ -148,7 +148,7 @@ export const VOCAB: Partial<Record<StyleId, StyleVocab>> = {},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,+ stemTargets: { chords: -20, bass: -22, lead: -17.5, counter: -26.5, arp: -23.5, kick: -20.5, 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" },@@ -173,7 +173,7 @@ export const VOCAB: Partial<Record<StyleId, StyleVocab>> = {},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,+ stemTargets: { chords: -19.5, arp: -20.5, lead: -13, counter: -19.5, bass: -21, kick: -20.5, snare: -26, ghost: -24.5, 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)" },@@ -198,7 +198,7 @@ export const VOCAB: Partial<Record<StyleId, StyleVocab>> = {},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,+ stemTargets: { lead: -13, chords: -21, arp: -20, counter: -18.5, bass: -18, kick: -15.5, snare: -20, ghost: -26, hat: -24, perc: -29.5 }, 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" },diff --git a/skills/anidoodle/engine/src/canvas-core/music/vocabMore.ts b/skills/anidoodle/engine/src/canvas-core/music/vocabMore.tsindex 2425227..f06adda 100644--- a/skills/anidoodle/engine/src/canvas-core/music/vocabMore.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/vocabMore.ts@@ -10,20 +10,21 @@ const kit = (o: number, soft: number, extra: Partial<Record<Slot, Voice>> = {}):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 });+// stemTargets are in the v2 stem meter (meter.stemRms: mid, 20 ms blocks, gated): converted at the sound-v2 merge from the v1+// (left-channel, -80 dB floor) numbers by measuring each style on the legacy render it was set on, so the balance is the same.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"],+ stemTargets: T({ lead: -13.5, arp: -25, bass: -26, counter: -19.5, chords: -26.5 }), 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"],+ alternates: {}, fx: {}, stemTargets: T({ lead: -15, chords: -23.5, bass: -24.5, counter: -30.5 }), 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" },@@ -31,28 +32,28 @@ export const VOCAB_MORE: StyleVocab[] = [{ 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"],+ stemTargets: T({ arp: -19, lead: -14, bass: -24, counter: -21, chords: -25.5 }), 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, { kind: "upright", 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"],+ stemTargets: T({ kick: -24.5, snare: -26, ghost: -24.5, hat: -23, perc: -30, bass: -18, chords: -21.5, lead: -13, counter: -18.5, arp: -22 }), 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"],+ stemTargets: T({ lead: -15, arp: -23.5, bass: -27, counter: -20.5, chords: -28.5 }), 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"],+ stemTargets: T({ lead: -16, arp: -20, bass: -18, kick: -17.5, snare: -20.5, 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" },@@ -61,21 +62,21 @@ export const VOCAB_MORE: StyleVocab[] = [alternates: { lead: { guitar: V("guitar", "melody", 2, undefined, 0.35), flute: V("woodwind", "melody", -2, undefined, 0.35) } },// the record: keys, counter and bass breathe with the kick; tape wow/flutter/drive (mood-scaled); the dusty chain (lofiFx.ts: sampler drums, warbly keys, tape colour, vinyl, tilt, room tone)fx: { duck: { by: "kick", parts: ["chords", "counter", "bass"], depth: 0.35 }, tape: { wowCents: 6, wowHz: 0.7, flutterCents: 1.2, flutterHz: 8, drive: 1.35 }, lofi: LOFI_DUSTY },- 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"],+ stemTargets: T({ kick: -17.5, snare: -21, ghost: -22, hat: -26.5, perc: -29, bass: -19, chords: -19.5, lead: -16.5, counter: -18.5, arp: -22 }), 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"],+ stemTargets: T({ lead: -13, chords: -19.5, arp: -21, bass: -20, counter: -23, perc: -17.5, kick: -17.5, snare: -23, 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"],+ stemTargets: T({ chords: -21.5, bass: -20, lead: -19.5, counter: -19, arp: -23, kick: -17.5, ghost: -27, perc: -18.5, 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" },@@ -83,42 +84,42 @@ export const VOCAB_MORE: StyleVocab[] = [// chords: an electric guitar (ensemble.ts, bridge pickup, clean DI) driven through the mix chain's amp + cab (mixDsp ampSim), not string stabspalette: { chords: V("guitar", "accomp", 4, { kind: "electric", pickup: "bridge", drive: 1, amp: 5, width: 0.8, 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, { kind: "pick", drive: 2.2 }), counter: V("organ", "color", -6, { bright: 1.2 }, 0.3), ...kit(0, 0.5) },alternates: { chords: { strings: V("strings", "accomp", -6, { attack: 0.005, release: 0.08, bright: 2.0, width: 0.9, grid: true }, 0.2), organ: V("organ", "accomp", -4, { bright: 1.3 }, 0.25), piano: V("piano", "accomp", -3, undefined, 0.2) }, lead: { guitar: V("guitar", "melody", 17, { kind: "electric", pickup: "neck", drive: 1, amp: 3.5 }, 0.3) } }, 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"],+ stemTargets: T({ kick: -13.5, snare: -16.5, ghost: -26, hat: -23.5, perc: -25.5, bass: -17, chords: -15.5, lead: -16, counter: -18.5, arp: -22 }), 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"],+ stemTargets: T({ kick: -13.5, snare: -17, ghost: -26, hat: -23, perc: -29.5, bass: -15, chords: -21.5, lead: -17.5, counter: -25.5, arp: -22 }), 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, { kind: "synth", 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"],+ stemTargets: T({ kick: -12.5, snare: -17, ghost: -26, hat: -26, perc: -27, bass: -16, chords: -20, lead: -16.5, counter: -23.5, 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, { kind: "synth", 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"],+ stemTargets: T({ kick: -13.5, snare: -16.5, ghost: -26, hat: -28, perc: -29.5, bass: -17, chords: -22, lead: -16, counter: -20.5, arp: -22 }), 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"],+ stemTargets: T({ lead: -14.5, counter: -7.5, arp: -20.5, chords: -25.5, bass: -22, kick: -17, ghost: -20, 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, kind: "pipe" }, 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, kind: "pipe" }, 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"],+ stemTargets: T({ chords: -20, lead: -17, bass: -23, counter: -21.5, arp: -23.5, 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.tsindex d207919..baab5f7 100644--- a/skills/anidoodle/engine/src/canvas-core/music/vocabTrim.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/vocabTrim.ts@@ -1,247 +1,234 @@// 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.+// voice's stem to its target on a neutral test phrase (stem meter v2: mid, gated). Calibrated (listened) styles keep their targets and get trims only; legacy scores never take a trim.import type { Slot } from "./vocab";export const VOCAB_TRIM: Record<string, Partial<Record<Slot, number>>> = {+ lofiElectronic: {+ chords: 2.4,+ lead: -1.1,+ counter: 5.5,+ bass: 0.4,+ kick: -3.1,+ snare: -1.6,+ hat: -0.5+ },drive: {- chords: 5.3,- lead: 7.4,- counter: 12,- bass: 3.1,- kick: 0.5,- snare: 8.5,- arp: 1.2,- perc: 8.3+ chords: 6.7,+ lead: 10.7,+ counter: 16.8,+ bass: 3,+ kick: -1,+ snare: 6.5,+ arp: 1.8,+ perc: 5.5},cinematic: {- chords: 5.2,- lead: 4.5,- counter: 12,- bass: 4.3,- kick: -4.4,- arp: 7.4+ chords: 6.1,+ lead: 6.9,+ counter: 18,+ bass: 2.4,+ kick: -1.8,+ arp: 8.5},ambient: {chords: 2.5,- lead: 1.3,- counter: 0.8,+ lead: 1.6,+ counter: 1.2,bass: -0.3,- kick: -2.4,- arp: 3.1+ kick: -3,+ arp: 1.6},folk: {- chords: 12,- lead: 12,- counter: 11.2,- bass: 1.6,+ chords: 18,+ lead: 14.7,+ counter: 12.7,+ bass: -1.2,kick: -0.5,- ghost: 9.4,- arp: 12,- perc: 12+ ghost: 8.3,+ arp: 16.5,+ perc: 17.4},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+ chords: 3.8,+ lead: 4,+ counter: 12.8,+ bass: -1.4,+ kick: -1.8,+ snare: 3.2,+ hat: 10.3,+ arp: 13.3,+ perc: 11.5},musicBox: {- chords: 4.7,- lead: 3.5,- counter: 4.3,- bass: 5,- arp: 3+ chords: 2.3,+ lead: 2.9,+ counter: 5,+ bass: 6.3,+ arp: 3.9},nocturne: {- chords: 12,- lead: 12,- counter: 12,- bass: 6.3+ chords: 17.7,+ lead: 14.1,+ counter: 14.6,+ bass: 6.5},minimalist: {- chords: 12,- lead: 2.1,- counter: 11.7,- bass: -3.9,- arp: 2.5+ chords: 18,+ lead: 4,+ counter: 15.9,+ bass: -4.3,+ arp: 3.1},jazz: {- chords: 12,- lead: 3.8,- counter: 10.5,- bass: 0.7,- kick: 2.8,- ghost: 10.5,- hat: 12,- perc: 11+ chords: 18,+ lead: 3.5,+ counter: 12.7,+ bass: -2,+ kick: 0.2,+ ghost: 10,+ hat: 17.2,+ perc: 8.5},lullaby: {- chords: 3.5,- lead: 5.3,- counter: 12,- bass: 12,- arp: 12+ chords: 4,+ lead: 4.7,+ counter: 18,+ bass: 13,+ arp: 16.4},chiptune: {lead: 7.4,- bass: -0.8,- kick: 9.6,+ bass: -0.7,+ kick: 9.2,snare: 10.7,- arp: 12+ arp: 13.2},lofi: {- chords: 10.2,- lead: 3.5,- counter: 12,- bass: -0.1,- kick: 3.4,- snare: 9.2,- ghost: 12,- hat: 12+ chords: 9.3,+ lead: 3.6,+ counter: 18,+ bass: -0.5,+ kick: 0.2,+ snare: 5.2,+ ghost: 14.5,+ hat: 18},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+ chords: 4.5,+ lead: 14.7,+ counter: 0,+ bass: 2.4,+ kick: -5.6,+ snare: 5.3,+ arp: 7.7,+ perc: 2.9},suspense: {- chords: 5.2,- lead: 7.3,- counter: 12,- bass: -0.1,- kick: -3.4,- arp: 8.7,- perc: 10.4+ chords: 5.8,+ lead: 7.2,+ counter: 13.5,+ bass: 0,+ kick: -0.3,+ arp: 8.9,+ perc: 8.2},rock: {- chords: 5.1,+ chords: 11.5,lead: 11.9,- counter: 12,- bass: 1.2,- kick: 1.2,- snare: 8.2,- hat: 8.6,- perc: 7+ counter: 18,+ bass: 0.7,+ kick: -1,+ snare: 5.8,+ hat: 8.4,+ perc: 5.7},hipHop: {- chords: 12,- lead: -1.3,- counter: 12,- bass: 1.5,- kick: 1.4,- snare: 7.2,- hat: 9.6,- perc: 9.9+ chords: 18,+ lead: -1.1,+ counter: 17.6,+ bass: 1.6,+ kick: -2.7,+ snare: 5.7,+ hat: 9.2,+ perc: 7.7},house: {- chords: 11.2,+ chords: 12.7,lead: -0.7,- counter: 10.9,- bass: 3.3,- kick: 1.6,- snare: 6.7,- arp: 1.5,- perc: 7.3+ counter: 11.5,+ bass: 3.5,+ kick: 0.3,+ snare: 4.8,+ arp: 2,+ perc: 4.1},synthwave: {- chords: 3.9,+ chords: 4.9,lead: 11.7,- counter: 12,- bass: 2.7,- kick: 1.4,- snare: 6.7,- arp: 1.1,- perc: 6.2+ counter: 16.7,+ bass: 2.8,+ kick: 1.2,+ snare: 4.3,+ arp: 1.2,+ perc: 3.5},world: {chords: 4.9,- lead: 8.7,- counter: 12,- bass: -1.6,- kick: 2.3,- ghost: 11.5,- arp: 12+ lead: 9.5,+ counter: 18,+ bass: -1.5,+ kick: 0.5,+ ghost: 12.5,+ arp: 16.7},choral: {- chords: -7.9,- lead: -3.1,- counter: 12,- bass: 12,- arp: 12,- perc: 9.5+ chords: -7.7,+ lead: -3.8,+ counter: 16.8,+ bass: 9.6,+ arp: 14,+ perc: 9.2}};-/** 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. */+/** Where an 18 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- },+ lofiElectronic: {},+ drive: {},cinematic: {- counter: -14.7+ counter: -8.9},ambient: {},folk: {- chords: -13,- lead: -2.8,- arp: -1.9,- perc: -5.8- },- playful: {- arp: -1.4+ chords: -6.5},+ playful: {},musicBox: {},- nocturne: {- chords: -6.3- },+ nocturne: {},minimalist: {- chords: -11.1+ chords: -4.6},jazz: {- chords: -10.5+ chords: -4},lullaby: {- counter: -4.7,- bass: -1,- arp: -4.3- },- chiptune: {- arp: -1.1+ counter: -1.2},+ chiptune: {},lofi: {- counter: -7.1,- ghost: -1.1,- hat: -13+ counter: -2.4,+ hat: -6.3},orchestral: {},- suspense: {- counter: -3- },+ suspense: {},rock: {- counter: -7.4+ counter: -8.6},hipHop: {- chords: -14.8,- counter: -4.2+ chords: -9.4},house: {},- synthwave: {- counter: -4.1- },+ synthwave: {},world: {- counter: -17.1,- arp: -3.2+ counter: -10.7},- choral: {- counter: -4.5,- arp: -2.3- }+ choral: {}};diff --git a/skills/anidoodle/engine/tools/ensemble-check.mjs b/skills/anidoodle/engine/tools/ensemble-check.mjsindex 7f477cd..0911a72 100644--- a/skills/anidoodle/engine/tools/ensemble-check.mjs+++ b/skills/anidoodle/engine/tools/ensemble-check.mjs@@ -88,7 +88,7 @@ if (cmd === "calibrate") {const parts = p.parts.filter((x) => ENS.has(x.inst) && (!slot || x.id === slot)); if (!parts.length) continue;const only = (x) => parts.some((q) => q.id === x.id);const a = M.renderPiece(p, SR, { stems: true, master: "none", only }), b = M.renderPiece({ ...p, legacy: true }, SR, { stems: true, master: "none", only });- for (const x of parts) { const nw = M.stemRms(a.stems[x.id][0]), old = M.stemRms(b.stems[x.id][0]); out.push({ style: v.id, slot: x.id, alt: nm, inst: x.inst, kind: x.opts?.kind ?? (x.opts?.reed ? "reed" : x.opts?.cello ? "cello" : ""), d: nw - old });+ for (const x of parts) { const nw = M.stemRms(...a.stems[x.id], SR), old = M.stemRms(...b.stems[x.id], SR); out.push({ style: v.id, slot: x.id, alt: nm, inst: x.inst, kind: x.opts?.kind ?? (x.opts?.reed ? "reed" : x.opts?.cello ? "cello" : ""), d: nw - old });console.log(` ${v.id.padEnd(15)} ${x.id.padEnd(8)} ${(nm ?? "").padEnd(9)} ${x.inst.padEnd(10)} ${String(out[out.length - 1].kind).padEnd(8)} v2-legacy ${(nw - old >= 0 ? "+" : "") + (nw - old).toFixed(1)} dB`); }}}diff --git a/skills/anidoodle/engine/tools/keys-demo.mjs b/skills/anidoodle/engine/tools/keys-demo.mjsindex 5e87141..aaf6cb0 100644--- a/skills/anidoodle/engine/tools/keys-demo.mjs+++ b/skills/anidoodle/engine/tools/keys-demo.mjs@@ -110,7 +110,7 @@ if (mode === "calibrate") {const p = M.composePiece(M.testMaterial(v, { bars: 4 }));if (!p.parts.some((x) => KEYS.has(x.inst))) continue;const a = M.renderPiece({ ...p, legacy: true }, 24000, { stems: true, master: "none" }), b = M.renderPiece({ ...p, legacy: false }, 24000, { stems: true, master: "none" });- for (const pt of p.parts) if (KEYS.has(pt.inst)) { const d = M.stemRms(b.stems[pt.id][0]) - M.stemRms(a.stems[pt.id][0]); rows.push([v.id, pt.id, pt.inst, JSON.stringify(pt.opts ?? {}), d]); }+ for (const pt of p.parts) if (KEYS.has(pt.inst)) { const d = M.stemRms(...b.stems[pt.id], 24000) - M.stemRms(...a.stems[pt.id], 24000); rows.push([v.id, pt.id, pt.inst, JSON.stringify(pt.opts ?? {}), d]); }}for (const r of rows) console.log(`${r[0].padEnd(15)} ${r[1].padEnd(8)} ${r[2].padEnd(12)} new-old ${r[4] >= 0 ? "+" : ""}${r[4].toFixed(1)} dB ${r[3]}`);const by = {}; for (const r of rows) (by[r[2]] ??= []).push(r[4]);diff --git a/skills/anidoodle/engine/tools/music-unit.mjs b/skills/anidoodle/engine/tools/music-unit.mjsindex a60c314..69a711c 100644--- a/skills/anidoodle/engine/tools/music-unit.mjs+++ b/skills/anidoodle/engine/tools/music-unit.mjs@@ -122,8 +122,12 @@ for (const secs of [70, 90, 110]) {assert(M.detectMode(M.line(0, src, { role: "melody", bpb: 4 }), ["lydian", "major", "aeolian", "dorian", "mixolydian"])[0].tonic !== "Db", "fixture must fool the raw detector");assert.deepEqual(M.planProblems(lp("Db", "lydian", src)), []); assert(M.planProblems(lp("E", "major", src)).length > 0);pass("Db lydian leaning on Ab is accepted (scale fits, tonic heard); a wrong key is still flagged");- const st = { lead: [new Float32Array([0.3 * 10 ** ((-16.5 + 5) / 20) / 0.3]), new Float32Array(1)] };- assert(M.stemBalance(st, { lead: -16.5 }).pass); assert(!M.stemBalance({ lead: [new Float32Array([10 ** ((-16.5 + 7) / 20)]), new Float32Array(1)] }, { lead: -16.5 }).pass); pass("stems: the lead may sit +3 dB over tolerance (guards win), not more");+ const cen = (x) => { const a = new Float32Array([x]); return [a, a]; }; // a centred part: the stem meter reads its mid+ assert(M.stemBalance({ lead: cen(10 ** ((-16.5 + 5) / 20)) }, { lead: -16.5 }).pass); assert(!M.stemBalance({ lead: cen(10 ** ((-16.5 + 7) / 20)) }, { lead: -16.5 }).pass); pass("stems: the lead may sit +3 dB over tolerance (guards win), not more");+ { const n = 48000, x = new Float32Array(n).map((_, i) => 0.1 * Math.sin(i / 7)), z = new Float32Array(n), lo = new Float32Array(n).map((_, i) => 0.001 * Math.sin(i / 7));+ const left = M.stemRms(x, z), right = M.stemRms(z, x), tail = M.stemRms(Float32Array.from([...x.slice(0, n / 2), ...lo.slice(0, n / 2)]), Float32Array.from([...x.slice(0, n / 2), ...lo.slice(0, n / 2)]));+ assert(Math.abs(left - right) < 1e-9 && Math.abs(tail - M.stemRms(x, x)) < 0.1, `mid meter: L ${left} R ${right}, tail ${tail}`);+ pass(`stem meter: a part panned hard left reads as hard right (${left.toFixed(1)} dB both; v1 read the left channel only), a -40 dB tail does not dilute it (${tail.toFixed(2)} vs ${M.stemRms(x, x).toFixed(2)})`); }const w = M.composePiece(M.testMaterial(M.VOCAB.world, { bars: 4 })), wr = M.renderPiece(w, SR), g = M.guardReport(wr, SR, wr.L.length / SR);assert(Number.isFinite(g.lufs) && g.ghost.windows > 0); pass(`guards run on a 7/8 score (${g.ghost.windows} windows)`); }diff --git a/skills/anidoodle/engine/tools/music.mjs b/skills/anidoodle/engine/tools/music.mjsindex a53c297..1a8f051 100644--- a/skills/anidoodle/engine/tools/music.mjs+++ b/skills/anidoodle/engine/tools/music.mjs@@ -214,17 +214,18 @@ const main = async () => {const calibrate = (M) => {const trim = {}, fix = {};for (const v of Object.values(M.VOCAB)) {- if (v.calibrated) continue; trim[v.id] = {}; fix[v.id] = {}; M.VOCAB_TARGET_FIX[v.id] = {};+ // calibrated (listened) styles: the targets never move, the voices are trimmed to them (sound v2 changed their levels); no target fix+ trim[v.id] = {}; fix[v.id] = {}; M.VOCAB_TARGET_FIX[v.id] = {};for (let pass = 0; pass < 3; pass++) {M.VOCAB_TRIM[v.id] = trim[v.id];const b = M.measureStems(M.composePiece(M.testMaterial(v)), STEM_SR);- for (const r of b.rows) if (r.offDb !== null && Number.isFinite(r.offDb)) trim[v.id][r.id] = +Math.max(-12, Math.min(12, (trim[v.id][r.id] ?? 0) - r.offDb)).toFixed(1); // capped: past 12 dB the gain is not the problem- if (pass === 2) { for (const r of b.rows) if (r.offDb !== null && Math.abs(r.offDb) > 1) fix[v.id][r.id] = +r.offDb.toFixed(1);+ for (const r of b.rows) if (r.offDb !== null && Number.isFinite(r.offDb)) trim[v.id][r.id] = +Math.max(-18, Math.min(18, (trim[v.id][r.id] ?? 0) - r.offDb)).toFixed(1); // capped: past 18 dB the gain is not the problem (12 under the v1 meter, whose tails read sparse parts low)+ if (pass === 2) { if (!v.calibrated) for (const r of b.rows) if (r.offDb !== null && Math.abs(r.offDb) > 1) fix[v.id][r.id] = +r.offDb.toFixed(1);console.log(v.id.padEnd(14), b.rows.filter((r) => r.offDb !== null).map((r) => `${r.id} ${r.offDb >= 0 ? "+" : ""}${r.offDb.toFixed(1)}`).join(" ")); }}}const file = join(here, "../src/canvas-core/music/vocabTrim.ts"), head = readFileSync(file, "utf8").split("export const VOCAB_TRIM")[0], j = (x) => JSON.stringify(x, null, 1).replace(/"(\w+)":/g, "$1:");- writeFileSync(file, `${head}export const VOCAB_TRIM: Record<string, Partial<Record<Slot, number>>> = ${j(trim)};\n/** Where a 12 dB trim could not reach the target (long-decaying plucks read low as active RMS), the target moves to where the voice sits. */\nexport const VOCAB_TARGET_FIX: Record<string, Partial<Record<Slot, number>>> = ${j(fix)};\n`);+ writeFileSync(file, `${head}export const VOCAB_TRIM: Record<string, Partial<Record<Slot, number>>> = ${j(trim)};\n/** Where an 18 dB trim could not reach the target (long-decaying plucks read low as active RMS), the target moves to where the voice sits. */\nexport const VOCAB_TARGET_FIX: Record<string, Partial<Record<Slot, number>>> = ${j(fix)};\n`);console.log(`wrote ${file}`);};