/ music / double-pendulum
Sign in
music / double-pendulum
double-pendulum / README.md
60 lines · 3.8 KBPreviewCodeBlameHistoryRaw
1# double pendulum
3An album of electroacoustic compositions. Each composition's sound and image are computed live in the browser from a double pendulum simulation.
5```bash
6npm install
7npm run dev # http://127.0.0.1:8031
8npm run build # static site in dist/ (relative paths, so it works under any subpath)
9```
11## Routes
13- `#/`: the track list
14- `#/<id>`: a composition with its published defaults (what visitors hear)
15- `#/<id>/edit`: author mode. Adds a panel of every parameter, readouts, "start at", and click-to-seek on the progress line.
17## Author workflow
191. Open a composition, click **edit**, and tweak while it plays. Most changes are heard immediately. Instrument choice and the seed apply on the next play.
202. Your edits persist in this browser (localStorage), and only in author mode.
213. **copy config** copies the full parameter set as JSON. Paste it over
22 `src/compositions/<dir>/defaults.json` and rebuild to publish it.
234. **seed** = 0 gives a new variation each play. The readouts show the seed that was used, so you can pin a variation you liked.
25## Layout
27- `src/physics/doublePendulum.ts`: Hamiltonian double pendulum, RK4. Energy is steered to a target by a force `λ·p` (`dE/dt = 2λT`), so it rises and falls smoothly.
28- `src/instruments/`: instrument interfaces (`NoteInstrument`, `DroneInstrument`), placeholders, and the registry. Add real instruments here and they appear in the composition's instrument menus.
29- `src/instruments/modal.ts`: instruments from the sibling **modal-synth** project (`../modal-synth`), imported live through the `@modal-synth` alias (see `vite.config.ts` and `tsconfig.json`). Every built-in modal-synth preset appears as `modal: <name>`. For your own sounds, press **Copy** in modal-synth, choose `modal: custom`, and paste the JSON into **modal custom**. The JSON then becomes part of the composition's config. Building requires `../modal-synth` to be present.
30- `src/music/scales.ts`: scales and quantization (including continuous and harmonic series).
31- `src/core/`: params schema, author panel, audio context, and the composition interface.
32- `src/compositions/`: one folder per track (`schema.ts`, `defaults.json`, `piece.ts`), listed in `index.ts`.
33- `src/compositions/c01-poincare/orbitWorker.ts`: background orbit portrait, run in short work slices that use about `orbitCpu` of one core.
35## 1. poincaré
37The section is θ1 = 0, crossed with dθ1/dt > 0, and plotted at (θ2, p2). Each crossing plays a note:
39- θ2 sets the pitch (signed or absolute, range, curve, scale, root)
40- |p2| sets the loudness
41- θ2 sets the pan
43Notes stop at `duration − finalAt`. The last note is then held for `finalHold` and faded over `finalFade`, all within `tail`.
45Behind the live crossings, a pool of energy-conserving orbits at the current energy keeps drawing the section's structure (islands and chaotic sea). They're reseeded as the energy moves.
47The hum is one held note of a sustained modal-synth preset (bowed, blown, self-oscillating or fed back). The energy sets a timbre value, which drives up to two synth settings (A and B), e.g. bow position and bow force. **normalize loudness** measures the hum's output and compensates slowly, so it holds a fixed pitch and loudness while only its timbre follows the energy. The energy follows an envelope: start → peak (exponential or linear rise) → hold → fall to zero at `duration`.
49Units: energy is in units of the potential energy with both arms up, and p2 is in units of √(m2·l2²·E_top).
51## Deploying
53The site is published from the `site/` directory of `music/double-pendulum` on vault1.magland.org, served at https://double-pendulum--music.vault1-sites.magland.org/. The build needs `../modal-synth`, so it runs locally, not in CI:
55```bash
56npm run site # build, then copy dist/ to site/
57git add -A && git commit -m "Update site" && git push
58```
60Every push to `main` republishes the site.
↑↓ move↵openescclose