Пример #1
0
def play_song_file(note, ms):
    m = musicbox.MusicBox()
    for x in note:
        m.play_note(note[x], ms[x])
        m.close()
Пример #2
0
def play_notes(notes):
    m = musicbox.MusicBox()
    for x in notes:
        m.play_note(notes[x], 500)
        m.close()
Пример #3
0
import musicbox
# CONSTANT VARIALBES
NOTES = [("C", 60), ("D", 62), ("E", 64), ("F", 65), ("G", 67), ("A", 69),
         ("B", 71)]
MAJOR_INTERVALS = [2, 2, 1, 2, 2, 2, 1]
MINOR_INTERVALS = [2, 1, 2, 2, 1, 2, 2]
DURATION = 500
OCTAVE_VALUE = 12
my_music = musicbox.MusicBox()


def note_to_int(note):
    # Counter for value of a note
    note_value = 0
    #Loops through the length of parameter
    for i in range(len(note)):
        #Loops through the length of List
        for j in range(len(NOTES)):
            #During the nest for loop if index of i in note == "^"
            if note[i] == "^":
                #if the note has another character after
                if note[i + 1] == "^" or (note[i + 1] == NOTES[j][0]):
                    note_value += OCTAVE_VALUE
                    # breaks the loops so it doesn't constantly add 12
                    break
            #if the note is just one character
            elif note[i] == NOTES[j][0]:
                # adds the default value to for that note from the list
                note_value += NOTES[j][1]
                #If the note has another character after
                if i < len(note) - 1: