Skip to content

Fix: non-loop scheduler bounded by play endTime — no early boundary beat (#500)

Choose a tag to compare

@naomiaro naomiaro released this 28 Jun 01:21
fb6438d

Fixes an audible early beat at the end of bounded (play(start, endTime)) playback. PR #500.

Published packages

Package Version
@dawcore/transport 0.0.14

What changed

play(0, endTime) auto-stop relied on the Timer's time >= endTime check, but the scheduler's non-loop lookahead generated events up to time + lookahead (~200ms) with no endTime clamp. So a metronome downbeat (or clip) sitting at the playback boundary was scheduled ~200ms early and started before stop()'s silence() could cancel it — sounding a beat into the next, nonexistent bar. The loop path was already bounded by loopEnd, which is why continuous/looping playback never showed this.

Added Scheduler.setPlayEnd(endTick), wired from Transport play() / stop() / seek() / count-in, which clamps the non-loop scheduling window so nothing is generated at or beyond the end (generate() uses tick < toTick, so the boundary tick is excluded). The loop path is unchanged. Adds scheduler tests for the bound.