01 · The integral
Three closed-form regimes plus one numerical regime, derived in the code comments.
The math behind tempo maps and warp markers, taught in code.
Tempo is a rate. "120 BPM" means beats arrive at 120 per minute — 2 per second. If musical position is
We almost always want the other direction — given a beat, what second is it? — so we flip the fraction and integrate. Integrating a rate recovers the total:
That integral is the whole subject. A warp map is this function from beats to seconds; a warp marker is a single
| Shape of tempo | The integral becomes | The warp map looks like |
|---|---|---|
| Constant | a straight line | |
| Piecewise-constant (what beat_this gives) | a running sum of rectangles | piecewise-linear, kinking at each marker |
| Linear ramp (accelerando) | a curve — a logarithm | |
| Curved (ease in/out, | no closed form — integrate numerically | a curve with no simple equation |
The last row is the payoff. For general
The same integral underlies all four; only the difficulty changes. The chapters work through them in order.
A live BPM readout is the derivative of the warp map coming back around:
Each map's bpmAt(β) is that derivative, evaluated analytically where a formula exists. The test suite confirms the round trip numerically across all four regimes.