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: one timpani. orchestra.timpani routes v2 pieces to the kit's concert timpani (drums.ts: 7 measured membrane modes, velocity glide, stick click, real rolls) and keeps v1 for legacy only; measured 4.5 s vs 16.9 s for a 30 s part at 48 kHz (44 strokes, 5 rolls). Orchestral, suspense, choral (and world's frame drum) reach it through the one entry point

Alex Greenshpun077d69e3756e
diff --git a/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts b/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts
index 0fd4254..cbca657 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts
@@ -5,6 +5,7 @@
import { type Rng, TAU, clamp, pan, SVF, blep, gauss } from "./dsp";
import type { Played } from "./perform";
import * as E from "./ensemble";
+import { timpani as kitTimpani } from "./drums";
type Out = { L: Float32Array; R: Float32Array };
type Opts = Record<string, number | boolean | string>;
@@ -69,7 +70,7 @@ const choirLegacy = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Ou
};
/** Timpani (`pitch`: a MIDI note to tune it when it plays a drum lane): a tuned membrane (modal partials 1, 1.5, 1.99, 2.44, 2.97 with their own decays), a small downward pitch settle, a felt-mallet thump. Pitched on the note. */
-export const timpani = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => {
+const timpaniLegacy = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => {
const out = out0(n), dec = num(o, "decay", 1.6), P = [[1, 1, 1], [1.5, 0.5, 0.7], [1.99, 0.35, 0.5], [2.44, 0.2, 0.35], [2.97, 0.12, 0.25]];
for (const k of keys) {
const f = f0(typeof o.pitch === "number" ? (o.pitch as number) : k.p), i0 = Math.round(k.t * sr), len = Math.min(n - i0, Math.ceil(dec * 4 * sr)), lp = new SVF(sr, 400, 0.7);
@@ -117,3 +118,6 @@ export const brass = (keys: Played[], sr: number, n: number, o: Opts): Out => (l
export const woodwind = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => (legacy(o) ? woodwindLegacy(keys, sr, n, o, r) : E.woodwind(keys, sr, n, o, r));
export const choir = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => (legacy(o) ? choirLegacy(keys, sr, n, o, r) : E.choir(keys, sr, n, o, r));
export const bowedSolo = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => (legacy(o) ? bowedSoloLegacy(keys, sr, n, o, r) : E.bowedSolo(keys, sr, n, o, r));
+/** Timpani: the kit's concert timpani (drums.ts: 7 measured membrane modes, velocity pitch glide, stick click, real rolls), 3.7x faster than v1
+ * (4.5 s vs 16.9 s for a 30 s part at 48 kHz, measured at the sound-v2 merge). v1 (5 sines, recomputed with Math.sin per sample, no rolls) stays for legacy only. */
+export const timpani = (keys: Played[], sr: number, n: number, o: Opts, r: Rng): Out => (legacy(o) ? timpaniLegacy(keys, sr, n, o, r) : kitTimpani(keys, sr, n, o, r));
diff --git a/skills/anidoodle/engine/src/canvas-core/music/render.ts b/skills/anidoodle/engine/src/canvas-core/music/render.ts
index 59625f2..f3374b2 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/render.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/render.ts
@@ -8,7 +8,7 @@ import { renderPiano, PIANO_REAL, type PianoOpts } from "./piano";
import { keysVoice, renderPianoV2 } from "./keys";
import * as I from "./instruments";
import * as O from "./orchestra";
-import { timpani as kitTimpani, chokeTimes, type KitCtx } from "./drums";
+import { chokeTimes, type KitCtx } from "./drums";
import { room, Biquad, db } from "./dsp";
import { warmPad, softPluck, sub, duckCurve, tape } from "./lofiKit";
import { pumpCurve, lofiStem, lofiMaster, LOFI_DUSTY } from "./lofiFx";
@@ -55,7 +55,7 @@ const voice = (pt: Part, keys: Played[], sr: number, n: number, seed: number, ct
case "brass": return O.brass(keys, sr, n, o);
case "woodwind": return O.woodwind(keys, sr, n, o, r);
case "choir": return O.choir(keys, sr, n, o, r);
- case "timpani": return ctx.legacy || o.legacy === true ? O.timpani(keys, sr, n, o, r) : kitTimpani(keys, sr, n, o, r);
+ case "timpani": return O.timpani(keys, sr, n, o, r); // v2: the kit timpani (drums.ts); legacy opts: v1
case "leadSynth": return O.leadSynth(keys, sr, n, o);
case "bowedSolo": return O.bowedSolo(keys, sr, n, o, r);
default: throw new Error(`no instrument ${pt.inst}`);