musicscore.quantize

class musicscore.quantize.QuantizeMixin(get_quantized=None, *args, **kwargs)[source]
get_possible_subdivisions(beat_quarter_duration: QuarterDuration | None = None) List[int][source]

QuantizeMixin method

This method is used by Beat’s quantize_quarter_durations().

Possible subdivisions dictionary can be set with set_possible_subdivisions(). Keys in the subdivisions dictionary correspond to beat quarter durations (e.g. 1, 1/2 etc.) For example if get_possible_subdivisions()[1] == [3, 5, 8] a beat with a quarter duration of 1 can after quantization consists only of eighth triplets, quintuplets and 32ths. If this dictionary is not set or beat_quarter_duration as key does not exist, the parent’s possible subdivisions dictionary will be checked.

Score has a default POSSIBLE_SUBDIVISIONS dictionary which will be used if no other musicscore node on the path from self to root has its own possible subdivisions dictionary with beat_quarter_duration as a key. For setting possible subdivisions dictionary use always set_possible_subdivisions().

Parameters:

beat_quarter_duration – Used as key in possible subdivisions dictionary. If None and self is a Beat self.quarter_duration is used. If None and self is not a Beat it is set to 1.

Returns:

A list of possible subdivisions of a Beat. This is used by beat’s quantize_quarter_durations()

Return type:

List[int]

set_possible_subdivisions(subdivisions: list[int], beat_quarter_duration: QuarterDuration | None = None) None[source]

QuantizeMixin method

This method is used to set or change possible subdivisions dictionary of a beat or its ascendants. For example if get_possible_subdivisions()[1] == [3, 5, 8] a beat with a quarter duration of 1 can after quantization consists only of eighth triplets, quintuplets and 32ths.

Parameters:
Returns:

None

property get_quantized: bool

QuantizeMixin property

Type:

Optional[bool]

Return type:

bool