Example #1
0
    def named_interval_class_segment(self):
        r'''Named interval class segment of scale.

        Returns interval-class segment.
        '''
        dics = []
        for left, right in \
            sequencetools.iterate_sequence_nwise(self, wrapped=True):
            dic = left - right
            dics.append(dic)
        dicg = pitchtools.IntervalClassSegment(
            items=dics,
            item_class=pitchtools.NamedInversionEquivalentIntervalClass,
        )
        return dicg
Example #2
0
 def _analyze_chord(expr):
     from abjad.tools import tonalanalysistools
     pitches = pitchtools.PitchSegment.from_selection(expr)
     npcset = pitchtools.PitchClassSet(
         pitches,
         item_class=pitchtools.NamedPitchClass,
     )
     ordered_npcs = []
     letters = ('c', 'e', 'g', 'b', 'd', 'f', 'a')
     for letter in letters:
         for npc in npcset:
             if npc.diatonic_pitch_class_name == letter:
                 ordered_npcs.append(npc)
     ordered_npcs = pitchtools.PitchClassSegment(
         ordered_npcs, item_class=pitchtools.NamedPitchClass)
     for x in range(len(ordered_npcs)):
         ordered_npcs = ordered_npcs.rotate(1)
         segment = \
             pitchtools.IntervalClassSegment(
                 items=mathtools.difference_series(ordered_npcs),
                 item_class=pitchtools.NamedInversionEquivalentIntervalClass,
                 )
         if segment.is_tertian:
             break
     else:
         return None
     root = ordered_npcs[0]
     class_ = tonalanalysistools.RootlessChordClass
     rootless_chord_class = class_.from_interval_class_segment(segment)
     bass = min(pitches).named_pitch_class
     inversion = ordered_npcs.index(bass)
     return tonalanalysistools.RootedChordClass(
         root,
         rootless_chord_class.quality_string,
         rootless_chord_class.extent,
         inversion,
     )