QGrid

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.QGrid.QGrid" [URL="../api/abjadext/nauert/QGrid.html#abjadext.nauert.QGrid.QGrid", color=black, fontcolor=white, label=QGrid, target=_top]; } 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.QGrid.QGrid"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjadext.nauert.QGrid.QGrid(root_node=None, next_downbeat=None)

Q-grid.

Rhythm-tree-based model for how millisecond attack points collapse onto the offsets generated by a nested rhythmic structure.

>>> q_grid = abjadext.nauert.QGrid()
>>> abjad.f(q_grid)
abjadext.nauert.QGrid(
    root_node=abjadext.nauert.QGridLeaf(
        preprolated_duration=abjad.Duration(1, 1),
        is_divisible=True,
        ),
    next_downbeat=abjadext.nauert.QGridLeaf(
        preprolated_duration=abjad.Duration(1, 1),
        is_divisible=True,
        ),
    )

QGrids model not only the internal nodes of the nesting structure, but also the downbeat to the “next” QGrid, allowing events which occur very late within one structure to collapse virtually onto the beginning of the next structure.

QEventProxies can be “loaded in” to the node contained by the QGrid closest to their virtual offset:

>>> q_event_a = abjadext.nauert.PitchedQEvent(250, [0])
>>> q_event_b = abjadext.nauert.PitchedQEvent(750, [1])
>>> proxy_a = abjadext.nauert.QEventProxy(q_event_a, 0.25)
>>> proxy_b = abjadext.nauert.QEventProxy(q_event_b, 0.75)
>>> q_grid.fit_q_events([proxy_a, proxy_b])
>>> for q_event_proxy in q_grid.root_node.q_event_proxies:
...     abjad.f(q_event_proxy)
...
abjadext.nauert.QEventProxy(
    abjadext.nauert.PitchedQEvent(
        offset=abjad.Offset(250, 1),
        pitches=(
            abjad.NamedPitch("c'"),
            ),
        ),
    abjad.Offset(1, 4)
    )
>>> for q_event_proxy in q_grid.next_downbeat.q_event_proxies:
...     abjad.f(q_event_proxy)
...
abjadext.nauert.QEventProxy(
    abjadext.nauert.PitchedQEvent(
        offset=abjad.Offset(750, 1),
        pitches=(
            abjad.NamedPitch("cs'"),
            ),
        ),
    abjad.Offset(3, 4)
    )

Used internally by the Quantizer.


Attributes Summary

__call__ Calls q-grid.
__copy__ Copies q-grid.
__eq__ True if argument is a q-grid with root node and next downbeat equal to those of this q-grid.
__format__ Formats q-event.
__hash__ Hashes q-grid.
distance The computed total distance of the offset of each QEventProxy contained by the QGrid to the offset of the QGridLeaf to which the QEventProxy is attached.
fit_q_events Fit each QEventProxy in q_event_proxies onto the contained QGridLeaf whose offset is nearest.
leaves All of the leaf nodes in the QGrid, including the next downbeat’s node.
next_downbeat The node representing the “next” downbeat after the contents of the QGrid’s tree.
offsets The offsets between 0 and 1 of all of the leaf nodes in the QGrid.
pretty_rtm_format The pretty RTM-format of the root node of the QGrid.
root_node The root node of the QGrid.
rtm_format The RTM format of the root node of the QGrid.
sort_q_events_by_index Sort QEventProxies attached to each QGridLeaf in a QGrid by their index.
subdivide_leaf Replace the QGridLeaf leaf contained in a QGrid by a QGridContainer containing QGridLeaves with durations equal to the ratio described in subdivisions
subdivide_leaves Given a sequence of leaf-index:subdivision-ratio pairs pairs, subdivide the QGridLeaves described by the indices into QGridContainers containing QGridLeaves with durations equal to their respective subdivision-ratios.

Special methods

__call__(beatspan)

Calls q-grid.

__copy__(*arguments)

Copies q-grid.

Returns new q-grid.

__eq__(argument)

True if argument is a q-grid with root node and next downbeat equal to those of this q-grid. Otherwise false.

Returns true or false.

__format__(format_specification='')

Formats q-event.

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

Returns string.

__hash__()

Hashes q-grid.

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

Returns integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Methods

fit_q_events(q_event_proxies)

Fit each QEventProxy in q_event_proxies onto the contained QGridLeaf whose offset is nearest.

Returns None

sort_q_events_by_index()

Sort QEventProxies attached to each QGridLeaf in a QGrid by their index.

Returns None.

subdivide_leaf(leaf, subdivisions)

Replace the QGridLeaf leaf contained in a QGrid by a QGridContainer containing QGridLeaves with durations equal to the ratio described in subdivisions

Returns the QEventProxies attached to leaf.

subdivide_leaves(pairs)

Given a sequence of leaf-index:subdivision-ratio pairs pairs, subdivide the QGridLeaves described by the indices into QGridContainers containing QGridLeaves with durations equal to their respective subdivision-ratios.

Returns the QEventProxies attached to thus subdivided QGridLeaf.


Read-only properties

distance

The computed total distance of the offset of each QEventProxy contained by the QGrid to the offset of the QGridLeaf to which the QEventProxy is attached.

Return Duration instance.

leaves

All of the leaf nodes in the QGrid, including the next downbeat’s node.

Returns tuple of QGridLeaf instances.

next_downbeat

The node representing the “next” downbeat after the contents of the QGrid’s tree.

Return QGridLeaf instance.

offsets

The offsets between 0 and 1 of all of the leaf nodes in the QGrid.

Returns tuple of Offset instances.

pretty_rtm_format

The pretty RTM-format of the root node of the QGrid.

Returns string.

root_node

The root node of the QGrid.

Return QGridLeaf or QGridContainer.

rtm_format

The RTM format of the root node of the QGrid.

Returns string.