brown.managed.abstract_graphic_beat

classes

permalink view source

AbstractGraphicBeat (Beat, Unit)

A GraphicBeat without defined Unit conversion attributes.

This is meant to be subclassed by class factory methods in context managers. Factory methods only need to define CONVERSION_RATE and _constant_offset to implement a concrete graphic beat.

This should never be instantiated directly.

NOTE: This was hackily extracted from an older version of Beat, and it doesn't work.

Return this value as a float in base unit values.

Returns: float

__init__ (*args) permalink view source

overriden from Beat

  • args: numerator (int or Beat): denominator (int):
OR: float_value (float): A floating point number to be approximated into a quantized beat. OR: beat (Beat): An existing Beat

inherited class attributes

CONVERSION_RATE: float the ratio of this class to Units. permalink view source

Subclasses should override this.

inherited from Unit

inherited properties

requires_tie: bool If this Beat requires a tie to be written. permalink view source

read-only.

inherited from Beat

numerator: int or Beat The numerator component of the beat fraction. permalink view source

If this is a Beat, self will represent a tuplet.

read-only.

inherited from Beat

denominator: int The denominator component of the beat fraction. permalink view source

read-only.

inherited from Beat

dot_count: int The number of dots this beat has. permalink view source

read-only.

inherited from Beat

base_division: int The basic division of the beat. permalink view source

read-only.

inherited from Beat

collapsed_fraction: Fraction The collapsed int / int Fraction of this beat. permalink view source

read-only.

inherited from Beat

class methods

make_concrete_beat (cls, whole_note_size, constant_offset=None, name=None) permalink view source

Make a concrete GraphicBeat class and return it.

arguments:

whole_note_size (Unit): The length of a Beat(1, 1)

constant_offset (Unit): A constant offset for all conversions.

name (str): The name for the concrete Beat class. If not specified, 'ConcreteBeat' is used.

returns:

type

inherited from AbstractGraphicBeat

inherited class methods

from_existing (existing) permalink view source

Clone any Unit object.

arguments:

existing (Unit): An existing unit

returns:

inherited from Unit

from_float (value, round_to=None, limit_denominator=1024) permalink view source

Initialize from a float with an optional denominator to round toward.

arguments:

value (float):

round_to (int): A denominator to round toward.

limit_denominator (int): The maximum denominator value. If round_to is specified, this does nothing.

returns:

inherited from Beat

inherited methods

__hash__ () permalink view source

Beats equal to each other share the same hash.

inherited from Beat

__float__ () permalink view source

Reduce the fractional representation to a float and return it.

inherited from Beat

__eq__ (other) permalink view source

Beats are equal if their numerators and denominators are.

inherited from Beat

__add__ (other) permalink view source

Durations are added by adding their reduced fractions.

Adding nested durations results in collapsing them into non-nested Durations

inherited from Beat

__sub__ (other) permalink view source

Durations are subtracted by subtracting their reduced fractions.

Subtracting nested durations results in collapsing them into non-nested Durations

inherited from Beat

__gt__ (other) permalink view source

Beats are ordered by their reduced fraction representations.

inherited from Beat

__ge__ (other) permalink view source

Beats are ordered by their reduced fraction representations.

Because Beat.__gt__ operates on the reduced fraction representation of the Beats being compared, but Beat.__eq__ compares based on exact non-reduced matches, Beats may pass Beat.__ge__, but not Beat.__eq__ if their numerators are nested differently. As such:

>>> Beat(1, 4) >= Beat(Beat(1, 1), 4)
True
>>> Beat(1, 4) == Beat(Beat(1, 1), 4)
False

inherited from Beat

__lt__ (other) permalink view source

Beats are ordered by their reduced fraction representations.

inherited from Beat

__le__ (other) permalink view source

Beats are ordered by their reduced fraction representations.

Because Beat.__lt__ operates on the reduced fraction representation of the Beats being compared, but Beat.__eq__ compares based on exact non-reduced matches, Beats may pass Beat.__le__, but not Beat.__eq__ if their numerators are nested differently. As such:

>>> Beat(1, 4) <= Beat(Beat(1, 1), 4)
True
>>> Beat(1, 4) == Beat(Beat(1, 1), 4)
False

inherited from Beat

to_fraction () permalink view source

Collapse this Beat into a single Fraction and return it.

returns:

Fraction

This recursively collapses any nested Beats and simplifies the returned Fraction.

inherited from Beat