예제 #1
0
 def _generate_all_subdivision_commands(self, q_grid):
     indices, subdivisions = \
         self._find_divisible_leaf_indices_and_subdivisions(q_grid)
     if not indices:
         return ()
     combinations = [tuple(x)
         for x in sequencetools.yield_outer_product_of_sequences(
         subdivisions)]
     return tuple(tuple(zip(indices, combo)) for combo in combinations)
예제 #2
0
 def _generate_all_subdivision_commands(self, q_grid):
     indices, subdivisions = \
         self._find_divisible_leaf_indices_and_subdivisions(q_grid)
     if not indices:
         return ()
     combinations = [tuple(x)
         for x in sequencetools.yield_outer_product_of_sequences(
         subdivisions)]
     return tuple(tuple(zip(indices, combo)) for combo in combinations)
예제 #3
0
파일: Tuning.py 프로젝트: jdavancens/abjad
    def voice_pitch_classes(
        self,
        pitch_classes,
        allow_open_strings=True,
    ):
        r"""Voices `pitch_classes`.

        ..  container:: example

            **Example 1.**

            ::

                >>> tuning = indicatortools.Tuning(('G3', 'D4', 'A4', 'E5'))
                >>> voicings = tuning.voice_pitch_classes(('a',))
                >>> for voicing in voicings:
                ...     voicing
                ...
                (NamedPitch('a'), None, None, None)
                (NamedPitch("a'"), None, None, None)
                (None, NamedPitch("a'"), None, None)
                (None, NamedPitch("a''"), None, None)
                (None, None, NamedPitch("a'"), None)
                (None, None, NamedPitch("a''"), None)
                (None, None, NamedPitch("a'''"), None)
                (None, None, None, NamedPitch("a''"))
                (None, None, None, NamedPitch("a'''"))

            ::

                >>> voicings = tuning.voice_pitch_classes(
                ...     ('a', 'd'),
                ...     allow_open_strings=False,
                ...     )
                >>> for voicing in voicings:
                ...     voicing
                ...
                (NamedPitch('a'), NamedPitch("d''"), None, None)
                (NamedPitch('a'), NamedPitch("d'''"), None, None)
                (NamedPitch('a'), None, NamedPitch("d''"), None)
                (NamedPitch('a'), None, NamedPitch("d'''"), None)
                (NamedPitch('a'), None, None, NamedPitch("d'''"))
                (NamedPitch('a'), None, None, NamedPitch("d''''"))
                (NamedPitch("d'"), NamedPitch("a'"), None, None)
                (NamedPitch("d'"), NamedPitch("a''"), None, None)
                (NamedPitch("d'"), None, NamedPitch("a''"), None)
                (NamedPitch("d'"), None, NamedPitch("a'''"), None)
                (NamedPitch("d'"), None, None, NamedPitch("a''"))
                (NamedPitch("d'"), None, None, NamedPitch("a'''"))
                (NamedPitch("a'"), NamedPitch("d''"), None, None)
                (NamedPitch("a'"), NamedPitch("d'''"), None, None)
                (NamedPitch("a'"), None, NamedPitch("d''"), None)
                (NamedPitch("a'"), None, NamedPitch("d'''"), None)
                (NamedPitch("a'"), None, None, NamedPitch("d'''"))
                (NamedPitch("a'"), None, None, NamedPitch("d''''"))
                (NamedPitch("d''"), NamedPitch("a'"), None, None)
                (NamedPitch("d''"), NamedPitch("a''"), None, None)
                (NamedPitch("d''"), None, NamedPitch("a''"), None)
                (NamedPitch("d''"), None, NamedPitch("a'''"), None)
                (NamedPitch("d''"), None, None, NamedPitch("a''"))
                (NamedPitch("d''"), None, None, NamedPitch("a'''"))
                (None, NamedPitch("a'"), NamedPitch("d''"), None)
                (None, NamedPitch("a'"), NamedPitch("d'''"), None)
                (None, NamedPitch("a'"), None, NamedPitch("d'''"))
                (None, NamedPitch("a'"), None, NamedPitch("d''''"))
                (None, NamedPitch("d''"), NamedPitch("a''"), None)
                (None, NamedPitch("d''"), NamedPitch("a'''"), None)
                (None, NamedPitch("d''"), None, NamedPitch("a''"))
                (None, NamedPitch("d''"), None, NamedPitch("a'''"))
                (None, NamedPitch("a''"), NamedPitch("d''"), None)
                (None, NamedPitch("a''"), NamedPitch("d'''"), None)
                (None, NamedPitch("a''"), None, NamedPitch("d'''"))
                (None, NamedPitch("a''"), None, NamedPitch("d''''"))
                (None, NamedPitch("d'''"), NamedPitch("a''"), None)
                (None, NamedPitch("d'''"), NamedPitch("a'''"), None)
                (None, NamedPitch("d'''"), None, NamedPitch("a''"))
                (None, NamedPitch("d'''"), None, NamedPitch("a'''"))
                (None, None, NamedPitch("d''"), NamedPitch("a''"))
                (None, None, NamedPitch("d''"), NamedPitch("a'''"))
                (None, None, NamedPitch("a''"), NamedPitch("d'''"))
                (None, None, NamedPitch("a''"), NamedPitch("d''''"))
                (None, None, NamedPitch("d'''"), NamedPitch("a''"))
                (None, None, NamedPitch("d'''"), NamedPitch("a'''"))
                (None, None, NamedPitch("a'''"), NamedPitch("d'''"))
                (None, None, NamedPitch("a'''"), NamedPitch("d''''"))

        Returns tuple of sequences.
        """
        from abjad.tools import pitchtools
        pitch_classes = [pitchtools.NamedPitchClass(x) for x in pitch_classes]
        pitch_classes.extend([None] * (len(self.pitches) - len(pitch_classes)))
        permutations = set([
            tuple(x) for x in sequencetools.yield_all_permutations_of_sequence(
                pitch_classes)
        ])
        pitch_ranges = self.pitch_ranges
        result = []
        for permutation in permutations:
            sequences = []
            for pitch_range, pitch_class in zip(pitch_ranges, permutation):
                if pitch_class is None:
                    sequences.append([None])
                    continue
                pitches = pitch_range.voice_pitch_class(pitch_class)
                if not allow_open_strings:
                    pitches = [
                        pitch for pitch in pitches
                        if pitch != pitch_range.start_pitch
                    ]
                if not pitches:
                    pitches = [None]
                sequences.append(pitches)
            subresult = sequencetools.yield_outer_product_of_sequences(
                sequences)
            subresult = [tuple(x) for x in subresult]
            result.extend(subresult)
        result.sort()
        return tuple(result)
예제 #4
0
파일: Tuning.py 프로젝트: ajyoon/abjad
    def voice_pitch_classes(
        self,
        pitch_classes,
        allow_open_strings=True,
        ):
        r"""Voices `pitch_classes`.

        ..  container:: example

            **Example 1.**

            ::

                >>> tuning = indicatortools.Tuning(('G3', 'D4', 'A4', 'E5'))
                >>> voicings = tuning.voice_pitch_classes(('a',))
                >>> for voicing in voicings:
                ...     voicing
                ...
                (NamedPitch('a'), None, None, None)
                (NamedPitch("a'"), None, None, None)
                (None, NamedPitch("a'"), None, None)
                (None, NamedPitch("a''"), None, None)
                (None, None, NamedPitch("a'"), None)
                (None, None, NamedPitch("a''"), None)
                (None, None, NamedPitch("a'''"), None)
                (None, None, None, NamedPitch("a''"))
                (None, None, None, NamedPitch("a'''"))

            ::

                >>> voicings = tuning.voice_pitch_classes(
                ...     ('a', 'd'),
                ...     allow_open_strings=False,
                ...     )
                >>> for voicing in voicings:
                ...     voicing
                ...
                (NamedPitch('a'), NamedPitch("d''"), None, None)
                (NamedPitch('a'), NamedPitch("d'''"), None, None)
                (NamedPitch('a'), None, NamedPitch("d''"), None)
                (NamedPitch('a'), None, NamedPitch("d'''"), None)
                (NamedPitch('a'), None, None, NamedPitch("d'''"))
                (NamedPitch('a'), None, None, NamedPitch("d''''"))
                (NamedPitch("d'"), NamedPitch("a'"), None, None)
                (NamedPitch("d'"), NamedPitch("a''"), None, None)
                (NamedPitch("d'"), None, NamedPitch("a''"), None)
                (NamedPitch("d'"), None, NamedPitch("a'''"), None)
                (NamedPitch("d'"), None, None, NamedPitch("a''"))
                (NamedPitch("d'"), None, None, NamedPitch("a'''"))
                (NamedPitch("a'"), NamedPitch("d''"), None, None)
                (NamedPitch("a'"), NamedPitch("d'''"), None, None)
                (NamedPitch("a'"), None, NamedPitch("d''"), None)
                (NamedPitch("a'"), None, NamedPitch("d'''"), None)
                (NamedPitch("a'"), None, None, NamedPitch("d'''"))
                (NamedPitch("a'"), None, None, NamedPitch("d''''"))
                (NamedPitch("d''"), NamedPitch("a'"), None, None)
                (NamedPitch("d''"), NamedPitch("a''"), None, None)
                (NamedPitch("d''"), None, NamedPitch("a''"), None)
                (NamedPitch("d''"), None, NamedPitch("a'''"), None)
                (NamedPitch("d''"), None, None, NamedPitch("a''"))
                (NamedPitch("d''"), None, None, NamedPitch("a'''"))
                (None, NamedPitch("a'"), NamedPitch("d''"), None)
                (None, NamedPitch("a'"), NamedPitch("d'''"), None)
                (None, NamedPitch("a'"), None, NamedPitch("d'''"))
                (None, NamedPitch("a'"), None, NamedPitch("d''''"))
                (None, NamedPitch("d''"), NamedPitch("a''"), None)
                (None, NamedPitch("d''"), NamedPitch("a'''"), None)
                (None, NamedPitch("d''"), None, NamedPitch("a''"))
                (None, NamedPitch("d''"), None, NamedPitch("a'''"))
                (None, NamedPitch("a''"), NamedPitch("d''"), None)
                (None, NamedPitch("a''"), NamedPitch("d'''"), None)
                (None, NamedPitch("a''"), None, NamedPitch("d'''"))
                (None, NamedPitch("a''"), None, NamedPitch("d''''"))
                (None, NamedPitch("d'''"), NamedPitch("a''"), None)
                (None, NamedPitch("d'''"), NamedPitch("a'''"), None)
                (None, NamedPitch("d'''"), None, NamedPitch("a''"))
                (None, NamedPitch("d'''"), None, NamedPitch("a'''"))
                (None, None, NamedPitch("d''"), NamedPitch("a''"))
                (None, None, NamedPitch("d''"), NamedPitch("a'''"))
                (None, None, NamedPitch("a''"), NamedPitch("d'''"))
                (None, None, NamedPitch("a''"), NamedPitch("d''''"))
                (None, None, NamedPitch("d'''"), NamedPitch("a''"))
                (None, None, NamedPitch("d'''"), NamedPitch("a'''"))
                (None, None, NamedPitch("a'''"), NamedPitch("d'''"))
                (None, None, NamedPitch("a'''"), NamedPitch("d''''"))

        Returns tuple of sequences.
        """
        from abjad.tools import pitchtools
        pitch_classes = [pitchtools.NamedPitchClass(x) for x in pitch_classes]
        pitch_classes.extend([None] * (len(self.pitches) - len(pitch_classes)))
        permutations = set([
            tuple(x) for x in
            sequencetools.yield_all_permutations_of_sequence(pitch_classes)
            ])
        pitch_ranges = self.pitch_ranges
        result = []
        for permutation in permutations:
            sequences = []
            for pitch_range, pitch_class in zip(pitch_ranges, permutation):
                if pitch_class is None:
                    sequences.append([None])
                    continue
                pitches = pitch_range.voice_pitch_class(pitch_class)
                if not allow_open_strings:
                    pitches = [pitch for pitch in pitches
                        if pitch != pitch_range.start_pitch
                        ]
                if not pitches:
                    pitches = [None]
                sequences.append(pitches)
            subresult = sequencetools.yield_outer_product_of_sequences(
                sequences)
            subresult = [tuple(x) for x in subresult]
            result.extend(subresult)
        result.sort()
        return tuple(result)