/ proof-of-concept / bead-percussion
Sign in
proof-of-concept / bead-percussion
bead-percussion / README.md
5.9 KBPreviewCodeBlameHistoryRaw

bead-percussion#

A browser app for idealized percussion: a network of beads (point masses) joined by springs, set up by a MATLAB-syntax script that runs in the browser with numbl, integrated accurately in time, and heard through the displacement of a listener bead.

The aim is to reproduce the phenomena of drums and cymbals (resonant modes, nonlinear coupling between them, transfer of energy to higher frequencies, amplitude-dependent detuning) in a system that is physical but much simpler than the continuum equations of a membrane or a shell. Nothing here discretizes a PDE. The bead network is the system.

Running#

npm install
npm run dev      # the app, at the printed localhost URL
npm test         # solver tests (Node)

The model#

Each bead has a mass and a position in 3D. The script defines:

Bending stiffness (for plates and cymbals) is not in yet.

The matlab/helpers/bp_*.m functions build common geometries (bp_hexdisk: a triangular lattice clipped to a disk, with its rim beads; bp_chain: a line of beads), list edges (bp_edges), make springs with a given tension at rest (bp_springs) and find beads near a point (bp_near). They are ordinary scripts; the app lists them, and a script can ignore them and build sys directly. The full list of sys fields is in the app under "sys fields".

Time integration#

The conservative part (springs and force pulses) is integrated with velocity Verlet, or with Yoshida's fourth-order composition of it (sys.method = 'yoshida4'). Damping is linear in the velocities, dv/dt = -A v, and is applied as a separate step v <- exp(-tau A) v, computed to round-off with a scaled Taylor series, once per audio sample (Strang splitting). The splitting error scales with the damping rate times the sample interval, which is small for the damping of interest here.

The time step is chosen automatically. We estimate the highest frequency of the system linearized about rest by power iteration, take sys.safety (default 0.5) of the method's stability limit, and round so that a whole number of steps fits in each audio sample (48 kHz by default). The in-plane (stretching) modes of a net are much stiffer than its transverse modes, so they, not the audible frequencies, usually set the step; a smaller pre-stretch makes this worse.

Each run reports:

Linear modes#

For a net that rests flat (all beads at one z), small transverse motion decouples from in-plane motion, and its stiffness matrix is a graph Laplacian weighted by spring tension over length. The app computes its eigenpairs with numbl's eig (up to 1500 free beads; about 1 s for the 721 free beads of the drum example) and records the energy of every mode over time. The "energy by linear mode" plot shows the share of the quadratic energy in log-spaced frequency bands: in a linear system each band only decays, so any band that gains energy is fed by the nonlinearity.

The "small-strike reference" option runs the same system with every hit scaled down by 1000 and the output scaled back up, which is what the system would do if it were linear. The app plays it for comparison and reports the difference from the actual run.

Examples#

Example What it shows
drum A 15 cm drum head (823 beads, fundamental 237 Hz) struck by a soft mallet. Nearly linear at first (2% from the small-strike reference over 10 ms); the slight pitch change at large amplitude accumulates to 25% by 0.3 s. About 7x real time.
cascade The same net with a 0.5% pre-stretch, weaker dashpots and a hard strike. The share of energy in modes above 1 kHz grows from 4% (small strike) to about 25% within 30 ms. About 10x real time.
string 120 beads on a string, struck slightly off-axis; fast.

Timings are for a laptop (Chrome, single thread).

Limitations and next steps#

↑↓ move↵openescclose