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.

Carry recorded room direct frames through loader reloads

Alex Greenshpun0a74d41926ea
diff --git a/skills/anidoodle/engine/tools/sounds-unit.mjs b/skills/anidoodle/engine/tools/sounds-unit.mjs
index 54e6b0c..d66a521 100644
--- a/skills/anidoodle/engine/tools/sounds-unit.mjs
+++ b/skills/anidoodle/engine/tools/sounds-unit.mjs
@@ -63,6 +63,12 @@ check('forced FLAC demuxers decode the exact hashed bytes even after the path ch
try { process.env.PATH = wrappers + ':' + oldPath; M.clearBanks(); loadBanks(M, root, ['piano']); assert.equal(M.bankFor('piano').zones[0].channels[0].length, frames); }
finally { process.env.PATH = oldPath; writeFileSync(file, bytes); }
});
+check('room directFrames is loaded and participates in reload identity', () => {
+ manifest.rooms = { test: { ...originalRoom, directFrames: 120 } }; writeFileSync(join(root, 'manifest.json'), JSON.stringify(manifest));
+ M.clearRooms(); loadBanks(M, root, []); assert.equal(M.roomFor('test').directFrames, 120);
+ manifest.rooms.test.directFrames = 121; writeFileSync(join(root, 'manifest.json'), JSON.stringify(manifest));
+ loadBanks(M, root, []); assert.equal(M.roomFor('test').directFrames, 121);
+});
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] } } }));
diff --git a/skills/anidoodle/engine/tools/sounds.mjs b/skills/anidoodle/engine/tools/sounds.mjs
index 947a615..ec12244 100644
--- a/skills/anidoodle/engine/tools/sounds.mjs
+++ b/skills/anidoodle/engine/tools/sounds.mjs
@@ -38,9 +38,9 @@ export const loadBanks = (M, dir, ids) => {
}
if (manifest.rooms !== undefined && (!manifest.rooms || typeof manifest.rooms !== "object" || Array.isArray(manifest.rooms))) throw new Error("invalid sound pack rooms");
for (const [id, entry] of Object.entries(manifest.rooms ?? {})) {
- if (M.roomFor(id)?.sha256 === entry.sha256?.toLowerCase() && M.roomFor(id)?.rt60 === entry.rt60 && M.roomFor(id)?.L.length === entry.frames) continue;
+ if (M.roomFor(id)?.sha256 === entry.sha256?.toLowerCase() && M.roomFor(id)?.rt60 === entry.rt60 && M.roomFor(id)?.L.length === entry.frames && (M.roomFor(id)?.directFrames ?? 0) === (entry.directFrames ?? 0)) continue;
const channels = decodeFlac(root, `room ${id}`, entry);
- M.registerRoom(id, { L: channels[0], R: channels[entry.channels - 1], rt60: entry.rt60, sha256: entry.sha256 });
+ M.registerRoom(id, { L: channels[0], R: channels[entry.channels - 1], rt60: entry.rt60, sha256: entry.sha256, directFrames: entry.directFrames });
}
};
export const printSounds = (M, piece) => {