예제 #1
0
파일: Scale.py 프로젝트: tchiwinpiti/abjad
    def __getitem__(self, argument):
        r'''Gets item in scale.

        Returns pitch-class segment.
        '''
        segment = PitchClassSegment(self)
        return segment.__getitem__(argument)
예제 #2
0
    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,
        )
예제 #3
0
    def __rmul__(self, expr):
        r'''Multiplies `expr` by twelve-tone row.

        Returns pitch-class segment.
        '''
        return PitchClassSegment(self) * expr
예제 #4
0
    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
예제 #5
0
    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