def AutoMusic(self, parent, page_type, loadpic, waitpic, incontainer, outcontainer, records, music): """ This is a callback function for 'Generate' button. It takes the random inputs, make an AutoComposeSong object, and execute its functions to output a MIDI file. * See 'AutoComposeSong.py' for the detailed explanation on how these methods work. """ genre = random.choice(["Waltz", "Pop", "New Age"]) key = C cp = random.choice([CP3, CP4, CP5]) title = "Randomly Generated Song" mode = Tonics numPhrase = 4 beat = 72 userInput = [] autoSong = AutoComposeSong() autoSong.reset() autoSong.setTitle(title) autoSong.setup(genre, key, mode, cp, numPhrase, beat, userInput) autoSong.exportMidi(1, 'Output MIDIs/' + title + '.mid') self.page_factory(parent, page_type, loadpic, waitpic, incontainer, outcontainer, records, autoSong)
def AutoMusic(self, parent, page_type, loadpic, waitpic, incontainer, outcontainer, records, music): """ This is a callback function for 'Generate' button. It takes the selected inputs from the listbox, make an AutoComposeSong object, and execute its functions to output a MIDI file. * See 'AutoComposeSong.py' for the detailed explanation on how these methods work. """ genre = self.genreList[int(self.gr_listbox.curselection()[0])] key = eval(self.keyList[int(self.key_listbox.curselection()[0])]) cp = self.cpList[int(self.cp_listbox.curselection()[0])] title = self.title.get() mode = Tonics numPhrase = 4 beat = 72 if self.entry_field.get() == '': userInput = [] else: userInput = Song() userInput.reset() userInputMelody = wrapNote(self.entry_field.get().split('-')) userInputTimes = constant_times(userInputMelody, 2, beat) userInput.wrapNotesAndTimes(userInputMelody, userInputTimes) autoSong = AutoComposeSong() autoSong.reset() autoSong.setTitle(title) autoSong.setup(genre, key, mode, cp, numPhrase, beat, userInput) autoSong.exportMidi(1, 'Output MIDIs/' + title + '.mid') self.page_factory(parent, page_type, loadpic, waitpic, incontainer, outcontainer, records, autoSong)