simfile.timing

Timing data classes, plus submodules that operate on timing data.

Submodules

Package Contents

Classes

Beat

A fractional beat value, denoting vertical position in a simfile.

BeatValue

An event that occurs on a particular beat, e.g. a BPM change or stop.

BeatValues

A list of BeatValue instances.

TimingData

Timing data for a simfile, possibly enriched with SSC chart timing.

class simfile.timing.Beat

Bases: fractions.Fraction

A fractional beat value, denoting vertical position in a simfile.

The constructor the same arguments as Python’s Fraction:

Takes a string like ‘3/2’ or ‘1.5’, another Rational instance, a numerator/denominator pair, or a float.

If the input is a float or string, the resulting fraction will be rounded to the nearest tick().

classmethod tick(cls)Beat

1/48 of a beat (1/192 of a measure).

classmethod from_str(cls, beat_str)Beat

Convert a decimal string to a beat, rounding to the nearest tick.

round_to_tick(self)Beat

Round the beat to the nearest tick.

class simfile.timing.BeatValue

Bases: NamedTuple

An event that occurs on a particular beat, e.g. a BPM change or stop.

The decimal value’s semantics vary based on the type of event:

  • BPMS: the new BPM value

  • STOPS, DELAYS: number of seconds to pause

  • WARPS: number of beats to skip

beat :Beat
value :decimal.Decimal
class simfile.timing.BeatValues(initlist=None)

Bases: simfile._private.generic.ListWithRepr[BeatValue]

A list of BeatValue instances.

classmethod from_str(cls: Type[BeatValues], string: Optional[str])BeatValues

Parse the MSD value component of a timing data list.

Specifically, BPMS, STOPS, DELAYS, and WARPS are the timing data lists whose values can be parsed by this method.

class simfile.timing.TimingData(simfile: simfile.types.Simfile, chart: Optional[simfile.types.Chart] = None)

Timing data for a simfile, possibly enriched with SSC chart timing.

If both an SSCSimfile (version 0.7 or higher) and an SSCChart are supplied to the constructor, and if the chart contains any timing fields, the chart will be used as the source of timing data.

Per StepMania’s behavior, the offset defaults to zero if the simfile (and/or SSC chart) doesn’t specify one. (However, unlike StepMania, the BPM does not default to 60 when omitted; the default BPM doesn’t appear to be used deliberately in any existing simfiles, whereas the default offset does get used intentionally from time to time.)

bpms :BeatValues
stops :BeatValues
delays :BeatValues
warps :BeatValues
offset :decimal.Decimal