<commit_before>"""Generate music."""


import random
import midiutil.MidiFile as MidiFile


NOTES = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
NOTE_COUNT = len(NOTES)
# This is for octave 1
MIDI_MAP = {'C': 24, 'D': 26, 'E': 28, 'F': 29, 'G': 31, 'A': 33, 'B': 35}


class Note(object):
    """Cute class to let us do math with notes."""

    def __init__(self, pitch, octave, note_number=None):
        if note_number is None:
            note_number = NOTES.index(pitch)

        self.pitch = pitch
        self.octave = octave
        self.note_number = note_number

    def __add__(self, steps):
        """Return the note @steps steps away from this note."""
        note_number = self.note_number + steps
        if note_number >= NOTE_COUNT or note_number < 0:
            octave = self.octave + (note_number // NOTE_COUNT)
            note_number = note_number % NOTE_COUNT
        else:
            octave = self.octave

        return Note(NOTES[note_number], octave, note_number=note_number)

    def midi_pitch(self):
        """Return the midi pitch number for this note."""
        octave_1_num = MIDI_MAP[self.pitch]
        number = octave_1_num + self.octave * 12
        while number > 127:
            number = number - 12
        return number<commit_msg>stay within reasonable octaves<commit_after>"""Generate music."""


import random
import midiutil.MidiFile as MidiFile


NOTES = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
NOTE_COUNT = len(NOTES)
# This is for octave 1
MIDI_MAP = {'C': 24, 'D': 26, 'E': 28, 'F': 29, 'G': 31, 'A': 33, 'B': 35}

MAX_OCTAVE = 7
MIN_OCTAVE = 1


class Note(object):
    """Cute class to let us do math with notes."""

    def __init__(self, pitch, octave, note_number=None):
        if note_number is None:
            note_number = NOTES.index(pitch)

        self.pitch = pitch
        self.octave = octave
        self.note_number = note_number

    def __add__(self, steps):
        """Return the note @steps steps away from this note."""
        note_number = self.note_number + steps
        if note_number >= NOTE_COUNT or note_number < 0:
            octave = self.octave + (note_number // NOTE_COUNT)
            octave = min(octave, MAX_OCTAVE)
            octave = max(octave, MIN_OCTAVE)
            note_number = note_number % NOTE_COUNT
        else:
            octave = self.octave

        return Note(NOTES[note_number], octave, note_number=note_number)

    def midi_pitch(self):
        """Return the midi pitch number for this note."""
        octave_1_num = MIDI_MAP[self.pitch]
        number = octave_1_num + self.octave * 12
        return number
{'fraction_non_alphanumeric': 0.12169919632606199, 'fraction_numerical': 0.017986988136241867, 'mean_word_length': 2.518169582772544, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2046192', 'n_tokens_mistral': 920, 'n_tokens_neox': 833, 'n_words': 256}