/ music / woodblock2
Sign in
music / woodblock2
woodblock2 / README.md
29 lines · 2.2 KBPreviewCodeBlameHistoryRaw
1# Woodblock
3Interactive woodblock played by real-time modal synthesis. The modes come from a 3D FDTD analysis of the block (WebGPU).
5```bash
6npm run dev # http://127.0.0.1:8020
7```
9Needs a browser with WebGPU (Chrome, Safari 26+). three.js loads from jsDelivr (pinned 0.169.0).
11## Model
13- **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).
14- **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.
15- **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.
17## Controls
19- Live: pitch (scales every mode frequency), loss factor, mallet hardness, mass, velocity, strike point (click the top face).
20- 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).
22## SoundFont export
24**Export .sf2** renders a chromatic instrument from the modal model (`js/export.js`, `js/sf2.js`):
26- 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.
27- 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).
28- Variation: SF2 has no round-robin, so each layer is split into 3 narrow velocity bands sampled from strike points a few mm apart.
29- Preset is GM program 116 (Wood Block), bank 0.
↑↓ move↵openescclose