MeasurewiseQSchema

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.MeasurewiseQSchema.MeasurewiseQSchema" [URL="../api/abjadext/nauert/MeasurewiseQSchema.html#abjadext.nauert.MeasurewiseQSchema.MeasurewiseQSchema", color=black, fontcolor=white, label="Measurewise\nQSchema", target=_top]; "abjadext.nauert.QSchema.QSchema" [URL="../api/abjadext/nauert/QSchema.html#abjadext.nauert.QSchema.QSchema", label=QSchema, shape=oval, style=bold, target=_top]; "abjadext.nauert.QSchema.QSchema" -> "abjadext.nauert.MeasurewiseQSchema.MeasurewiseQSchema"; } 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.QSchema.QSchema"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjadext.nauert.MeasurewiseQSchema.MeasurewiseQSchema(*arguments, **keywords)

Measurewise q-schema.

Treats measures as its timestep unit.

>>> q_schema = abjadext.nauert.MeasurewiseQSchema()

Without arguments, it uses smart defaults:

>>> abjad.f(q_schema)
abjadext.nauert.MeasurewiseQSchema(
    search_tree=abjadext.nauert.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=abjad.MetronomeMark(
        reference_duration=abjad.Duration(1, 4),
        units_per_minute=60,
        ),
    time_signature=abjad.TimeSignature((4, 4)),
    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 = abjadext.nauert.UnweightedSearchTree({7: None})
>>> time_signature = abjad.TimeSignature((3, 4))
>>> tempo = abjad.MetronomeMark((1, 4), 54)
>>> use_full_measure = True
>>> q_schema = abjadext.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 Quantizer 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: 4=54
time_signature: 3/4
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: 4=54
time_signature: 3/4
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': abjadext.nauert.UnweightedSearchTree({2: None})}
>>> b = {'search_tree': abjadext.nauert.UnweightedSearchTree({3: None})}
>>> c = {'search_tree': abjadext.nauert.UnweightedSearchTree({5: None})}
>>> q_schema = abjadext.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 = abjadext.nauert.MeasurewiseQSchema(settings)
>>> q_schema[0]['time_signature']
TimeSignature((4, 4))
>>> q_schema[1]['time_signature']
TimeSignature((4, 4))
>>> q_schema[2]['time_signature']
TimeSignature((7, 32))
>>> q_schema[3]['time_signature']
TimeSignature((7, 32))
>>> q_schema[4]['time_signature']
TimeSignature((3, 4))
>>> q_schema[5]['time_signature']
TimeSignature((3, 4))
>>> q_schema[6]['time_signature']
TimeSignature((5, 8))
>>> q_schema[1000]['time_signature']
TimeSignature((5, 8))

The following is equivalent to the above schema definition:

>>> q_schema = abjadext.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

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.

(QSchema).__format__(format_specification='')

Formats q-event.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(QSchema).__getitem__(argument)

Gets item or slice identified by argument.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Read-only properties

item_class

Item class of measurewise q-schema.

Returns MeasurewiseQSchemaItem.

(QSchema).items

The item dictionary.

(QSchema).search_tree

The default search tree.

target_class

Target class of measurewise q-schema.

Returns MeasurewiseQTarget.

target_item_class

Target item class of measurewise q-schema.

Returns QTargetMeasure.

(QSchema).tempo

The default tempo.

time_signature

Default time signature of measurewise q-schema.

Returns time signature.

use_full_measure

The full-measure-as-beatspan default.

Returns true or false.