pitchtools.insert_and_transpose_nested_subruns_in_chromatic_pitch_class_number_list

abjad.tools.pitchtools.insert_and_transpose_nested_subruns_in_chromatic_pitch_class_number_list.insert_and_transpose_nested_subruns_in_chromatic_pitch_class_number_list(notes, subrun_indicators)[source]

New in version 1.1.

Insert and transpose nested subruns in chromatic_pitch_class_number_list according to subrun_indicators:

abjad> notes = [Note(p, (1, 4)) for p in [0, 2, 7, 9, 5, 11, 4]]
abjad> subrun_indicators = [(0, [2, 4]), (4, [3, 1])]
abjad> pitchtools.insert_and_transpose_nested_subruns_in_chromatic_pitch_class_number_list(notes, subrun_indicators)

abjad> t = []
abjad> for x in notes:
...   try:
...        t.append(x.written_pitch.chromatic_pitch_number)
...   except AttributeError:
...        t.append([y.written_pitch.chromatic_pitch_number for y in x])

abjad> t
[0, [5, 7], 2, [4, 0, 6, 11], 7, 9, 5, [10, 6, 8], 11, [7], 4]

Set subrun_indicators to a list of zero or more (index, length_list) pairs.

For each (index, length_list) pair in subrun_indicators the function will read index mod len(notes) and insert a subrun of length length_list[0] immediately after notes[index], a subrun of length length_list[1] immediately after notes[index+1], and, in general, a subrun of length_list[i] immediately after notes[index+i], for i < length(length_list).

New subruns are wrapped with lists. These wrapper lists are designed to allow inspection of the structural changes to notes immediately after the function returns. For this reason most calls to this function will be followed by notes = sequencetools.flatten_sequence(notes):

abjad> from abjad.tools import sequencetools
abjad> notes = sequencetools.flatten_sequence(notes)
abjad> notes
[Note("c'4"), Note("f'4"), Note("g'4"), Note("d'4"), Note("e'4"), Note("c'4"), Note("fs'4"), Note("b'4"), Note("g'4"), Note("a'4"), Note("f'4"), Note("bf'4"), Note("fs'4"), Note("af'4"), Note("b'4"), Note("g'4"), Note("e'4")]

This function is designed to work on a built-in Python list of notes. This function is not designed to work on Abjad voices, staves or other containers because the function currently implements no spanner-handling. That is, this function is designed to be used during precomposition when other, similar abstract pitch transforms may be common.

Return list of integers and / or floats.

Changed in version 2.0: renamed pitchtools.insert_transposed_pc_subruns() to pitchtools.insert_and_transpose_nested_subruns_in_chromatic_pitch_class_number_list().

This Page