qschemas

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_abc { graph [label=abc]; node [color=1]; "abc.ABC" [URL="https://docs.python.org/3.10/library/abc.html#abc.ABC", label=ABC, target=_top]; } subgraph "cluster_abjadext.nauert.qschemas" { graph [label="abjadext.nauert.qschemas"]; node [color=2]; "abjadext.nauert.qschemas.BeatwiseQSchema" [URL="../api/abjadext/nauert/qschemas.html#abjadext.nauert.qschemas.BeatwiseQSchema", color=black, fontcolor=white, label="Beatwise\nQSchema", target=_top]; "abjadext.nauert.qschemas.MeasurewiseQSchema" [URL="../api/abjadext/nauert/qschemas.html#abjadext.nauert.qschemas.MeasurewiseQSchema", color=black, fontcolor=white, label="Measurewise\nQSchema", target=_top]; "abjadext.nauert.qschemas.QSchema" [URL="../api/abjadext/nauert/qschemas.html#abjadext.nauert.qschemas.QSchema", color=black, fontcolor=white, label=QSchema, shape=oval, style="bold, filled", target=_top]; "abjadext.nauert.qschemas.QSchema" -> "abjadext.nauert.qschemas.BeatwiseQSchema"; "abjadext.nauert.qschemas.QSchema" -> "abjadext.nauert.qschemas.MeasurewiseQSchema"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } "abc.ABC" -> "abjadext.nauert.qschemas.QSchema"; "builtins.object" -> "abc.ABC"; }


Abstract Classes

QSchema

Abstract Q-schema.

abstract class abjadext.nauert.qschemas.QSchema(*arguments, **keywords)[source]

Abstract Q-schema.

QSchema allows for the specification of quantization settings diachronically, at any time-step of the quantization process.

In practice, this provides a means for the composer to change the tempo, search-tree, time-signature etc., effectively creating a template into which quantized rhythms can be “poured”, without yet knowing what those rhythms might be, or even how much time the ultimate result will take. Like Abjad indicators the settings made at any given time-step via a QSchema instance are understood to persist until changed.

All concrete QSchema subclasses strongly implement default values for all of their parameters.

QSchema is abstract.


Attributes Summary

__call__

Calls QSchema on duration.

__getitem__

Gets item or slice identified by argument.

item_class

The schema's item class.

items

The item dictionary.

search_tree

The default search tree.

target_class

The schema's target class.

target_item_class

The schema's target class' item class.

tempo

The default tempo.


Special methods

overridden __call__(duration)[source]

Calls QSchema on duration.

Return type:

QTarget

__getitem__(argument)[source]

Gets item or slice identified by argument.

Return type:

dict


Read-only properties

item_class

The schema’s item class.

items

The item dictionary.

search_tree

The default search tree.

target_class

The schema’s target class.

target_item_class

The schema’s target class’ item class.

tempo

The default tempo.


Classes

BeatwiseQSchema

Beatwise q-schema.

MeasurewiseQSchema

Measurewise q-schema.

class abjadext.nauert.qschemas.BeatwiseQSchema(*arguments, **keywords)[source]

Beatwise q-schema.

Treats beats as timestep unit.

>>> q_schema = nauert.BeatwiseQSchema()

Without arguments, it uses smart defaults:

>>> q_schema
BeatwiseQSchema(beatspan=Duration(1, 4), search_tree=UnweightedSearchTree(definition={2: {2: {2: {2: None}, 3: None}, 3: None, 5: None, 7: None}, 3: {2: {2: None}, 3: None, 5: None}, 5: {2: None, 3: None}, 7: {2: None}, 11: None, 13: None}), tempo=MetronomeMark(reference_duration=Duration(1, 4), units_per_minute=60, textual_indication=None, custom_markup=None, decimal=False, hide=False))

Each time-step in a BeatwiseQSchema is composed of three settings:

  • beatspan

  • search_tree

  • tempo

These settings can be applied as global defaults for the schema via keyword arguments, which persist until overridden:

>>> beatspan = abjad.Duration(5, 16)
>>> search_tree = nauert.UnweightedSearchTree({7: None})
>>> tempo = abjad.MetronomeMark(abjad.Duration(1, 4), 54)
>>> q_schema = nauert.BeatwiseQSchema(
...     beatspan=beatspan,
...     search_tree=search_tree,
...     tempo=tempo,
... )

The computed value at any non-negative time-step can be found by subscripting:

>>> index = 0
>>> for key, value in sorted(q_schema[index].items()):
...     print("{}:".format(key), value)
... 
beatspan: 5/16
search_tree: UnweightedSearchTree(definition={7: None})
tempo: MetronomeMark(reference_duration=Duration(1, 4), units_per_minute=54, textual_indication=None, custom_markup=None, decimal=False, hide=False)
>>> index = 1000
>>> for key, value in sorted(q_schema[index].items()):
...     print("{}:".format(key), value)
... 
beatspan: 5/16
search_tree: UnweightedSearchTree(definition={7: None})
tempo: MetronomeMark(reference_duration=Duration(1, 4), units_per_minute=54, textual_indication=None, custom_markup=None, decimal=False, hide=False)

Per-time-step settings can be applied in a variety of ways.

Instantiating the schema via *arguments with a series of either BeatwiseQSchemaItem instances, or dictionaries which could be used to instantiate BeatwiseQSchemaItem instances, will apply those settings sequentially, starting from time-step 0:

>>> a = {"beatspan": abjad.Duration(5, 32)}
>>> b = {"beatspan": abjad.Duration(3, 16)}
>>> c = {"beatspan": abjad.Duration(1, 8)}
>>> q_schema = nauert.BeatwiseQSchema(a, b, c)
>>> q_schema[0]["beatspan"]
Duration(5, 32)
>>> q_schema[1]["beatspan"]
Duration(3, 16)
>>> q_schema[2]["beatspan"]
Duration(1, 8)
>>> q_schema[3]["beatspan"]
Duration(1, 8)

Similarly, instantiating the schema from a single dictionary, consisting of integer:specification pairs, or a sequence via *arguments of (integer, specification) pairs, allows for applying settings to non-sequential time-steps:

>>> a = {"search_tree": nauert.UnweightedSearchTree({2: None})}
>>> b = {"search_tree": nauert.UnweightedSearchTree({3: None})}
>>> settings = {
...     2: a,
...     4: b,
... }
>>> q_schema = nauert.BeatwiseQSchema(settings)
>>> q_schema[0]["search_tree"]
UnweightedSearchTree(definition={2: {2: {2: {2: None}, 3: None}, 3: None, 5: None, 7: None}, 3: {2: {2: None}, 3: None, 5: None}, 5: {2: None, 3: None}, 7: {2: None}, 11: None, 13: None})
>>> q_schema[1]["search_tree"]
UnweightedSearchTree(definition={2: {2: {2: {2: None}, 3: None}, 3: None, 5: None, 7: None}, 3: {2: {2: None}, 3: None, 5: None}, 5: {2: None, 3: None}, 7: {2: None}, 11: None, 13: None})
>>> q_schema[2]["search_tree"]
UnweightedSearchTree(definition={2: None})
>>> q_schema[3]["search_tree"]
UnweightedSearchTree(definition={2: None})
>>> q_schema[4]["search_tree"]
UnweightedSearchTree(definition={3: None})
>>> q_schema[1000]["search_tree"]
UnweightedSearchTree(definition={3: None})

The following is equivalent to the above schema definition:

>>> q_schema = nauert.BeatwiseQSchema(
...     (2, {"search_tree": nauert.UnweightedSearchTree({2: None})}),
...     (4, {"search_tree": nauert.UnweightedSearchTree({3: None})}),
... )

Attributes Summary

__repr__

Gets repr.

beatspan

Default beatspan of beatwise q-schema.

item_class

The schema's item class.

target_class

Target class of beatwise q-schema.

target_item_class

Target item class of beatwise q-schema.


Special methods

(QSchema).__call__(duration)

Calls QSchema on duration.

Return type:

QTarget

(QSchema).__getitem__(argument)

Gets item or slice identified by argument.

Return type:

dict

overridden __repr__()[source]

Gets repr.


Read-only properties

beatspan

Default beatspan of beatwise q-schema.

overridden item_class

The schema’s item class.

(QSchema).items

The item dictionary.

(QSchema).search_tree

The default search tree.

overridden target_class

Target class of beatwise q-schema.

overridden target_item_class

Target item class of beatwise q-schema.

(QSchema).tempo

The default tempo.

class abjadext.nauert.qschemas.MeasurewiseQSchema(*arguments, **keywords)[source]

Measurewise q-schema.

Treats measures as its timestep unit.

>>> q_schema = nauert.MeasurewiseQSchema()

Without arguments, it uses smart defaults:

>>> q_schema
MeasurewiseQSchema(search_tree=UnweightedSearchTree(definition={2: {2: {2: {2: None}, 3: None}, 3: None, 5: None, 7: None}, 3: {2: {2: None}, 3: None, 5: None}, 5: {2: None, 3: None}, 7: {2: None}, 11: None, 13: None}), tempo=MetronomeMark(reference_duration=Duration(1, 4), units_per_minute=60, textual_indication=None, custom_markup=None, decimal=False, hide=False), time_signature=TimeSignature(pair=(4, 4), hide=False, partial=None), use_full_measure=False)

Each time-step in a MeasurewiseQSchema is composed of four settings:

  • search_tree

  • tempo

  • time_signature

  • use_full_measure

These settings can be applied as global defaults for the schema via keyword arguments, which persist until overridden:

>>> search_tree = nauert.UnweightedSearchTree({7: None})
>>> time_signature = abjad.TimeSignature((3, 4))
>>> tempo = abjad.MetronomeMark(abjad.Duration(1, 4), 54)
>>> use_full_measure = True
>>> q_schema = nauert.MeasurewiseQSchema(
...     search_tree=search_tree,
...     tempo=tempo,
...     time_signature=time_signature,
...     use_full_measure=use_full_measure,
... )

All of these settings are self-descriptive, except for use_full_measure, which controls whether the measure is subdivided by the quantize function into beats according to its time signature.

If use_full_measure is False, the time-step’s measure will be divided into units according to its time-signature. For example, a 4/4 measure will be divided into 4 units, each having a beatspan of 1/4.

On the other hand, if use_full_measure is set to True, the time-step’s measure will not be subdivided into independent quantization units. This usually results in full-measure tuplets.

The computed value at any non-negative time-step can be found by subscripting:

>>> index = 0
>>> for key, value in sorted(q_schema[index].items()):
...     print("{}:".format(key), value)
... 
search_tree: UnweightedSearchTree(definition={7: None})
tempo: MetronomeMark(reference_duration=Duration(1, 4), units_per_minute=54, textual_indication=None, custom_markup=None, decimal=False, hide=False)
time_signature: TimeSignature(pair=(3, 4), hide=False, partial=None)
use_full_measure: True
>>> index = 1000
>>> for key, value in sorted(q_schema[index].items()):
...     print("{}:".format(key), value)
... 
search_tree: UnweightedSearchTree(definition={7: None})
tempo: MetronomeMark(reference_duration=Duration(1, 4), units_per_minute=54, textual_indication=None, custom_markup=None, decimal=False, hide=False)
time_signature: TimeSignature(pair=(3, 4), hide=False, partial=None)
use_full_measure: True

Per-time-step settings can be applied in a variety of ways.

Instantiating the schema via *arguments with a series of either MeasurewiseQSchemaItem instances, or dictionaries which could be used to instantiate MeasurewiseQSchemaItem instances, will apply those settings sequentially, starting from time-step 0:

>>> a = {"search_tree": nauert.UnweightedSearchTree({2: None})}
>>> b = {"search_tree": nauert.UnweightedSearchTree({3: None})}
>>> c = {"search_tree": nauert.UnweightedSearchTree({5: None})}
>>> q_schema = nauert.MeasurewiseQSchema(a, b, c)
>>> q_schema[0]["search_tree"]
UnweightedSearchTree(definition={2: None})
>>> q_schema[1]["search_tree"]
UnweightedSearchTree(definition={3: None})
>>> q_schema[2]["search_tree"]
UnweightedSearchTree(definition={5: None})
>>> q_schema[1000]["search_tree"]
UnweightedSearchTree(definition={5: None})

Similarly, instantiating the schema from a single dictionary, consisting of integer:specification pairs, or a sequence via *arguments of (integer, specification) pairs, allows for applying settings to non-sequential time-steps:

>>> a = {"time_signature": abjad.TimeSignature((7, 32))}
>>> b = {"time_signature": abjad.TimeSignature((3, 4))}
>>> c = {"time_signature": abjad.TimeSignature((5, 8))}
>>> settings = {
...     2: a,
...     4: b,
...     6: c,
... }
>>> q_schema = nauert.MeasurewiseQSchema(settings)
>>> q_schema[0]["time_signature"]
TimeSignature(pair=(4, 4), hide=False, partial=None)
>>> q_schema[1]["time_signature"]
TimeSignature(pair=(4, 4), hide=False, partial=None)
>>> q_schema[2]["time_signature"]
TimeSignature(pair=(7, 32), hide=False, partial=None)
>>> q_schema[3]["time_signature"]
TimeSignature(pair=(7, 32), hide=False, partial=None)
>>> q_schema[4]["time_signature"]
TimeSignature(pair=(3, 4), hide=False, partial=None)
>>> q_schema[5]["time_signature"]
TimeSignature(pair=(3, 4), hide=False, partial=None)
>>> q_schema[6]["time_signature"]
TimeSignature(pair=(5, 8), hide=False, partial=None)
>>> q_schema[1000]["time_signature"]
TimeSignature(pair=(5, 8), hide=False, partial=None)

The following is equivalent to the above schema definition:

>>> q_schema = nauert.MeasurewiseQSchema(
...     (2, {"time_signature": abjad.TimeSignature((7, 32))}),
...     (4, {"time_signature": abjad.TimeSignature((3, 4))}),
...     (6, {"time_signature": abjad.TimeSignature((5, 8))}),
... )

Attributes Summary

__repr__

Gets repr.

item_class

Item class of measurewise q-schema.

target_class

Target class of measurewise q-schema.

target_item_class

Target item class of measurewise q-schema.

time_signature

Default time signature of measurewise q-schema.

use_full_measure

The full-measure-as-beatspan default.


Special methods

(QSchema).__call__(duration)

Calls QSchema on duration.

Return type:

QTarget

(QSchema).__getitem__(argument)

Gets item or slice identified by argument.

Return type:

dict

overridden __repr__()[source]

Gets repr.


Read-only properties

overridden item_class

Item class of measurewise q-schema.

(QSchema).items

The item dictionary.

(QSchema).search_tree

The default search tree.

overridden target_class

Target class of measurewise q-schema.

overridden target_item_class

Target item class of measurewise q-schema.

(QSchema).tempo

The default tempo.

time_signature

Default time signature of measurewise q-schema.

>>> q_schema = nauert.MeasurewiseQSchema(time_signature=abjad.TimeSignature((3, 4)))
>>> q_schema.time_signature
TimeSignature(pair=(3, 4), hide=False, partial=None)

If there are multiple time signatures in the QSchema, this returns the default time signature of (4, 4).

>>> a = {"time_signature": abjad.TimeSignature((7, 32))}
>>> b = {"time_signature": abjad.TimeSignature((3, 4))}
>>> c = {"time_signature": abjad.TimeSignature((5, 8))}
>>> settings = {
...     2: a,
...     4: b,
...     6: c,
... }
>>> q_schema = nauert.MeasurewiseQSchema(settings)
>>> q_schema.time_signature
TimeSignature(pair=(4, 4), hide=False, partial=None)
use_full_measure

The full-measure-as-beatspan default.