genmusic
v1.3.1
Published
Seed-based procedural music engine for the browser
Maintainers
Readme
GenMusic
Seed-deterministic generative music engine for the web. Feed it a seed and an intensity signal — it composes and plays music in real time.
Architecture
Pattern → Player separation. Patterns are seed-generated note sequences. Players interpret them into sound. The engine just routes.
seed ──→ patterns (shared)
│
engine ──→ arpeggio player ──→ audio
──→ melody player ──→ audio
──→ solo player ──→ audioSame seed = same composition. Always.
Features
- Deterministic: seeded PRNG controls all randomness
- Single control signal: just feed
setIntensity(0-1)continuously - Player system: modular musical interpreters (arpeggio, melody, solo, rhythm, bass)
- Phrase engine: configurable styles with form structures (AABA), contours, verse alternation
- Time signatures: 4/4, 3/4, 6/8
- Production moods: intimate, warm, distant, bright (effect chain presets)
- Zero dependencies: vanilla TypeScript, WebAudio API
- Auto-rebirth: when intensity drops to 0 and rises, generates a new key and patterns
Quick Start
import { GenMusic } from './src/engine.js';
button.onclick = () => {
const engine = new GenMusic({ seed: 42 });
engine.start();
// Feed intensity from your simulation
function loop() {
engine.setIntensity(mySimulation.getActivity());
requestAnimationFrame(loop);
}
loop();
};Build
npx tsc
npx esbuild src/index.ts --bundle --format=iife --global-name=GenMusicLib --outfile=dist/genmusic.bundle.js --minifyPlayground
Open playground/index.html — interactive test UI with seed controls, intensity slider, and real-time visualization.
Docs
- Architecture — module structure, data flow, Player interface
- Composition — what the seed controls, phrase engine, melody design
- Players — each player type and its behavior
- Intensity — the single control signal
- Production — moods, voices, tempo
- Integration — how to connect to your project
- Playground — test UI documentation
Used In
- Petri — Gray-Scott reaction-diffusion dish that composes its own music
