QEventSequence

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=1]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjadext/nauert/../../abjad/system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph "cluster_abjadext.nauert" { graph [label="abjadext.nauert"]; node [color=2]; "abjadext.nauert.QEventSequence.QEventSequence" [URL="../api/abjadext/nauert/QEventSequence.html#abjadext.nauert.QEventSequence.QEventSequence", color=black, fontcolor=white, label="QEvent\nSequence", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadObject.AbjadObject" -> "abjadext.nauert.QEventSequence.QEventSequence"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjadext.nauert.QEventSequence.QEventSequence(sequence=None)

Q-event sequence.

Contains only pitched q-events and silent q-events, and terminates with a single terminal q-event.

A q-event sequence is the primary input to the quantizer.

A q-event sequence provides a number of convenience functions to assist with instantiating new sequences:

>>> durations = (1000, -500, 1250, -500, 750)
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_millisecond_durations(
...     durations)
>>> for q_event in sequence:
...     abjad.f(q_event)
...
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(0, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(1000, 1),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(1500, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(2750, 1),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(3250, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.TerminalQEvent(
    offset=abjad.Offset(4000, 1),
    )

Attributes Summary

__contains__ Is true when q-event sequence contains argument.
__eq__ Is true when q-event sequence equals argument.
__format__ Formats q-event sequence.
__getitem__ Gets item or slice identified by argument.
__hash__ Hashes q-event sequence.
__iter__ Iterates q-event sequence.
__len__ Length of q-event sequence.
duration_in_ms Duration in milliseconds of the QEventSequence:
from_millisecond_durations Convert a sequence of millisecond durations durations into a QEventSequence:
from_millisecond_offsets Convert millisecond offsets offsets into a QEventSequence:
from_millisecond_pitch_pairs Convert millisecond-duration:pitch pairs pairs into a QEventSequence:
from_tempo_scaled_durations Convert durations, scaled by tempo into a QEventSequence:
from_tempo_scaled_leaves Convert leaves, optionally with tempo into a QEventSequence:
sequence Sequence of q-events.

Special methods

__contains__(argument)

Is true when q-event sequence contains argument. Otherwise false.

Returns true or false.

__eq__(argument)

Is true when q-event sequence equals argument. Otherwise false.

Returns true or false.

__format__(format_specification='')

Formats q-event sequence.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

>>> durations = (1000, -500, 1250, -500, 750)
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_millisecond_durations(
...     durations)
>>> print(format(sequence))
abjadext.nauert.QEventSequence(
    (
        abjadext.nauert.PitchedQEvent(
            offset=abjad.Offset(0, 1),
            pitches=(
                abjad.NamedPitch("c'"),
                ),
            ),
        abjadext.nauert.SilentQEvent(
            offset=abjad.Offset(1000, 1),
            ),
        abjadext.nauert.PitchedQEvent(
            offset=abjad.Offset(1500, 1),
            pitches=(
                abjad.NamedPitch("c'"),
                ),
            ),
        abjadext.nauert.SilentQEvent(
            offset=abjad.Offset(2750, 1),
            ),
        abjadext.nauert.PitchedQEvent(
            offset=abjad.Offset(3250, 1),
            pitches=(
                abjad.NamedPitch("c'"),
                ),
            ),
        abjadext.nauert.TerminalQEvent(
            offset=abjad.Offset(4000, 1),
            ),
        )
    )

Returns string.

__getitem__(argument)

Gets item or slice identified by argument.

Returns item or slice.

__hash__()

Hashes q-event sequence.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

__iter__()

Iterates q-event sequence.

Yields items.

__len__()

Length of q-event sequence.

Returns nonnegative integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Class & static methods

classmethod from_millisecond_durations(milliseconds, fuse_silences=False)

Convert a sequence of millisecond durations durations into a QEventSequence:

>>> durations = [-250, 500, -1000, 1250, -1000]
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_millisecond_durations(
...     durations)
>>> for q_event in sequence:
...     print(format(q_event, 'storage'))
...
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(0, 1),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(250, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(750, 1),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(1750, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(3000, 1),
    )
abjadext.nauert.TerminalQEvent(
    offset=abjad.Offset(4000, 1),
    )

Returns QEventSequence instance.

classmethod from_millisecond_offsets(offsets)

Convert millisecond offsets offsets into a QEventSequence:

>>> offsets = [0, 250, 750, 1750, 3000, 4000]
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_millisecond_offsets(
...     offsets)
>>> for q_event in sequence:
...     print(format(q_event, 'storage'))
...
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(0, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(250, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(750, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(1750, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(3000, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.TerminalQEvent(
    offset=abjad.Offset(4000, 1),
    )

Returns QEventSequence instance.

classmethod from_millisecond_pitch_pairs(pairs)

Convert millisecond-duration:pitch pairs pairs into a QEventSequence:

>>> durations = [250, 500, 1000, 1250, 1000]
>>> pitches = [(0,), None, (2, 3), None, (1,)]
>>> pairs = tuple(zip(durations, pitches))
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_millisecond_pitch_pairs(
...     pairs)
>>> for q_event in sequence:
...     print(format(q_event, 'storage'))
...
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(0, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(250, 1),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(750, 1),
    pitches=(
        abjad.NamedPitch("d'"),
        abjad.NamedPitch("ef'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(1750, 1),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(3000, 1),
    pitches=(
        abjad.NamedPitch("cs'"),
        ),
    )
abjadext.nauert.TerminalQEvent(
    offset=abjad.Offset(4000, 1),
    )

Returns QEventSequence instance.

classmethod from_tempo_scaled_durations(durations, tempo=None)

Convert durations, scaled by tempo into a QEventSequence:

>>> tempo = abjad.MetronomeMark((1, 4), 174)
>>> durations = [(1, 4), (-3, 16), (1, 16), (-1, 2)]
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_tempo_scaled_durations(
...     durations, tempo=tempo)
>>> for q_event in sequence:
...     print(format(q_event, 'storage'))
...
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(0, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(10000, 29),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(17500, 29),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(20000, 29),
    )
abjadext.nauert.TerminalQEvent(
    offset=abjad.Offset(40000, 29),
    )

Returns QEventSequence instance.

classmethod from_tempo_scaled_leaves(leaves, tempo=None)

Convert leaves, optionally with tempo into a QEventSequence:

>>> staff = abjad.Staff("c'4 <d' fs'>8. r16 gqs'2")
>>> tempo = abjad.MetronomeMark((1, 4), 72)
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_tempo_scaled_leaves(
...     staff[:], tempo=tempo)
>>> for q_event in sequence:
...     print(format(q_event, 'storage'))
...
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(0, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(2500, 3),
    pitches=(
        abjad.NamedPitch("d'"),
        abjad.NamedPitch("fs'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(4375, 3),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(5000, 3),
    pitches=(
        abjad.NamedPitch("gqs'"),
        ),
    )
abjadext.nauert.TerminalQEvent(
    offset=abjad.Offset(10000, 3),
    )

If tempo is None, all leaves in leaves must have an effective, non-imprecise tempo. The millisecond-duration of each leaf will be determined by its effective tempo.

Return QEventSequence instance.


Read-only properties

duration_in_ms

Duration in milliseconds of the QEventSequence:

>>> durations = (1000, -500, 1250, -500, 750)
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_millisecond_durations(
...     durations)
>>> sequence.duration_in_ms
Duration(4000, 1)

Return Duration instance.

sequence

Sequence of q-events.

>>> durations = (1000, -500, 1250, -500, 750)
>>> sequence = \
...     abjadext.nauert.QEventSequence.from_millisecond_durations(
...     durations)
>>> for q_event in sequence.sequence:
...     print(format(q_event, 'storage'))
...
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(0, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(1000, 1),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(1500, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.SilentQEvent(
    offset=abjad.Offset(2750, 1),
    )
abjadext.nauert.PitchedQEvent(
    offset=abjad.Offset(3250, 1),
    pitches=(
        abjad.NamedPitch("c'"),
        ),
    )
abjadext.nauert.TerminalQEvent(
    offset=abjad.Offset(4000, 1),
    )

Returns tuple.