qeventsequence¶
Classes
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
Is true when q-event sequence contains
argument
.Is true when q-event sequence equals
argument
.Gets item or slice identified by argument.
Hashes q-event sequence.
Iterates q-event sequence.
Length of q-event sequence.
Duration in milliseconds of the
QEventSequence
:Changes sequence of millisecond durations
durations
to aQEventSequence
:Changes millisecond offsets
offsets
to aQEventSequence
:Changes millisecond-duration:pitch:attachment tuples
tuples
into aQEventSequence
:Changes millisecond-duration:pitch pairs
pairs
into aQEventSequence
:Changes
durations
, scaled bytempo
into aQEventSequence
:Changes
leaves
, optionally withtempo
into aQEventSequence
:Sequence of q-events.
Special methods
- __contains__(argument)[source]¶
Is true when q-event sequence contains
argument
. Otherwise false.- Return type:
- overridden __eq__(argument)[source]¶
Is true when q-event sequence equals
argument
. Otherwise false.- Return type:
- overridden __hash__()[source]¶
Hashes q-event sequence.
Required to be explicitly redefined on Python 3 if __eq__ changes.
- Return type:
Class & static methods
- classmethod from_millisecond_durations(milliseconds, fuse_silences=False)[source]¶
Changes sequence of millisecond durations
durations
to aQEventSequence
:>>> 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 aQEventSequence
:>>> 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 aQEventSequence
:>>> 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 aQEventSequence
:>>> 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 bytempo
into aQEventSequence
:>>> 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:
- classmethod from_tempo_scaled_leaves(leaves, tempo=None)[source]¶
Changes
leaves
, optionally withtempo
into aQEventSequence
:>>> 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
isNone
, all leaves inleaves
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=())