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_abjadext.nauert.qeventsequence" { graph [label="abjadext.nauert.qeventsequence"]; node [color=1]; "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=2]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } "builtins.object" -> "abjadext.nauert.qeventsequence.QEventSequence"; }


Classes

QEventSequence

Q-event sequence.

class abjadext.nauert.qeventsequence.QEventSequence(sequence)[source]

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 = nauert.QEventSequence.from_millisecond_durations(durations)
>>> for q_event in sequence:
...     q_event
... 
PitchedQEvent(offset=Offset((0, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
SilentQEvent(offset=Offset((1000, 1)), index=None, attachments=())
PitchedQEvent(offset=Offset((1500, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
SilentQEvent(offset=Offset((2750, 1)), index=None, attachments=())
PitchedQEvent(offset=Offset((3250, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
TerminalQEvent(offset=Offset((4000, 1)), index=None, attachments=())

Attributes Summary

__contains__

Is true when q-event sequence contains argument.

__eq__

Is true when q-event sequence equals argument.

__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

Changes sequence of millisecond durations durations to a QEventSequence:

from_millisecond_offsets

Changes millisecond offsets offsets to a QEventSequence:

from_millisecond_pitch_attachment_tuples

Changes millisecond-duration:pitch:attachment tuples tuples into a QEventSequence:

from_millisecond_pitch_pairs

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

from_tempo_scaled_durations

Changes durations, scaled by tempo into a QEventSequence:

from_tempo_scaled_leaves

Changes leaves, optionally with tempo into a QEventSequence:

sequence

Sequence of q-events.


Special methods

__contains__(argument)[source]

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

Return type:

bool

overridden __eq__(argument)[source]

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

Return type:

bool

__getitem__(argument)[source]

Gets item or slice identified by argument.

Returns item or slice.

Return type:

QEvent | tuple[QEvent, ...]

overridden __hash__()[source]

Hashes q-event sequence.

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

Return type:

int

__iter__()[source]

Iterates q-event sequence.

Yields items.

Return type:

Iterator[QEvent]

__len__()[source]

Length of q-event sequence.

Return type:

int


Class & static methods

classmethod from_millisecond_durations(milliseconds, fuse_silences=False)[source]

Changes sequence of millisecond durations durations to a QEventSequence:

>>> durations = [-250, 500, -1000, 1250, -1000]
>>> sequence = nauert.QEventSequence.from_millisecond_durations(durations)
>>> for q_event in sequence:
...     q_event
... 
SilentQEvent(offset=Offset((0, 1)), index=None, attachments=())
PitchedQEvent(offset=Offset((250, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
SilentQEvent(offset=Offset((750, 1)), index=None, attachments=())
PitchedQEvent(offset=Offset((1750, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
SilentQEvent(offset=Offset((3000, 1)), index=None, attachments=())
TerminalQEvent(offset=Offset((4000, 1)), index=None, attachments=())
classmethod from_millisecond_offsets(offsets)[source]

Changes millisecond offsets offsets to a QEventSequence:

>>> offsets = [0, 250, 750, 1750, 3000, 4000]
>>> sequence = nauert.QEventSequence.from_millisecond_offsets(offsets)
>>> for q_event in sequence:
...     q_event
... 
PitchedQEvent(offset=Offset((0, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
PitchedQEvent(offset=Offset((250, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
PitchedQEvent(offset=Offset((750, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
PitchedQEvent(offset=Offset((1750, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
PitchedQEvent(offset=Offset((3000, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
TerminalQEvent(offset=Offset((4000, 1)), index=None, attachments=())
classmethod from_millisecond_pitch_attachment_tuples(tuples)[source]

Changes millisecond-duration:pitch:attachment tuples tuples into a QEventSequence:

>>> durations = [250, 500, 1000, 1250, 1000]
>>> pitches = [(0,), None, (2, 3), None, (1,)]
>>> attachments = [("foo",), None, None, None, ("foobar", "foo")]
>>> tuples = tuple(zip(durations, pitches, attachments))
>>> sequence = nauert.QEventSequence.from_millisecond_pitch_attachment_tuples(
...     tuples
... )
>>> for q_event in sequence:
...     q_event
... 
PitchedQEvent(offset=Offset((0, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=('foo',))
SilentQEvent(offset=Offset((250, 1)), index=None, attachments=())
PitchedQEvent(offset=Offset((750, 1)), pitches=(NamedPitch("d'"), NamedPitch("ef'")), index=None, attachments=())
SilentQEvent(offset=Offset((1750, 1)), index=None, attachments=())
PitchedQEvent(offset=Offset((3000, 1)), pitches=(NamedPitch("cs'"),), index=None, attachments=('foobar', 'foo'))
TerminalQEvent(offset=Offset((4000, 1)), index=None, attachments=())

PitchedQEvent(offset=Offset((3000, 1)), pitches=(NamedPitch(“cs’”),), index=None, attachments=(‘foobar’, ‘foo’)) TerminalQEvent(offset=Offset((4000, 1)), index=None, attachments=())

classmethod from_millisecond_pitch_pairs(pairs)[source]

Changes 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 = nauert.QEventSequence.from_millisecond_pitch_pairs(pairs)
>>> for q_event in sequence:
...     q_event
... 
PitchedQEvent(offset=Offset((0, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
SilentQEvent(offset=Offset((250, 1)), index=None, attachments=())
PitchedQEvent(offset=Offset((750, 1)), pitches=(NamedPitch("d'"), NamedPitch("ef'")), index=None, attachments=())
SilentQEvent(offset=Offset((1750, 1)), index=None, attachments=())
PitchedQEvent(offset=Offset((3000, 1)), pitches=(NamedPitch("cs'"),), index=None, attachments=())
TerminalQEvent(offset=Offset((4000, 1)), index=None, attachments=())
classmethod from_tempo_scaled_durations(durations, tempo)[source]

Changes durations, scaled by tempo into a QEventSequence:

>>> tempo = abjad.MetronomeMark(abjad.Duration(1, 4), 174)
>>> durations = [(1, 4), (-3, 16), (1, 16), (-1, 2)]
>>> sequence = nauert.QEventSequence.from_tempo_scaled_durations(
...     durations, tempo=tempo
... )
>>> for q_event in sequence:
...     q_event
... 
PitchedQEvent(offset=Offset((0, 1)), pitches=(NamedPitch("c'"),), index=None, attachments=())
SilentQEvent(offset=Offset((10000, 29)), index=None, attachments=())
PitchedQEvent(offset=Offset((17500, 29)), pitches=(NamedPitch("c'"),), index=None, attachments=())
SilentQEvent(offset=Offset((20000, 29)), index=None, attachments=())
TerminalQEvent(offset=Offset((40000, 29)), index=None, attachments=())
Return type:

QEventSequence

classmethod from_tempo_scaled_leaves(leaves, tempo=None)[source]

Changes leaves, optionally with tempo into a QEventSequence:

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

PitchedQEvent(offset=Offset((5000, 3)), pitches=(NamedPitch(“gqs’”),), index=None, attachments=()) TerminalQEvent(offset=Offset((10000, 3)), index=None, attachments=())

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.


Read-only properties

duration_in_ms

Duration in milliseconds of the QEventSequence:

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

Sequence of q-events.

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