de6cf45cymroom: load a .cymsim file and show every part of it in a 3D scene; the room acoustics solver is not written yetJeremy Magland 1// Smoke test: load a .cymsim file through the reader and exercise the playback sources.
2// Usage: node tools/read-check.ts file.cymsim
3import { readCymsim, type H5Module } from "../src/io/cymsimFile.ts";
4import { parseConfigYaml } from "../src/config/yaml.ts";
5import { displacementSource, accelerationSource } from "../src/playback.ts";
7const h5: H5Module = (await import("h5wasm/node")).default as unknown as H5Module;
8await h5.ready;
9const run = readCymsim(h5, process.argv[2], (y) => { const r = parseConfigYaml(y); if (!r.config) throw new Error("bad yaml"); return r.config; });
10console.log("nodes", run.mesh.nNodes, "elements", run.mesh.nElements, "boundary", run.mesh.boundary.length);
11console.log("audio", run.audioUnbaffled.length, "at", run.fs, "hits", run.hits.length, "energy rows", run.energy.length);
12console.log("displacement frames", run.displacement?.frames.length, "rate", run.displacement?.rate);
13console.log("acceleration samples", run.acceleration?.nSamples);
15const ds = displacementSource(run.displacement!);
16const f0 = ds.frame(100);
17console.log("disp frame 100: scale", f0.scale, "w[50]", f0.w![50], "finite", Number.isFinite(f0.field![50]));
19const as = accelerationSource(run.acceleration!, run.displacement);
20const f1 = as.frame(5000);
21console.log("acc frame 5000: scale", f1.scale.toExponential(3), "field[50]", f1.field![50].toExponential(3), "w present", f1.w !== null);
23// probe signal for node 50, as main.ts extracts it
24const a = run.acceleration!, N = a.nodes, sig = new Float32Array(a.nSamples);
25for (const b of a.blocks) for (let r = 0; r < b.count; r++) sig[b.first + r] = b.data[r * N + 50] * b.scale[r];
26let peak = 0; for (const v of sig) peak = Math.max(peak, Math.abs(v));
27console.log("probe node 50: peak |a| =", peak.toExponential(3), "m/s^2");