示例#1
0
    def append(self, cell_token):
        r'''Appends `cell_token` to pitch array row.

        Returns none.
        '''
        from abjad.tools import pitchtools
        cell = pitchtools.PitchArrayCell(cell_token)
        cell._parent_row = self
        self._cells.append(cell)
示例#2
0
 def __init__(self, rows=None):
     from abjad.tools import pitchtools
     self._rows = []
     self._columns = []
     if not rows:
         return
     for row in rows:
         row_ = pitchtools.PitchArrayRow([])
         for cell in row:
             if isinstance(cell, int):
                 cell = pitchtools.PitchArrayCell(width=cell)
             elif isinstance(cell, tuple):
                 assert len(cell) == 2, repr(cell)
                 pitches, width = cell
                 if isinstance(pitches, int):
                     pitches = [pitches]
                 cell = pitchtools.PitchArrayCell(
                     pitches=pitches,
                     width=width,
                     )
             row_.append(cell)
         self.append_row(row_)
示例#3
0
    def pad_to_width(self, width):
        r'''Pads pitch array row to `width`.

        Returns none.
        '''
        from abjad.tools import pitchtools
        self_width = self.width
        if width < self_width:
            message = 'pad width must not be less than row width.'
            raise ValueError(message)
        missing_width = width - self_width
        for i in range(missing_width):
            cell = pitchtools.PitchArrayCell()
            self.append(cell)
示例#4
0
    def from_counts(class_, row_count, column_count):
        r'''Makes pitch array from row and column counts.

        Returns pitch array.
        '''
        from abjad.tools import pitchtools
        array = class_()
        for i in range(row_count):
            row = pitchtools.PitchArrayRow([])
            for j in range(column_count):
                cell = pitchtools.PitchArrayCell()
                row.append(cell)
            array.append_row(row)
        return array