Skip to content

Add beat-based TransportControl APIs for position and loop range#14

Merged
lucaromagnoli merged 1 commit into
magda_minimalfrom
feat/transport-beat-apis
May 11, 2026
Merged

Add beat-based TransportControl APIs for position and loop range#14
lucaromagnoli merged 1 commit into
magda_minimalfrom
feat/transport-beat-apis

Conversation

@lucaromagnoli

Copy link
Copy Markdown
Contributor

Summary

Stage 1 of #12. Adds beat-based overloads on TransportControl so callers can pass musical-time intent directly and let TE own the conversion against Edit::tempoSequence.

  • void setPosition(BeatPosition)
  • BeatPosition getPositionBeats() const
  • void setLoopRange(BeatRange)
  • BeatRange getLoopRangeBeats() const

Internal storage stays in TimePosition for now — these are thin wrappers that convert through the Edit's TempoSequence and delegate to the existing time-based setters. The point is to centralise the conversion inside TE instead of having each caller cache beats and recompute seconds on every BPM change.

Why

The motivating bug: changing BPM while looping is active causes the playhead to drift out of loop bounds, because MAGDA caches beat values, recomputes seconds against the new tempo, then pushes seconds back to TE — and the playhead is already in flight against the old conversion. With these APIs the caller hands beats to TE, and TE converts at the moment of use against whatever tempo is current.

This fixes the immediate bug after the MAGDA-side port (separate PR) and removes a whole class of time → beat → time drift issues across transport.

Test plan

Adds setPosition(BeatPosition) / getPositionBeats() and
setLoopRange(BeatRange) / getLoopRangeBeats() on TransportControl,
centralising the conversion against Edit::tempoSequence so callers no
longer need to re-derive seconds from beats around tempo changes.

Stage 1 of #12 — internal storage stays in TimePosition for now; these
are wrapper overloads that delegate to the existing time-based setters
after converting through the Edit's TempoSequence.
@lucaromagnoli lucaromagnoli merged commit 469606c into magda_minimal May 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant