Beispiel #1
0
 def __init__(
     self,
     pitches=None,
     ):
     if pitches is not None:
         if not isinstance(pitches, collections.Iterable):
             pitches = [pitches]
         pitches = pitchtools.PitchSet(
             items=pitches,
             item_class=pitchtools.NumberedPitch,
             )
     self._pitches = pitches
Beispiel #2
0
    def has_duplicates(self):
        r'''Is true when segment has duplicates. Otherwise false.

        ..  container:: example

            >>> segment = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7])
            >>> segment.has_duplicates()
            True

        ..  container:: example

            >>> segment = abjad.PitchSegment("c d e f g a b")
            >>> segment.has_duplicates()
            False

        Returns true or false.
        '''
        from abjad.tools import pitchtools
        return len(pitchtools.PitchSet(self)) < len(self)
Beispiel #3
0
    def has_duplicates(self):
        r'''True if pitch segment has duplicate items. Otherwise false.

        ::

            >>> pitch_class_segment = pitchtools.PitchSegment(
            ...     items=[-2, -1.5, 6, 7, -1.5, 7],
            ...     )
            >>> pitch_class_segment.has_duplicates
            True

        ::

            >>> pitch_class_segment = pitchtools.PitchSegment(
            ...     items="c d e f g a b",
            ...     )
            >>> pitch_class_segment.has_duplicates
            False

        Returns boolean.
        '''
        from abjad.tools import pitchtools
        return len(pitchtools.PitchSet(self)) < len(self)
Beispiel #4
0
    def create_named_pitch_set_in_pitch_range(self, pitch_range):
        r'''Creates named pitch-set in `pitch_range`.

        Returns pitch-set.
        '''
        if not isinstance(pitch_range, pitchtools.PitchRange):
            pitch_range = pitchtools.PitchRange(
                float(pitchtools.NamedPitch(pitch_range[0])),
                float(pitchtools.NamedPitch(pitch_range[1])))
        low = pitch_range.start_pitch.octave_number
        high = pitch_range.stop_pitch.octave_number
        pitches = []
        octave = low
        while octave <= high:
            for x in self:
                pitch = pitchtools.NamedPitch(x, octave)
                if pitch_range.start_pitch <= pitch and \
                    pitch <= pitch_range.stop_pitch:
                    pitches.append(pitch)
            octave += 1
        return pitchtools.PitchSet(
            items=pitches,
            item_class=pitchtools.NamedPitch,
        )
Beispiel #5
0
 def _make_dicv(*named_pitch_classes):
     pitch_set = pitchtools.PitchSet(named_pitch_classes)
     return pitchtools.IntervalClassVector(
         items=pitch_set,
         item_class=pitchtools.NamedInversionEquivalentIntervalClass,
     )