BeatwiseQSchema

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.BeatwiseQSchema.BeatwiseQSchema" [URL="../api/abjadext/nauert/BeatwiseQSchema.html#abjadext.nauert.BeatwiseQSchema.BeatwiseQSchema", color=black, fontcolor=white, label="Beatwise\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.BeatwiseQSchema.BeatwiseQSchema"; } 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.BeatwiseQSchema.BeatwiseQSchema(*arguments, **keywords)

Beatwise q-schema.

Treats beats as timestep unit.

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

Without arguments, it uses smart defaults:

>>> abjad.f(q_schema)
abjadext.nauert.BeatwiseQSchema(
    beatspan=abjad.Duration(1, 4),
    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,
        ),
    )

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 = abjadext.nauert.UnweightedSearchTree({7: None})
>>> tempo = abjad.MetronomeMark((1, 4), 54)
>>> q_schema = abjadext.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: 4=54
>>> 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: 4=54

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 = abjadext.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': abjadext.nauert.UnweightedSearchTree({2: None})}
>>> b = {'search_tree': abjadext.nauert.UnweightedSearchTree({3: None})}
>>> settings = {
...     2: a,
...     4: b,
... }
>>> q_schema = abjadext.nauert.MeasurewiseQSchema(settings)
>>> abjad.f(q_schema[0]['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,
        },
    )
>>> print(format(q_schema[1]['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,
        },
    )
>>> 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 = abjadext.nauert.MeasurewiseQSchema(
...     (2, {'search_tree': abjadext.nauert.UnweightedSearchTree({2: None})}),
...     (4, {'search_tree': abjadext.nauert.UnweightedSearchTree({3: None})}),
...     )

Attributes Summary

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.

(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

beatspan

Default beatspan of beatwise q-schema.

item_class

The schema’s item class.

Returns beatwise q-schema item.

(QSchema).items

The item dictionary.

(QSchema).search_tree

The default search tree.

target_class

Target class of beatwise q-schema.

Returns beatwise q-target.

target_item_class

Target item class of beatwise q-schema.

Returns q-target beat.

(QSchema).tempo

The default tempo.