Within a a Chain / Voice events
can be combined (with ties or glissandi) to produce lines of any complexity.
When an event is added to a container that container becomes its
parent.
The offset attribute of an event determines its
start time relative to the parent container. This offset can be None,
in which case it is resolved based on the context of the event
(is the object part of a Chain / Voice, which events precede it, etc).
The resolved relative offset can be queried via relOffset(),
the absolute offset via absOffset(). These values are always
in quarternote beats. To query the position of an event within a score structure or to
know its absolute position in time (in seconds), see location()
Example
In the following example the 2nd note (4D), which has an unset offset (offset is None),
has a relative offset of 0.5 since it is placed after the first note (4C), which
has a duration of 0.5. Since the chain itself has an offset of 1, the resulting
absolute offset of the 2nd note is 1+0.5=2.5
>>> frommaelzel.coreimport*# We create a chain with two notes. The chain itself has an offset>>> chain=Chain(["4C:0.5","4D:1"],offset=1)>>> chain.dump(forcetext=True)Chain -- beat: 1, offset: 1, dur: 1.5 beat offset dur item 1 0 0.5 4C:0.5♩ 1.5 0.5 1 4D:1♩>>> chain[1].offsetisNoneTrue>>> chain[1].relOffset()0.5>>> chain[1].absOffset()1.5
All time attributes (offset, dur, end) are expressed in quarternote beats.
To map a beat (measured in quarternotes) to its corresponding real-time (measured in
seconds) a score structure (ScoreStruct) is needed. Such a
score structure defines the overall structure of a score (measures, time-signatures, etc)
, providing information about the tempo and tempo changes along the timeline.