musicscore.time
- class musicscore.time.Time(*signatures, show=True, **kwargs)[source]
Bases:
XMLWrapper- get_beats_quarter_durations() List[QuarterDuration][source]
- Returns:
List of quarter durations according to
actual_signatures
- to_string(*args, **kwargs) str
XMLWrappermethodCalls
to_stringmethod of self.xml_object- Returns:
musicxml snippet
- property actual_signatures: List[int]
Set and gets actual signatures. If
parent_measureexists its beats inside voices will be updated.- Returns:
A list of int representing actual time signatures. If not set manually, it is calculated internally. For example a 4/4 time signature gets automatically [1, 4, 1, 4, 1, 4, 1, 4] as actual_signatures if not set otherwise.
See also
- property show: bool
If time signature is shown or not.
- Type:
bool
- Returns:
bool
- property signatures: List[int]
Set and gets signatures. If
parent_measureexists, beats inside its voices will be updated. If it is set toNonea 4/4 signature will be used.- Returns:
A list of int representing time signature.
- property xml_object: XMLElement
XMLWrappermethodThis musicscore class has an equivalent
MusicXMLclass which can be reached via this property.If an attribute is not found directly in the main class, it wll be passed on to
__get_attribute__or__set__attribute__methods ofself.xml_object. It can also use the short cut attributes ofXMLElementto get or set the first child.- Returns:
wrapped MusicXML element of type
XMLClass
- musicscore.time.flatten_times(times) List[Time][source]
- Parameters:
times – an expandable list of times or tuples representing times. For example [x * Time(3, 8)] return x time intances of Time(3, 8)
- Returns:
List[Time]
>>> ts = [2 * Time(3, 8), (3, 4), 3 * [(1, 8)], Time(1, 8, 3, 4), Time(3, 4)] >>> [t.signatures for t in flatten_times(ts)] [(3, 8), (3, 8), (3, 4), (1, 8), (1, 8), (1, 8), (1, 8, 3, 4), (3, 4)]
- musicscore.time.CONVERSION_DICTIONARY = {'2/8': [2, 8], '4/8': [2, 8, 2, 8], '5/8': [3, 8, 2, 8], '7/8': [4, 8, 3, 8]}
If
Time.actual_signaturesis not set manually first this dictionary is used to create actual signature.