# Path: moonlight/music/constants.py
# MAJOR_SCALE = [0, 2, 4, 5, 7, 9, 11]
# NUM_SEMITONES_PER_OCTAVE = 12
# NUM_SEMITONES_IN_PERFECT_FIFTH = 7
# NUM_NOTES_IN_DIATONIC_SCALE = 7
# CIRCLE_OF_FIFTHS = [0, 7, 2, 9, 4, 11, 6, 1, 8, 3, 10, 5]


import itertools
import librosa
import six
from moonlight.music import constants
from moonlight.protobuf import musicscore_pb2
      next_pitch_class = full_key_sig[len(pitch_classes)]
      accidental = six.next(iter(values))
      # The pitch class must match exactly one of the 7 y positions that are
      # allowed for this key signature.
      for y_position in _KEY_SIGNATURE_Y_POSITION_RANGES[self.clef.glyph,
                                                         accidental]:
        if (self.clef.y_position_to_midi(y_position) %
            constants.NUM_SEMITONES_PER_OCTAVE) == next_pitch_class:
          return y_position, accidental
      raise AssertionError('Failed to find the next accidental y position')
    else:
      # The current key signature is unrecognized.
      return None, None

  def get_type(self):
    """Returns whether this is a sharp, flat, or None (C major) signature."""
    return (six.next(iter(self._accidentals.values()))
            if self._accidentals else None)

  def __len__(self):
    """Returns the number of accidentals in the key signature."""
    return len(self._accidentals)


def _key_sig_pitch_classes(note_name, ascending_fifths):
  first_pitch_class = (
      librosa.note_to_midi(note_name + '0') %
      constants.NUM_SEMITONES_PER_OCTAVE)
  # Go through the circle of fifths in ascending or descending order.
  step = 1 if ascending_fifths else -1

# Path: moonlight/music/constants.py
# MAJOR_SCALE = [0, 2, 4, 5, 7, 9, 11]
# NUM_SEMITONES_PER_OCTAVE = 12
# NUM_SEMITONES_IN_PERFECT_FIFTH = 7
# NUM_NOTES_IN_DIATONIC_SCALE = 7
# CIRCLE_OF_FIFTHS = [0, 7, 2, 9, 4, 11, 6, 1, 8, 3, 10, 5]


# Path: moonlight/score/elements/key_signature.py
import itertools
import librosa
import six
from moonlight.music import constants
from moonlight.protobuf import musicscore_pb2

      next_pitch_class = full_key_sig[len(pitch_classes)]
      accidental = six.next(iter(values))
      # The pitch class must match exactly one of the 7 y positions that are
      # allowed for this key signature.
      for y_position in _KEY_SIGNATURE_Y_POSITION_RANGES[self.clef.glyph,
                                                         accidental]:
        if (self.clef.y_position_to_midi(y_position) %
            constants.NUM_SEMITONES_PER_OCTAVE) == next_pitch_class:
          return y_position, accidental
      raise AssertionError('Failed to find the next accidental y position')
    else:
      # The current key signature is unrecognized.
      return None, None

  def get_type(self):
    """Returns whether this is a sharp, flat, or None (C major) signature."""
    return (six.next(iter(self._accidentals.values()))
            if self._accidentals else None)

  def __len__(self):
    """Returns the number of accidentals in the key signature."""
    return len(self._accidentals)


def _key_sig_pitch_classes(note_name, ascending_fifths):
  first_pitch_class = (
      librosa.note_to_midi(note_name + '0') %
      constants.NUM_SEMITONES_PER_OCTAVE)
  # Go through the circle of fifths in ascending or descending order.
  step = 1 if ascending_fifths else -1

  order = constants.CIRCLE_OF_FIFTHS[::step]