qschemas¶
Abstract Classes
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
Calls QSchema on
duration
.Gets item or slice identified by argument.
The schema's item class.
The item dictionary.
The default search tree.
The schema's target class.
The schema's target class' item class.
The default tempo.
Special methods
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
Beatwise q-schema. |
|
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 eitherBeatwiseQSchemaItem
instances, or dictionaries which could be used to instantiateBeatwiseQSchemaItem
instances, will apply those settings sequentially, starting from time-step0
:>>> 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
Gets repr.
Default beatspan of beatwise q-schema.
The schema's item class.
Target class of beatwise q-schema.
Target item class of beatwise q-schema.
Special methods
Read-only properties
- beatspan¶
Default beatspan of beatwise q-schema.
- overridden item_class¶
The schema’s item class.
- overridden target_class¶
Target class of beatwise q-schema.
- overridden target_item_class¶
Target item class of beatwise q-schema.
- 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 thequantize
function into beats according to its time signature.If
use_full_measure
isFalse
, 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 toTrue
, 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 eitherMeasurewiseQSchemaItem
instances, or dictionaries which could be used to instantiateMeasurewiseQSchemaItem
instances, will apply those settings sequentially, starting from time-step0
:>>> 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
Gets repr.
Item class of measurewise q-schema.
Target class of measurewise q-schema.
Target item class of measurewise q-schema.
Default time signature of measurewise q-schema.
The full-measure-as-beatspan default.
Special methods
Read-only properties
- overridden item_class¶
Item class of measurewise q-schema.
- overridden target_class¶
Target class of measurewise q-schema.
- overridden target_item_class¶
Target item class of measurewise q-schema.
- 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.