(quantized_sequence, max_steps=None,
                   all_transpositions=False)
Extracts a single chord progression from a quantized NoteSequence.

  This function will extract the underlying chord progression (encoded as text
  annotations) from `quantized_sequence`.

  Args:
    quantized_sequence: A quantized NoteSequence.
    max_steps: An integer, maximum length of a chord progression. Chord
        progressions will be trimmed to this length. If None, chord
        progressions will not be trimmed.
    all_transpositions: If True, also transpose the chord progression into all
        12 keys.

  Returns:
    chord_progressions: If `all_transpositions` is False, a python list
        containing a single ChordProgression instance. If `all_transpositions`
        is True, a python list containing 12 ChordProgression instances, one
        for each transposition.
    stats: A dictionary mapping string names to `statistics.Statistic` objects.
Extracts a single chord progression from a quantized NoteSequence.
Extracts a single chord progression from a quantized NoteSequence .
def extract_chords(quantized_sequence, max_steps=None,
                   all_transpositions=False):
  """Extracts a single chord progression from a quantized NoteSequence.

  This function will extract the underlying chord progression (encoded as text
  annotations) from `quantized_sequence`.

  Args:
    quantized_sequence: A quantized NoteSequence.
    max_steps: An integer, maximum length of a chord progression. Chord
        progressions will be trimmed to this length. If None, chord
        progressions will not be trimmed.
    all_transpositions: If True, also transpose the chord progression into all
        12 keys.

  Returns:
    chord_progressions: If `all_transpositions` is False, a python list
        containing a single ChordProgression instance. If `all_transpositions`
        is True, a python list containing 12 ChordProgression instances, one
        for each transposition.
    stats: A dictionary mapping string names to `statistics.Statistic` objects.
  """
  sequences_lib.assert_is_relative_quantized_sequence(quantized_sequence)

  stats = dict([('chords_truncated', statistics.Counter('chords_truncated'))])
  chords = ChordProgression()
  chords.from_quantized_sequence(
      quantized_sequence, 0, quantized_sequence.total_quantized_steps)
  if max_steps is not None:
    if len(chords) > max_steps:
      chords.set_length(max_steps)
      stats['chords_truncated'].increment()
  if all_transpositions:
    chord_progressions = []
    for amount in range(-6, 6):
      transposed_chords = copy.deepcopy(chords)
      transposed_chords.transpose(amount)
      chord_progressions.append(transposed_chords)
    return chord_progressions, stats.values()
  else:
    return [chords], stats.values()
def extract_chords ( quantized_sequence , max_steps = None , all_transpositions = False ) : sequences_lib . assert_is_relative_quantized_sequence ( quantized_sequence ) stats = dict ( [ ( 'chords_truncated' , statistics . Counter ( 'chords_truncated' ) ) ] ) chords = ChordProgression ( ) chords . from_quantized_sequence ( quantized_sequence , 0 , quantized_sequence . total_quantized_steps ) if max_steps is not None : if len ( chords ) > max_steps : chords . set_length ( max_steps ) stats [ 'chords_truncated' ] . increment ( ) if all_transpositions : chord_progressions = [ ] for amount in range ( - 6 , 6 ) : transposed_chords = copy . deepcopy ( chords ) transposed_chords . transpose ( amount ) chord_progressions . append ( transposed_chords ) return chord_progressions , stats . values ( ) else : return [ chords ] , stats . values ( )