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.Quantizer.Quantizer" [URL="../api/abjadext/nauert/Quantizer.html#abjadext.nauert.Quantizer.Quantizer", color=black, fontcolor=white, label=Quantizer, 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.Quantizer.Quantizer"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjadext.nauert.Quantizer.Quantizer


Quantizes sequences of attack-points, encapsulated by QEventSequences, into score trees.

>>> quantizer = abjadext.nauert.Quantizer()
>>> durations = [1000] * 8
>>> pitches = range(8)
>>> q_event_sequence = \
...     abjadext.nauert.QEventSequence.from_millisecond_pitch_pairs(
...     tuple(zip(durations, pitches)))

Quantization defaults to outputting into a 4/4, quarter=60 musical structure:

>>> result = quantizer(q_event_sequence)
>>> staff = abjad.Staff([result])
>>> score = abjad.Score([staff])
>>> abjad.show(score) 

However, the behavior of the Quantizer can be modified at call-time. Passing a QSchema instance will alter the macro-structure of the output.

Here, we quantize using settings specified by a MeasurewiseQSchema, which will cause the Quantizer to group the output into measures with different tempi and time signatures:

>>> measurewise_q_schema = abjadext.nauert.MeasurewiseQSchema(
...     {'tempo': ((1, 4), 78), 'time_signature': (2, 4)},
...     {'tempo': ((1, 8), 57), 'time_signature': (5, 4)},
...     )
>>> result = quantizer(
...     q_event_sequence,
...     q_schema=measurewise_q_schema,
...     )
>>> staff = abjad.Staff([result])
>>> score = abjad.Score([staff])
>>> abjad.show(score) 

Here we quantize using settings specified by a BeatwiseQSchema, which keeps the output of the quantizer “flattened”, without measures or explicit time signatures. The default beat-wise settings of quarter=60 persists until the third “beatspan”:

>>> beatwise_q_schema = abjadext.nauert.BeatwiseQSchema(
... {
...     2: {'tempo': ((1, 4), 120)},
...     5: {'tempo': ((1, 4), 90)},
...     7: {'tempo': ((1, 4), 30)},
... })
>>> result = quantizer(
...     q_event_sequence,
...     q_schema=beatwise_q_schema,
...     )
>>> staff = abjad.Staff([result])
>>> score = abjad.Score([staff])
>>> abjad.show(score) 

Note that TieChains are generally fused together in the above example, but break at tempo changes.

Other keyword arguments are:

  • grace_handler: a GraceHandler instance controls whether and how grace notes are used in the output. Options currently include CollapsingGraceHandler, ConcatenatingGraceHandler and DiscardingGraceHandler.
  • heuristic: a Heuristic instance controls how output rhythms are selected from a pool of candidates. Options currently include the DistanceHeuristic class.
  • job_handler: a JobHandler instance controls whether or not parallel processing is used during the quantization process. Options include the SerialJobHandler and ParallelJobHandler classes.
  • attack_point_optimizer: an AttackPointOptimizer instance controls whether and how logical ties are re-notated. Options currently include MeasurewiseAttackPointOptimizer, NaiveAttackPointOptimizer and NullAttackPointOptimizer.

Refer to the reference pages for BeatwiseQSchema and MeasurewiseQSchema for more information on controlling the Quantizer’s output, and to the reference on SearchTree for information on controlling the rhythmic complexity of that same output.

Attributes Summary

__call__ Calls quantizer.

Special methods

__call__(q_event_sequence, q_schema=None, grace_handler=None, heuristic=None, job_handler=None, attack_point_optimizer=None, attach_tempos=True)

Calls quantizer.

Returns Abjad components.


Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.


Gets interpreter representation of Abjad object.

Returns string.