Deterministic firecracker simulation
Models an electronic firecracker string as a state machine: from the number of bursts, seed, particles per burst, interval and bursts per batch it produces each burst time, position, spark trajectories and suggested sound parameters (pitch / length / volume). The same seed gives identical bursts; the page renders and plays them.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Burst timeline
Each burst’s time, position, sparks and suggested sound (pitch / length / volume) come from a seed-driven xorshift32; the page only renders the frames and plays the audio.
Type some text to get this firecracker’s burst timeline
What this tool does
- Produce a “crack-crack” burst timeline for a page or small game: each burst’s time, on-screen percentage position and the initial speed / lifetime / hue / size of its 24 sparks
- Get suggested audio parameters per burst (pitch 900–3100 Hz, length 60–180 ms, gain 0.4–1.0) so Web Audio can synthesise the sound
- Use the text as a seed to reproduce the very same string of firecrackers — identical text, identical result, so tests and screenshots never flake
Example
Input
新年快乐
Output
Seed text: 新年快乐 Firecracker: 12 bursts, 24 particles each Total duration: 3180ms (interval 180ms) Seed: 3332390218 1. 0ms @ (75.01%, 43.42%) → 2446Hz/63ms 2. 180ms @ (96.38%, 60.44%) → 2514Hz/148ms 3. 360ms @ (80.5%, 40.05%) → 1310Hz/93ms 4. 540ms @ (88.84%, 49.49%) → 1361Hz/67ms 5. 720ms @ (6.88%, 51.31%) → 2271Hz/117ms 6. 900ms @ (5.24%, 49.71%) → 2603Hz/172ms … 6 more bursts omitted
The input text is folded into a 32-bit seed with FNV-1a (“新年快乐” = 3332390218) and every random draw afterwards comes from xorshift32. Only the first 6 of the 12 bursts are printed above; the full list is in the result object.
Frequently asked questions
How are the bursts computed?
The input text is folded into a seed with a 32-bit FNV-1a variant (blank falls back to the fixed seed 2166136261); every later draw — burst time, position, sparks, sound — comes from xorshift32. The same seed gives an identical sequence, so results are reproducible and neither the system clock nor Math.random is ever read.
What are the ranges for sparks and sound?
Sparks fly at speed 0.6–3.0 (angle 0–2π) with lifetime 320–800 ms, hue 10–60 and size 1–4 px; suggested audio is pitch 900–3100 Hz, length 60–180 ms, gain 0.4–1.0. The ranges are fixed, so rendering and synthesis never see out-of-range values.
Can I change the number of bursts, sparks or the rhythm?
Yes. The pure function accepts 1–500 bursts, 1–400 sparks each, an interval of 10–5000 ms and 1–20 bursts detonated per batch; the page checkbox switches on the “three at a time” string mode. Total duration = the last burst’s time + 1200 ms of trailing sparks.
Does anything actually explode?
No. This only emits numbers (a timeline and parameters): nothing is lit, nothing is played and no file is written. The calling page decides how to render and play it, and no real fireworks are involved.
Keywords:Deterministic firecracker simulationfirecrackerofflinedeterministic