def __getitem__(self, argument): r'''Gets item in scale. Returns pitch-class segment. ''' segment = PitchClassSegment(self) return segment.__getitem__(argument)
def __getslice__(self, start, stop): r'''Gets items from `start` to `stop` in twelve-tone row. Returns pitch-class segment. ''' from abjad.tools import pitchtools items = self._collection[start:stop] return PitchClassSegment( items=items, item_class=pitchtools.NumberedPitchClass, )
def __rmul__(self, expr): r'''Multiplies `expr` by twelve-tone row. Returns pitch-class segment. ''' return PitchClassSegment(self) * expr
def __rmul__(self, argument): r'''Multiplies `argument` by row. .. container:: example Multiplies integer by row: >>> row = abjad.TwelveToneRow() >>> abjad.show(row) # doctest: +SKIP >>> segment = row * 2 >>> abjad.show(segment) # doctest: +SKIP .. docs:: >>> lilypond_file = segment.__illustrate__() >>> abjad.f(lilypond_file[abjad.Voice]) \new Voice { c'8 cs'8 d'8 ef'8 e'8 f'8 fs'8 g'8 af'8 a'8 bf'8 b'8 c'8 cs'8 d'8 ef'8 e'8 f'8 fs'8 g'8 af'8 a'8 bf'8 b'8 \bar "|." %! SCORE1 \override Score.BarLine.transparent = ##f } .. container:: example Multiplies integer by row: >>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> abjad.show(row) # doctest: +SKIP >>> segment = row * 2 >>> abjad.show(segment) # doctest: +SKIP .. docs:: >>> lilypond_file = segment.__illustrate__() >>> abjad.f(lilypond_file[abjad.Voice]) \new Voice { cs'8 b'8 a'8 ef'8 fs'8 g'8 f'8 e'8 bf'8 d'8 af'8 c'8 cs'8 b'8 a'8 ef'8 fs'8 g'8 f'8 e'8 bf'8 d'8 af'8 c'8 \bar "|." %! SCORE1 \override Score.BarLine.transparent = ##f } .. container:: example Returns pitch-class segment: >>> segment PitchClassSegment([1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0, 1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0]) ''' return PitchClassSegment(self) * argument
def __getitem__(self, argument): r'''Gets item or slice identified by `argument`. .. container:: example Example row: >>> numbers = [1, 11, 9, 3, 6, 7, 5, 4, 10, 2, 8, 0] >>> row = abjad.TwelveToneRow(numbers) >>> abjad.show(row) # doctest: +SKIP .. container:: example Gets first hexachord: >>> abjad.show(row[:6]) # doctest: +SKIP PitchClassSegment([0, 1, 11, 9, 3, 6]) .. docs:: >>> lilypond_file = row[:6].__illustrate__() >>> abjad.f(lilypond_file[abjad.Voice]) \new Voice { cs'8 b'8 a'8 ef'8 fs'8 g'8 \bar "|." %! SCORE1 \override Score.BarLine.transparent = ##f } .. container:: example Gets second hexachord: >>> abjad.show(row[-6:]) # doctest: +SKIP .. docs:: >>> lilypond_file = row[-6:].__illustrate__() >>> abjad.f(lilypond_file[abjad.Voice]) \new Voice { f'8 e'8 bf'8 d'8 af'8 c'8 \bar "|." %! SCORE1 \override Score.BarLine.transparent = ##f } .. container:: example Returns pitch-class segment: >>> row[-6:] PitchClassSegment([5, 4, 10, 2, 8, 0]) ''' from abjad.tools import pitchtools item = self._collection.__getitem__(argument) try: return PitchClassSegment( items=item, item_class=pitchtools.NumberedPitchClass, ) except TypeError: return item