SimClock(dt, sample_rate=48000) | dt must be a positive Dur |
.dt / .set_dt(dur) | Fixed timestep; writable — retunes later step / frame (keeps accumulator residual) |
.tick | Completed steps (with constant dt, now == tick * dt under step) |
.grid(n) | TickGrid for % quantize (same as tick(n); does not collide with .tick) |
.accumulator | Leftover Dur toward the next fixed step (frame only) |
.alpha | accumulator / dt (usually [0, 1); may be >= 1 after set_dt) |
.on_step(fn, *, priority=0) / @sim.on_step | Fixed-update hook; after shreds; ascending priority, then registration order |
.on_update | Alias for on_step |
.on_render(fn, *, priority=0) / @sim.on_render | Render hook; once per frame after updates (not on bare step) |
.clear_hooks / .off_step / .off_update / .off_render | Drop registrations |
.paused / .pause() / .resume() | Freeze step / frame / run_ticks as no-ops |
.timescale | Scale frame(elapsed) only (default 1.0, >= 0); step ignores it |
.step(n=1) / .run_ticks(n) | Advance n fixed steps by current dt |
.frame(elapsed, *, max_steps=None) | Bank elapsed * timescale, drain updates, then render once |
.reset() | Back to origin; hooks stay; pending shreds cancelled; pause/timescale/dt unchanged |
.lerp(a, b, t=None) | a + (b - a) * t; omit t to use this clock’s alpha |
lerp(a, b, t=None) | Module helper; omit t to use current SimClock.alpha |