MeasurewiseQSchema

class quantizationtools.MeasurewiseQSchema(*arguments, **keywords)

Concrete QSchema subclass which treats “measures” as its time-step unit.

>>> q_schema = quantizationtools.MeasurewiseQSchema()

Without arguments, it uses smart defaults:

>>> print(format(q_schema, 'storage'))
quantizationtools.MeasurewiseQSchema(
    search_tree=quantizationtools.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=indicatortools.Tempo(
        reference_duration=durationtools.Duration(1, 4),
        units_per_minute=60,
        ),
    time_signature=indicatortools.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 = quantizationtools.UnweightedSearchTree({7: None})
>>> time_signature = TimeSignature((3, 4))
>>> tempo = Tempo((1, 4), 54)
>>> use_full_measure = True
>>> q_schema = quantizationtools.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': quantizationtools.UnweightedSearchTree({2: None})}
>>> b = {'search_tree': quantizationtools.UnweightedSearchTree({3: None})}
>>> c = {'search_tree': quantizationtools.UnweightedSearchTree({5: None})}
>>> q_schema = quantizationtools.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': TimeSignature((7, 32))}
>>> b = {'time_signature': TimeSignature((3, 4))}
>>> c = {'time_signature': TimeSignature((5, 8))}
>>> settings = {
...     2: a,
...     4: b,
...     6: c,
... }
>>> q_schema = quantizationtools.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 = quantizationtools.MeasurewiseQSchema(
...     (2, {'time_signature': TimeSignature((7, 32))}),
...     (4, {'time_signature': TimeSignature((3, 4))}),
...     (6, {'time_signature': TimeSignature((5, 8))}),
...     )

Return MeasurewiseQSchema instance.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_quantizationtools { graph [label=quantizationtools]; "abjad.tools.quantizationtools.MeasurewiseQSchema.MeasurewiseQSchema" [color=black, fontcolor=white, group=2, label=<<B>MeasurewiseQSchema</B>>, shape=box, style="filled, rounded"]; "abjad.tools.quantizationtools.QSchema.QSchema" [color=3, group=2, label=QSchema, shape=oval, style=bold]; "abjad.tools.quantizationtools.QSchema.QSchema" -> "abjad.tools.quantizationtools.MeasurewiseQSchema.MeasurewiseQSchema"; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.quantizationtools.QSchema.QSchema"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

item_class Item class of measurewise q-schema.
items The item dictionary.
search_tree The default search tree.
target_class Target class of measurewise q-schema.
target_item_class Target item class of measurewise q-schema.
tempo The default tempo.
time_signature Default time signature of measurewise q-schema.
use_full_measure The full-measure-as-beatspan default.
__call__(duration) Calls QSchema on duration.
__eq__(argument) Is true when ID of argument equals ID of Abjad object.
__format__([format_specification]) Formats q-event.
__getitem__(argument) Gets item or slice identified by argument.
__hash__() Hashes Abjad object.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

MeasurewiseQSchema.item_class

Item class of measurewise q-schema.

Returns MeasurewiseQSchemaItem.

(QSchema).items

The item dictionary.

(QSchema).search_tree

The default search tree.

MeasurewiseQSchema.target_class

Target class of measurewise q-schema.

Returns MeasurewiseQTarget.

MeasurewiseQSchema.target_item_class

Target item class of measurewise q-schema.

Returns QTargetMeasure.

(QSchema).tempo

The default tempo.

MeasurewiseQSchema.time_signature

Default time signature of measurewise q-schema.

Returns time signature.

MeasurewiseQSchema.use_full_measure

The full-measure-as-beatspan default.

Returns true or false.

Special methods

(QSchema).__call__(duration)

Calls QSchema on duration.

(AbjadObject).__eq__(argument)

Is true when ID of argument equals ID of Abjad object. Otherwise false.

Returns true or false.

(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).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.