clockblocks.tempo_envelope.MetricPhaseTarget

class clockblocks.tempo_envelope.MetricPhaseTarget(phase_or_phases: Union[float, Sequence[float]], divisor: float = 1, relative: bool = False)[source]

Bases: object

Class representing a particular point in a (beat or measure) cycle.

Parameters:
  • phase_or_phases – Where we are in the cycle.

  • divisor – Length of the cycle (defaults to one beat, meaning that this specifies where we are in the beat)

  • relative – Whether or not the start of the cycle is measured relative to the current beat/time or to the start of the clock.

Methods

get_nearest_matching_beats(beat)

Get the nearest beats below and above the given beat with the correct metric phase

get_nearest_matching_times(time)

Get the nearest times below and above the given time with the correct metric phase

interpret(value)

Interpret a tuple or just a number as a MetricPhaseTarget.

classmethod interpret(value: Union[float, Sequence]) MetricPhaseTarget[source]

Interpret a tuple or just a number as a MetricPhaseTarget. E.g. we want the user to be able to hand in a tuple like (0.5, 3) and have it get interpreted as a target of 0.5 with divisor 3.

Parameters:

value – either a tuple (which becomes the constructor arguments), a MetricPhaseTarget (which is passed through unchanged), or a number which is treated as the phase with other args as defaults.

Returns:

A MetricPhaseTarget, interpreted from the argument

get_nearest_matching_beats(beat: float) tuple[float, float][source]

Get the nearest beats below and above the given beat with the correct metric phase

Parameters:

beat – the beat to search around

Returns:

tuple of nearest beat below, nearest beat above

get_nearest_matching_times(time: float) tuple[float, float][source]

Get the nearest times below and above the given time with the correct metric phase

Parameters:

time – the time to search around

Returns:

tuple of nearest time below, nearest time above