resolved.. _mevent:

Musical Events

All individual events inherit from MEvent. Such an event can be a a Note, a Chord, a media Clip or anything derived from those clases.

  • Musical Events
    • Note: a one-pitch event, can represent any microtonal pitch.

    • Chord: a Chord is a collection of one or more Notes with a shared duration

  • Media Events
    • Clip: an Event representing a soundfile

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.

Absolute / Relative Offset

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

>>> from maelzel.core import *
# 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].offset is None
True
>>> chain[1].relOffset()
0.5
>>> chain[1].absOffset()
1.5
_images/relative-offset-vs-absolute-offset.png

Real-Time / Quarternote-Time

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.


Functions

Rest(dur[, offset, label, dynamic])

Create a Rest

asEvent(obj, **kws)

Convert obj to a Note or Chord, depending on the input itself

Grace(pitch[, slash, stemless, offset, ...])

Create a gracenote (a note or chord)

Classes

MEvent(dur[, offset, amp, parent, ...])

Abstract class representing a discrete event in time (a Note, Chord, etc)

Note(pitch[, dur, amp, offset, gliss, ...])

A Note represents a one-pitch event

Chord(notes[, dur, amp, offset, gliss, ...])

A Chord is a stack of Notes

Class Inheritance Diagram

digraph inheritancedf0543f60b { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Chord" [URL="api/maelzel.core.event.Chord.html#maelzel.core.event.Chord",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Chord is a stack of Notes"]; "MEvent" -> "Chord" [arrowsize=0.5,style="setlinewidth(0.5)"]; "MEvent" [URL="api/maelzel.core.event.MEvent.html#maelzel.core.event.MEvent",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract class representing a discrete event in time (a Note, Chord, etc)"]; "MObj" -> "MEvent" [arrowsize=0.5,style="setlinewidth(0.5)"]; "MObj" [URL="api/maelzel.core.mobj.MObj.html#maelzel.core.mobj.MObj",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="This is the base class for all core objects."]; "ABC" -> "MObj" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Note" [URL="api/maelzel.core.event.Note.html#maelzel.core.event.Note",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Note represents a one-pitch event"]; "MEvent" -> "Note" [arrowsize=0.5,style="setlinewidth(0.5)"]; }