pitchtools.insert_transposed_pc_subruns

abjad.tools.pitchtools.insert_transposed_pc_subruns(notes, subrun_indicators)

Insert transposed subruns according to subrun_indicators.

  • pitches must be a list of zero or more Abjad Note instances.
  • subrun_indicators must be 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). This is easiest to see with an example.

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_transposed_pc_subruns(notes, subrun_indicators)

abjad> for x in notes:
   try:
      t.append(x.pitch.number)
   except AttributeError:
      t.append([y.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]

Note

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 = listtools.flatten(notes).

abjad> notes = listtools.flatten(notes)
abjad> notes
[0, 5, 7, 2, 4, 0, 6, 11, 7, 9, 5, 10, 6, 8, 11, 7, 4]

Note

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. Specifically, this function is designed to be used during precomposition when other, similar abstract pitch transforms may be common.

Previous topic

pitchtools.get_signed_interval_series

Next topic

pitchtools.is_carrier

This Page