| js | |
| .gitignore | |
| index.html | |
| main.js | |
| package.json | |
| README.md | |
| style.css |
Woodblock#
Interactive woodblock played by real-time modal synthesis. The modes come from a 3D FDTD analysis of the block (WebGPU).
npm run dev # http://127.0.0.1:8020
Needs a browser with WebGPU (Chrome, Safari 26+). three.js loads from jsDelivr (pinned 0.169.0).
Model#
- Mode analysis (
js/fdtd.js): undamped staggered-grid velocity–stress solver, orthotropic wood (grain along length) and air on one grid (air = μ 0, λ = ρc²), sponge boundary. Three short runs record vertical velocity at every top-face node: one with a volume-velocity pulse at the mic, 12 mm in front of the slot (by reciprocity, mic pressure per unit force at every strike point), and two with a force pulse at reference points on the top (surface mobility, for the mallet contact). - Modes (
js/modal.js): peaks from the combined spectra, radiation decay from two half windows, complex residues by a least-squares fit with those poles. - Strike: Hertz mallet (F = K δ^1.5) simulated against the modal surface at the strike point; the contact force drives the modes. Damping: Rayleigh law fitted to the loss factor at 400 Hz and 4 kHz (
js/physics.js), plus each mode's radiation decay.
Controls#
- Live: pitch (scales every mode frequency), loss factor, mallet hardness, mass, velocity, strike point (click the top face).
- Block geometry, density and E_L need Analyze modes again (about 40–60 s at 3 mm on an Apple GPU; 4 mm is faster).
SoundFont export#
Export .sf2 renders a chromatic instrument from the modal model (js/export.js, js/sf2.js):
- Keys: each sampled key is the block retuned so its loudest ringing mode lands exactly on that note. Samples every 1–6 semitones; the player pitch-shifts in between.
- Velocity: 4 layers; harder layers use a faster strike and a harder mallet (K down to ~0.25× at the softest layer). The velocity slider sets the loudest layer. The default SoundFont velocity-to-volume curve is turned off so loudness comes from the samples themselves (some players may ignore that).
- Variation: SF2 has no round-robin, so each layer is split into 3 narrow velocity bands sampled from strike points a few mm apart.
- Preset is GM program 116 (Wood Block), bank 0.