Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Created By Lewisk3 / Redxone
- import winsound
- import time
- music = []
- notes = {
- 'C': { '1':131, '2':262, '3':523, '4':1046, '5':2096 },
- 'C#': { '1':139, '2':277, '3':554, '4':1108, '5':2217 },
- 'D': { '1':147, '2':294, '3':587, '4':1175, '5':2349 },
- 'D#': { '1':156, '2':311, '3':622, '4':1244, '5':2489 },
- 'E': { '1':165, '2':330, '3':659, '4':1318, '5':2637 },
- 'F': { '1':175, '2':349, '3':698, '4':1397, '5':2794 },
- 'F#': { '1':185, '2':370, '3':740, '4':1480, '5':2960 },
- 'G': { '1':196, '2':392, '3':784, '4':1568, '5':3136 },
- 'G#': { '1':208, '2':415, '3':831, '4':1664, '5':3322 },
- 'A': { '1':220, '2':440, '3':880, '4':1760, '5':3520 },
- 'A#': { '1':233, '2':466, '3':932, '4':1866, '5':3729 },
- 'B': { '1':248, '2':494, '3':988, '4':1973, '5':951 },
- }
- def loadInto(table):
- for note in table:
- music.append( note )
- def interpret(file):
- online = 1
- f_Song = []
- #######################################################
- try:
- rFile = open(file, 'r')
- except:
- print('[NOSTALGIAFY] - File not found [' + file + ']')
- time.sleep(1)
- exit()
- ################### - Done Open Trying - ###################
- for line in rFile.readlines():
- fInfo = str(line).split()
- comp = len(fInfo)
- if(str(fInfo[0]) in notes):
- if comp == 2:
- k, v = str(fInfo[0]), str(fInfo[1])
- f_Song.append( ( notes[k][v], 250, 0.0 ) )
- elif comp == 3:
- k, v, l = str(fInfo[0]), str(fInfo[1]), int(fInfo[2])
- f_Song.append( ( notes[k][v], l, 0.0 ) )
- elif comp == 4:
- k, v, l, t = str(fInfo[0]), str(fInfo[1]), int(fInfo[2]), float(fInfo[3])
- f_Song.append( ( notes[k][v], l, t ) )
- else:
- print('[NOSTALGIAFY] - Invalid note on line [' + str(online) + ']')
- time.sleep(1)
- exit()
- online += 1
- #######################################################
- # - DONE LOADING - # Put File Into Music Below \-/
- ####################
- loadInto(f_Song)
- play()
- def play():
- for sound in music:
- print ("[NOSTALGIAFY] - Frec[" + str(float(sound[0])) + "] Duration[" + str(float(sound[1])) + "]")
- time.sleep(0.01)
- winsound.Beep(sound[0], sound[1])
- print ("[NOSTALGIAFY] - Waiting " + str(float(sound[2])) + "s")
- time.sleep(sound[2])
- music_file = input("Input Music File Location: ")
- interpret(music_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement