def label_leaves_in_expr_with_numbered_inversion_equivalent_interval_classes(expr, markup_direction=Up):
    r"""Label leaves in `expr` with numbered inversion-equivalent interval classes:

    ::

        >>> notes = notetools.make_notes([0, 25, 11, -4, -14, -13, 9, 10, 6, 5], [Duration(1, 8)])
        >>> staff = Staff(notes)
        >>> labeltools.label_leaves_in_expr_with_numbered_inversion_equivalent_interval_classes(
        ...     staff)

    ..  doctest::

        >>> f(staff)
        \new Staff {
            c'8 ^ \markup { 1 }
            cs'''8 ^ \markup { 2 }
            b'8 ^ \markup { 3 }
            af8 ^ \markup { 2 }
            bf,8 ^ \markup { 1 }
            b,8 ^ \markup { 2 }
            a'8 ^ \markup { 1 }
            bf'8 ^ \markup { 4 }
            fs'8 ^ \markup { 1 }
            f'8
        }

    ::

        >>> show(staff) # doctest: +SKIP

    Returns none.
    """

    for note in iterationtools.iterate_notes_in_expr(expr):
        logical_voice_iterator = \
            iterationtools.iterate_logical_voice_from_component(
            note, leaftools.Leaf)
        try:
            logical_voice_iterator.next()
            next_leaf = logical_voice_iterator.next()
            if isinstance(next_leaf, notetools.Note):
                mdi = note.written_pitch - next_leaf.written_pitch
                iecic = \
                    pitchtools.NumberedInversionEquivalentIntervalClass(mdi)
                markup = markuptools.Markup(iecic, markup_direction)
                attach(markup, note)
        except StopIteration:
            pass
def label_leaves_in_expr_with_named_interval_classes(expr, markup_direction=Up):
    r"""Label leaves in `expr` with named interval classes:

    ::

        >>> notes = notetools.make_notes([0, 25, 11, -4, -14, -13, 9, 10, 6, 5], [Duration(1, 8)])
        >>> staff = Staff(notes)
        >>> labeltools.label_leaves_in_expr_with_named_interval_classes(staff)

    ..  doctest::

        >>> f(staff)
        \new Staff {
            c'8 ^ \markup { +aug8 }
            cs'''8 ^ \markup { -M2 }
            b'8 ^ \markup { -aug2 }
            af8 ^ \markup { -m7 }
            bf,8 ^ \markup { aug1 }
            b,8 ^ \markup { +m7 }
            a'8 ^ \markup { +m2 }
            bf'8 ^ \markup { -dim4 }
            fs'8 ^ \markup { aug1 }
            f'8
        }

    ::

        >>> show(staff) # doctest: +SKIP

    Returns none.
    """

    for note in iterationtools.iterate_notes_in_expr(expr):
        logical_voice_iterator = \
            iterationtools.iterate_logical_voice_from_component(
            note, leaftools.Leaf)
        try:
            logical_voice_iterator.next()
            next_leaf = logical_voice_iterator.next()
            if isinstance(next_leaf, notetools.Note):
                mdi = pitchtools.NamedInterval.from_pitch_carriers(
                    note, next_leaf)
                mdic = pitchtools.NamedIntervalClass(mdi)
                markup = markuptools.Markup(mdic, markup_direction)
                attach(markup, note)
        except StopIteration:
            pass
Пример #3
0
 def __call__(self, expr):
     for i, note in enumerate(iterationtools.iterate_notes_in_expr(expr)):
         cluster_width = self.cluster_widths[i]
         start = note.written_pitch.diatonic_pitch_number
         diatonic_numbers = range(start, start + cluster_width)
         chromatic_numbers = [
             (12 * (x // 7)) +
             pitchtools.PitchClass._diatonic_pitch_class_number_to_pitch_class_number[
                 x % 7]
             for x in diatonic_numbers 
             ] 
         chord_pitches = [pitchtools.NamedPitch(x) 
             for x in chromatic_numbers]
         chord = scoretools.Chord(note)
         chord[:] = []
         chord.extend(chord_pitches)
         mutationtools.mutate(note).replace(chord)
def label_notes_in_expr_with_note_indices(expr, markup_direction=Down):
    r'''Label notes in `expr` with note indices:

    ::

        >>> staff = Staff("c'8 d'8 r8 r8 g'8 a'8 r8 c''8")

    ::

        >>> labeltools.label_notes_in_expr_with_note_indices(staff)

    ..  doctest::

        >>> f(staff)
        \new Staff {
            c'8 _ \markup { \small 0 }
            d'8 _ \markup { \small 1 }
            r8
            r8
            g'8 _ \markup { \small 2 }
            a'8 _ \markup { \small 3 }
            r8
            c''8 _ \markup { \small 4 }
        }

    ::

        >>> show(staff) # doctest: +SKIP

    Returns none.
    '''

    for i, note in enumerate(iterationtools.iterate_notes_in_expr(expr)):
        label = r'\small %s' % i
        markup = markuptools.Markup(label, markup_direction)
        attach(markup, note)