quantizationtools.QGrid

Inheritance diagram of abjad.tools.quantizationtools.QGrid.QGrid.QGrid

class abjad.tools.quantizationtools.QGrid.QGrid.QGrid(definition, next)[source]

Abjad model of a QGrid, a nesting division structure which assists certain quantization algorithms.

QGrids are defined by a list, which must be prime in length, whose members are either Numbers or tuples of Numbers (useful for representing timepoint or pitch information), a QEvent or tuple of QEvent objects, or None (representing silence), or other lists which must recursively obey the same rules.

QGrids also have a next attribute, representing the downbeat of not “this” QGrid, but the next QGrid in a list of grids. This is useful as timepoints must often be quantized not to any internal division of a the “current” beat, but to the next beat.

abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, 0, [0, 0]], 0)

The values in the grid can be access via subscript, as though the grid were a flat list.

abjad> q[0] = 1
abjad> q[2] = 3
abjad> q[4] = 5
abjad> q
QGrid([1, 0, [3, 0]], 5)

QGrids are quasi-immutable.

Read-only Properties

QGrid.definition[source]

The nested list which defines the QGrid’s structure.

abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, 0, [0, 0]], 0)
abjad> q.definition
[0, 0, [0, 0]]

Read-only.

QGrid.next[source]

The contents of the final offset in the QGrid.

abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, 0, [0, 0]], 0)
abjad> q[-1] = 9
abjad> q
QGrid([0, 0, [0, 0]], 9)
abjad> q.next
9

Read-only.

QGrid.offsets[source]

An ordered tuple of those Offset objects generated by the division structure of a QGrid.

abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, [0, 0], 0], 0)
abjad> q.offsets
(Offset(0, 1), Offset(1, 3), Offset(1, 2), Offset(2, 3), Offset(1, 1))

Read-only.

Methods

QGrid.find_divisible_indices(points)[source]

Given a list of numbers 0 <= n <= 1, return a list of indices in self which countain those points, as though they were segments.

abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, [0, 0]], 0)
abjad> q.offsets
(Offset(0, 1), Offset(1, 2), Offset(3, 4), Offset(1, 1))
abjad> points = [0.1, 0.9]
abjad> q.find_divisible_indices(points)
[0, 2]

Returns a list.

QGrid.find_parentage_of_index(index)[source]

Return a tuple of the lengths of each container containing index, from the topmost to the bottommost.

abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, [0, [0, 0], 0], 0, 0, 0], 0)
abjad> q.find_parentage_of_index(0)
(5,)
abjad> q.find_parentage_of_index(1)
(5, 3)
abjad> q.find_parentage_of_index(2)
(5, 3, 2)
abjad> q.find_parentage_of_index(7)
(5,)

Returns a tuple.

QGrid.format_for_beatspan(beatspan=Fraction(1, 4))[source]

Return an Abjad container, whose structure mirrors the division structure of the QGrid. The values of the items in the QGrid have no effect on the output.

abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, [0, 0], 0], 0)
abjad> q.format_for_beatspan()
Tuplet(2/3, [c'8, c'16, c'16, c'8])

Returns a Tuplet or Container, depending on structure.

QGrid.subdivide_indices(pairs)[source]

Given a list of 2-tuples, where for each tuple t, t[0] is a valid index into self, and t[1] is a prime integer greater than 1, return a new QGrid with those indices subdivided.

abjad> from abjad.tools.quantizationtools import QGrid
abjad> q = QGrid([0, 0], 0)
abjad> q.subdivide_indices([(0, 2), (1, 3)])
QGrid([[0, 0], [0, 0, 0]], 0)

Returns a new QGrid.

Special Methods

QGrid.__delattr__()

x.__delattr__(‘name’) <==> del x.name

Note

Inherited from __builtin__.object

QGrid.__eq__(other)[source]
QGrid.__ge__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

QGrid.__getitem__(item)[source]
QGrid.__gt__(arg)

Abjad objects by default do not implement this method.

Raise exception

Note

Inherited from abctools.AbjadObject

QGrid.__hash__() <==> hash(x)

Note

Inherited from __builtin__.object

QGrid.__iter__()[source]
QGrid.__le__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

QGrid.__len__()[source]
QGrid.__lt__(arg)

Abjad objects by default do not implement this method.

Raise exception.

Note

Inherited from abctools.AbjadObject

QGrid.__ne__(arg)

True when id(self) does not equal id(arg).

Return boolean.

Note

Inherited from abctools.AbjadObject

QGrid.__repr__()[source]
QGrid.__setattr__()

x.__setattr__(‘name’, value) <==> x.name = value

Note

Inherited from __builtin__.object

QGrid.__setitem__(item, value)[source]
QGrid.__str__() <==> str(x)

Note

Inherited from __builtin__.object

Table Of Contents

This Page