PitchArrayRow

class pitchtools.PitchArrayRow(cells=None)

Pitch array row.

Example 1. A pitch array row:

>>> array = pitchtools.PitchArray([[1, 2, 1], [2, 1, 1]])
>>> array[0].cells[0].append_pitch(0)
>>> array[0].cells[1].append_pitch(2)
>>> array[1].cells[2].append_pitch(4)
>>> print(array)
[c'] [d'    ] [  ]
[       ] [ ] [e']
>>> print(format(array[0]))
pitchtools.PitchArrayRow(
    cells=(
        pitchtools.PitchArrayCell(
            pitches=[
                pitchtools.NamedPitch("c'"),
                ],
            width=1,
            ),
        pitchtools.PitchArrayCell(
            pitches=[
                pitchtools.NamedPitch("d'"),
                ],
            width=2,
            ),
        pitchtools.PitchArrayCell(
            width=1,
            ),
        ),
    )
>>> array[0].cell_widths
(1, 2, 1)
>>> array[0].dimensions
(1, 4)
>>> array[0].pitches
(NamedPitch("c'"), NamedPitch("d'"))

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_pitchtools { graph [label=pitchtools]; "abjad.tools.pitchtools.PitchArrayRow.PitchArrayRow" [color=black, fontcolor=white, group=2, label=<<B>PitchArrayRow</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.pitchtools.PitchArrayRow.PitchArrayRow"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

append(cell) Appends cell to pitch array row.
apply_pitches(pitch_tokens) Applies pitch_tokens to pitch cells in pitch array row.
cell_tokens Gets cell items of pitch array row.
cell_widths Gets cell widths of pitch array row.
cells Gets cells of pitch array row.
copy_subrow([start, stop]) Copies subrow of pitch array row from start to stop.
depth Gets depth of pitch array row.
dimensions Gets dimensions of pitch array row.
empty_pitches() Empties pitches in pitch array row.
extend(cells) Extends pitch array row with cells.
has_spanning_cell_over_index(i) Is true when pitch array row has one or more cells spanning over index i.
index(cell) Gets index of pitch array cell in pitch array row.
is_defective Is true when width of pitch array row does not equal width of parent pitch array.
is_in_range Is true when all pitches in pitch array row are in pitch range of pitch array row.
merge(cells) Merges cells.
pad_to_width(width) Pads pitch array row to width.
parent_array Gets parent pitch array housing pitch array row.
pitch_range Gets and sets pitch range of pitch array row.
pitches Gets pitches in pitch array row.
pop(cell_index) Pops cell cell_index from pitch array row.
remove(cell) Removes cell form pitch array row.
row_index Gets row index of pitch array row in parent pitch array.
to_measure([cell_duration_denominator]) Changes pitch array row to measures.
weight Gets weight of pitch array row.
width Gets width of pitch array row.
withdraw() Withdraws pitch array row from parent pitch array.
__add__(arg) Concatenates arg to pitch array row.
__copy__() Copies pitch array row.
__eq__(arg) Is true when arg is a pitch array row with contents equal to that of this pitch array row.
__format__([format_specification]) Formats Abjad object.
__getitem__(arg) Gets pitch array cell arg from pitch array row.
__hash__() Hashes pitch array row.
__iadd__(arg) Adds arg to pitch array row in place.
__iter__() Iterates pitch array row.
__len__() Gets length of pitch array row.
__ne__(arg) Is true when pitch array row does not equal arg.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of pitch array row.

Read-only properties

PitchArrayRow.cell_tokens

Gets cell items of pitch array row.

Returns tuple.

PitchArrayRow.cell_widths

Gets cell widths of pitch array row.

Returns tuple.

PitchArrayRow.cells

Gets cells of pitch array row.

Returns tuple.

PitchArrayRow.depth

Gets depth of pitch array row.

Defined equal to 1.

Returns 1.

PitchArrayRow.dimensions

Gets dimensions of pitch array row.

Returns pair.

PitchArrayRow.is_defective

Is true when width of pitch array row does not equal width of parent pitch array. Otherwise false.

Returns true or false.

PitchArrayRow.is_in_range

Is true when all pitches in pitch array row are in pitch range of pitch array row. Otherwise false.

Returns true or false.

PitchArrayRow.parent_array

Gets parent pitch array housing pitch array row.

Returns pitch array or none.

PitchArrayRow.pitches

Gets pitches in pitch array row.

Returns tuple.

PitchArrayRow.row_index

Gets row index of pitch array row in parent pitch array.

Returns nonnegative integer.

PitchArrayRow.weight

Gets weight of pitch array row.

Defined equal to sum of weights of pitch array cells in pitch array row.

Returns nonnegative integer.

PitchArrayRow.width

Gets width of pitch array row.

Defined equal to sum of widths of pitch array cells in pitch array row.

Returns nonnegative integer.

Read/write properties

PitchArrayRow.pitch_range

Gets and sets pitch range of pitch array row.

Returns pitch range.

Methods

PitchArrayRow.append(cell)

Appends cell to pitch array row.

Returns none.

PitchArrayRow.apply_pitches(pitch_tokens)

Applies pitch_tokens to pitch cells in pitch array row.

Returns none.

PitchArrayRow.copy_subrow(start=None, stop=None)

Copies subrow of pitch array row from start to stop.

Returns new pitch array row.

PitchArrayRow.empty_pitches()

Empties pitches in pitch array row.

Returns none.

PitchArrayRow.extend(cells)

Extends pitch array row with cells.

Returns none.

PitchArrayRow.has_spanning_cell_over_index(i)

Is true when pitch array row has one or more cells spanning over index i. Otherwise false.

Returns true or false.

PitchArrayRow.index(cell)

Gets index of pitch array cell in pitch array row.

Retunrs nonnegative integer.

PitchArrayRow.merge(cells)

Merges cells.

Returns pitch array cell.

PitchArrayRow.pad_to_width(width)

Pads pitch array row to width.

Returns none.

PitchArrayRow.pop(cell_index)

Pops cell cell_index from pitch array row.

Returns pitch array cell.

PitchArrayRow.remove(cell)

Removes cell form pitch array row.

Returns none.

PitchArrayRow.to_measure(cell_duration_denominator=8)

Changes pitch array row to measures.

Sets time signature numerators equal to pitch array row widths and time signature denominators equal to cell_duration_denominator.

Example 1. Changes row to measure:

>>> array = pitchtools.PitchArray([
...     [1, (2, 1), ([-2, -1.5], 2)],
...     [(7, 2), (6, 1), 1]])
>>> print(array)
[  ] [d'] [bf bqf    ]
[g'     ] [fs'   ] [ ]
>>> measure = array.rows[0].to_measure()
>>> show(measure) 

Returns measure.

PitchArrayRow.withdraw()

Withdraws pitch array row from parent pitch array.

Returns pitch array row.

Special methods

PitchArrayRow.__add__(arg)

Concatenates arg to pitch array row.

Returns new pitch array row.

PitchArrayRow.__copy__()

Copies pitch array row.

Returns new pitch array row.

PitchArrayRow.__eq__(arg)

Is true when arg is a pitch array row with contents equal to that of this pitch array row. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

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

Returns string.

PitchArrayRow.__getitem__(arg)

Gets pitch array cell arg from pitch array row.

Returns pitch array cell.

PitchArrayRow.__hash__()

Hashes pitch array row.

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

Returns integer.

PitchArrayRow.__iadd__(arg)

Adds arg to pitch array row in place.

Returns pitch array row.

PitchArrayRow.__iter__()

Iterates pitch array row.

Returns generator.

PitchArrayRow.__len__()

Gets length of pitch array row.

Length defined equal to the width of pitch array row.

Returns nonnegative integer.

PitchArrayRow.__ne__(arg)

Is true when pitch array row does not equal arg. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

PitchArrayRow.__str__()

Gets string representation of pitch array row.

Returns string.