Margrete RPC

TimeCalculator

Converts between ticks and (bar, beat, offset) positions for a chart.

Built from the chart's :class:BeatEvent list, which partitions the timeline into time-signature segments. Bars before the first event default to 4/4. Most callers use the module-level :func:tick_to_pos / :func:pos_to_tick instead of constructing this directly.

Functions

func__init__(self, beat_events) -> None

Build a calculator from a chart's beat (time-signature) events.

paramself
parambeat_eventsIterable[BeatEvent]

Returns

None
functick_to_pos(self, tick) -> Position

Convert an absolute tick to a (bar, beat, offset) position.

paramself
paramtickint

Non-negative absolute tick from the chart start.

Returns

margrete_rpc.chart.time.Position

The (bar, beat, offset) position of tick.

func_find_segment_index(self, tick) -> int
paramself
paramtickint

Returns

int
funcpos_to_tick(self, bar, beat=0, offset=0) -> int

Convert a (bar, beat, offset) position to an absolute tick.

paramself
parambarint

Zero-based bar index.

parambeatint
= 0

Zero-based beat within the bar.

paramoffsetint
= 0

Tick offset within the beat.

Returns

int

The absolute tick from the chart start.

func_find_segment_index_for_bar(self, bar) -> int
paramself
parambarint

Returns

int

On this page