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
Discover default recordings in music and film audio
Alex Greenshpun7a9434d91b05
diff --git a/skills/anidoodle/engine/tools/audio.mjs b/skills/anidoodle/engine/tools/audio.mjsindex 1d78da2..018f072 100644--- a/skills/anidoodle/engine/tools/audio.mjs+++ b/skills/anidoodle/engine/tools/audio.mjs@@ -6,6 +6,7 @@ import { pathToFileURL } from 'node:url';import { overlay } from './overlay.mjs';import { splitShape, requireFilm } from './names.mjs';import { loadBanks, soundIds, printSounds, codeBuiltNotice } from './sounds.mjs';+import { soundsDir } from './soundfetch.mjs';let filmModuleId = 0;/** Film and music registry share one bundle, so its audio closure sees the loaded banks. */@@ -16,7 +17,7 @@ export const loadFilmModule = async (title, plugins = [overlay]) => {if (shape && !mod.film.reshape) throw new Error(`${base} has one shape; ${shape} needs film.reshape`);return { film: shape ? mod.film.reshape(shape) : mod.film, music: mod.music };};-export const prepareFilmSounds = (film, M, pack = process.env.ANIDOODLE_SOUNDS) => {+export const prepareFilmSounds = (film, M, pack = process.env.ANIDOODLE_SOUNDS || soundsDir()) => {M.clearBanks(); M.clearRooms();if (!film.audio) return false;const scores = film.audio.scores ?? [];diff --git a/skills/anidoodle/engine/tools/music.mjs b/skills/anidoodle/engine/tools/music.mjsindex bf616d2..fa866c2 100644--- a/skills/anidoodle/engine/tools/music.mjs+++ b/skills/anidoodle/engine/tools/music.mjs@@ -33,6 +33,7 @@ import { fileURLToPath } from "node:url";import { Worker } from "node:worker_threads";import { availableParallelism } from "node:os";import { loadBanks, soundIds, printSounds, codeBuiltNotice } from "./sounds.mjs";+import { soundsDir } from './soundfetch.mjs';const here = dirname(fileURLToPath(import.meta.url));const SR = 48000;@@ -190,7 +191,7 @@ const main = async () => {const [cmd, ...args] = process.argv.slice(2);const soundsAt = args.indexOf("--sounds");if (soundsAt >= 0 && (!args[soundsAt + 1] || args[soundsAt + 1].startsWith("--"))) throw new Error("--sounds needs a pack directory");- SOUNDS_DIR = soundsAt >= 0 ? args.splice(soundsAt, 2)[1] : process.env.ANIDOODLE_SOUNDS;+ SOUNDS_DIR = soundsAt >= 0 ? args.splice(soundsAt, 2)[1] : process.env.ANIDOODLE_SOUNDS || soundsDir();if (SOUNDS_DIR) SOUNDS_DIR = resolve(SOUNDS_DIR);const roomAt = args.indexOf("--room");if (roomAt >= 0 && (!args[roomAt + 1] || args[roomAt + 1].startsWith("--"))) throw new Error("--room needs a room id");diff --git a/skills/anidoodle/engine/tools/sounds-unit.mjs b/skills/anidoodle/engine/tools/sounds-unit.mjsindex 451d879..ca6b188 100644--- a/skills/anidoodle/engine/tools/sounds-unit.mjs+++ b/skills/anidoodle/engine/tools/sounds-unit.mjs@@ -3,7 +3,7 @@// node tools/sounds-unit.mjs <durable-test-dir>import { build } from "esbuild";import { strict as assert } from "node:assert";-import { execFileSync } from "node:child_process";+import { execFileSync, spawnSync } from "node:child_process";import { createHash } from "node:crypto";import { mkdirSync, readFileSync, writeFileSync } from "node:fs";import { resolve, join } from "node:path";@@ -40,3 +40,25 @@ manifest.rooms = {};M.clearBanks(); zone.sha256 = "0".repeat(64); writeFileSync(join(root, "manifest.json"), JSON.stringify(manifest));assert.throws(() => loadBanks(M, root, ["piano"]), /sha256 mismatch/); assert.equal(M.bankFor("piano"), undefined);console.log("PASS corrupt large FLAC hash: rejected before registration");+let failures = 0;+const check = (label, fn) => { try { fn(); console.log(`PASS ${label}`); } catch (e) { failures++; console.error(`FAIL ${label}: ${e.message}`); } };+zone.sha256 = originalRoom.sha256; manifest.rooms = {}; writeFileSync(join(root, 'manifest.json'), JSON.stringify(manifest));+const isolatedHome = join(root, 'default-home'), install = join(isolatedHome, '.anidoodle', 'sounds'); mkdirSync(install, { recursive: true });+writeFileSync(join(install, 'large.flac'), bytes);+writeFileSync(join(install, 'manifest.json'), JSON.stringify({ ...manifest, rooms: {}, instruments: { piano: { ...entry, range: [21, 108] } } }));+const preload = join(root, 'home.cjs');+writeFileSync(preload, "require('node:os').homedir=()=>process.env.ANIDOODLE_TEST_HOME; require('node:module').syncBuiltinESMExports();");+const env = { ...process.env, ANIDOODLE_TEST_HOME: isolatedHome }; delete env.ANIDOODLE_SOUNDS;+check('music CLI discovers a default install with env and --sounds unset', () => {+ const result = spawnSync(process.execPath, ['--require', preload, 'tools/music.mjs', 'check', 'nocturne', '--seconds', '1'], { env: { ...env, ANIDOODLE_THREADS: '1' }, encoding: 'utf8', maxBuffer: 1<<24 });+ assert.notEqual(result.status, null, result.stderr); assert.match(result.stdout, /calibration piano:/);+});+check('film audio discovers and plays a default install with env unset', () => {+ const script = join(root, 'default-film.mjs');+ const audioUrl = new URL('./audio.mjs', import.meta.url).href;+ writeFileSync(script, `import assert from 'node:assert/strict'; import {prepareFilmSounds,filmFloat32} from ${JSON.stringify(audioUrl)}; const M=await import(${JSON.stringify('data:text/javascript;base64,'+Buffer.from(js).toString('base64'))}); const film={audio:M.filmAudio(M.nocturne(),1)}; assert.equal(prepareFilmSounds(film,M),true); assert.equal(filmFloat32(film).frames,48000); console.log('DEFAULT FILM RECORDINGS PASS');`);+ const out = execFileSync(process.execPath, ['--require', preload, script], { env, encoding: 'utf8', maxBuffer: 1<<24 });+ assert.match(out, /DEFAULT FILM RECORDINGS PASS/);+});+if (failures) process.exitCode = 1;+else console.log('SOUNDS LOADER REVIEW PASS');diff --git a/skills/anidoodle/engine/tools/sounds.mjs b/skills/anidoodle/engine/tools/sounds.mjsindex 8b50676..964ecb0 100644--- a/skills/anidoodle/engine/tools/sounds.mjs+++ b/skills/anidoodle/engine/tools/sounds.mjs@@ -50,4 +50,4 @@ export const printSounds = (M, piece) => {}console.log(`voices recordings: ${recorded.join(", ") || "none"}; modeled: ${modeled.join(", ") || "none"}`);};-export const codeBuiltNotice = () => console.log('audio: using code-built instruments; download the optional anidoodle sound pack and set ANIDOODLE_SOUNDS=<pack-dir> to use recordings');+export const codeBuiltNotice = () => console.log('audio: using code-built instruments; run node tools/soundfetch.mjs get all to install recordings, or set ANIDOODLE_SOUNDS=<pack-dir>');