gracehandlers¶
Abstract Classes
Abstract grace-handler. |
- abstract class abjadext.nauert.gracehandlers.GraceHandler[source]¶
Abstract grace-handler.
Determines what pitch, if any, will be selected from a list of
QEvents
to be applied to an attack-point generated by aQGrid
, and whether there should be aBeforeGraceContainer
attached to that attack-point.When called on a sequence of
QEvents
,GraceHandler
subclasses should return a pair, where the first item of the pair is a sequence of pitch tokens orNone
, and where the second item of the pair is aBeforeGraceContainer
instance or None.Attributes Summary
Calls grace handler.
Special methods
- overridden abstract __call__(q_events)[source]¶
Calls grace handler.
- Return type:
tuple
[tuple
[NamedPitch
,...
],Optional
[tuple
],Optional
[BeforeGraceContainer
]]
Classes
Collapsing grace-handler. |
|
Concatenating grace-handler. |
|
Discarding grace-handler. |
- class abjadext.nauert.gracehandlers.CollapsingGraceHandler[source]¶
Collapsing grace-handler.
Collapses pitch information into a single chord rather than creating a grace container.
>>> durations = [1000, 1, 1, 997] >>> pitches = [0, 7, 4, 0] >>> q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs( ... tuple(zip(durations, pitches)) ... ) >>> grace_handler = nauert.CollapsingGraceHandler() >>> result = nauert.quantize(q_event_sequence, grace_handler=grace_handler) >>> abjad.show(result)
Attributes Summary
Calls collapsing grace handler.
Special methods
- class abjadext.nauert.gracehandlers.ConcatenatingGraceHandler(discard_grace_rest=True, grace_duration=None, replace_rest_with_final_grace_note=True)[source]¶
Concatenating grace-handler.
Concatenates all but the final
QEvent
attached to aQGrid
offset into aBeforeGraceContainer
, using a fixed leaf durationduration
.When called, it returns pitch information of final
QEvent
, and the generatedBeforeGraceContainer
, if any.>>> durations = [1000, 1, 999] >>> pitches = [0, 2, 0] >>> q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs( ... tuple(zip(durations, pitches)) ... ) >>> grace_handler = nauert.ConcatenatingGraceHandler() >>> result = nauert.quantize(q_event_sequence, grace_handler=grace_handler) >>> abjad.show(result)
When
discard_grace_rest
is set toTrue
(the default), all the grace rests are discarded.>>> durations = [1000, 1, 999] >>> pitches = [0, None, 0] >>> q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs( ... tuple(zip(durations, pitches)) ... ) >>> grace_handler = nauert.ConcatenatingGraceHandler() >>> result = nauert.quantize(q_event_sequence, grace_handler=grace_handler) >>> abjad.show(result)
When
discard_grace_rest
is set toFalse
, grace rests are not discarded.>>> grace_handler = nauert.ConcatenatingGraceHandler(discard_grace_rest=False) >>> result = nauert.quantize(q_event_sequence, grace_handler=grace_handler) >>> abjad.show(result)
When
replace_rest_with_final_grace_note
is set toFalse
, grace notes are allowed to be attached to a rest.>>> durations = [1000, 1, 999, 1000] >>> pitches = [0, 0, None, 0] >>> q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs( ... tuple(zip(durations, pitches)) ... ) >>> grace_handler = nauert.ConcatenatingGraceHandler( ... replace_rest_with_final_grace_note=False ... ) >>> result = nauert.quantize(q_event_sequence, grace_handler=grace_handler) >>> abjad.show(result)
When
replace_rest_with_final_grace_note
is set toTrue
(the default behavior), any rest with grace notes attached to it is replaced by the last pitched grace note in the grace container.>>> grace_handler = nauert.ConcatenatingGraceHandler() >>> result = nauert.quantize(q_event_sequence, grace_handler=grace_handler) >>> abjad.show(result)
Attributes Summary
Calls concatenating grace handler.
Boolean of whether to discard grace rests or not.
Grace duration of concantenating grace handler.
Embeds orphaned
QEvents
into anAfterGraceContainer
and attaches it to the last leaf.Boolean of whether to replace the rest with the final (pitched) grace note.
Special methods
- overridden __call__(q_events)[source]¶
Calls concatenating grace handler.
- Return type:
tuple
[tuple
[NamedPitch
,...
],Optional
[tuple
],Optional
[BeforeGraceContainer
]]
Methods
- handle_orphaned_q_event_proxies(last_leaf, q_event_proxies)[source]¶
Embeds orphaned
QEvents
into anAfterGraceContainer
and attaches it to the last leaf.>>> durations = [1000, 1000, 1000, 400, 50, 50] >>> pitches = range(len(durations)) >>> q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs( ... tuple(zip(durations, pitches)) ... ) >>> search_tree = nauert.UnweightedSearchTree() >>> attack_point_optimizer = nauert.MeasurewiseAttackPointOptimizer() >>> q_schema = nauert.MeasurewiseQSchema( ... search_tree=search_tree, time_signature=(7, 8), use_full_measure=True ... ) >>> result = nauert.quantize( ... q_event_sequence, ... q_schema=q_schema, ... attach_tempos=True, ... attack_point_optimizer=attack_point_optimizer, ... ) >>> staff = abjad.Staff([result]) >>> score = abjad.Score([staff], name="Score") >>> abjad.show(staff)
Read-only properties
- discard_grace_rest¶
Boolean of whether to discard grace rests or not.
- grace_duration¶
Grace duration of concantenating grace handler.
- replace_rest_with_final_grace_note¶
Boolean of whether to replace the rest with the final (pitched) grace note.
- class abjadext.nauert.gracehandlers.DiscardingGraceHandler[source]¶
Discarding grace-handler.
Discards all but final q-event attached to an offset.
Does not create grace containers.
>>> durations = [1000, 1, 999] >>> pitches = [0, 0, 1] >>> q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs( ... tuple(zip(durations, pitches)) ... ) >>> grace_handler = nauert.DiscardingGraceHandler() >>> result = nauert.quantize(q_event_sequence, grace_handler=grace_handler) >>> abjad.show(result)
Attributes Summary
Calls discarding grace handler.
Special methods