def playSolution(solution): """ Plays back a given solution. INPUT: dict solution: NOTE: GUI passes in a list of the form: [["<singer><time>", int pitchnum], ...] Command-line interface uses a different representation than the GUI code. So, this function handles both cases until I update the GUI code to follow the CLI style. OUTPUT: True if playback is successful, False otherwise. """ # TODO(erickim)[2018-12-09] Not fond of using global canPlayback if not canPlayback: print "Warning: midi playback not supported. Did you install mingus?" return False if type(solution) is dict: track = sol2fluidsynth(solution) elif type(solution) is list: # Convert list-repr to dict repr soldict = {} for (key, pitchnum) in solution: dictkey = key[0] + "_" + key[1:] soldict[dictkey] = pitchnum track = sol2fluidsynth(soldict) else: raise ValueError("Unexpected type: {0}".format(type(solution))) try: fluidsynth.play_Track(track) fluidsynth.main_volume(1, 127) except Exception as e: print e return False return True
def playSolution(solution): """ Plays back a given solution. INPUT: dict solution: NOTE: GUI passes in a list of the form: [["<singer><time>", int pitchnum], ...] Command-line interface uses a different representation than the GUI code. So, this function handles both cases until I update the GUI code to follow the CLI style. OUTPUT: True if playback is successful, False otherwise. """ if type(solution) is dict: track = sol2fluidsynth(solution) elif type(solution) is list: # Convert list-repr to dict repr soldict = {} for (key,pitchnum) in solution: dictkey = key[0]+"_"+key[1:] soldict[dictkey] = pitchnum track = sol2fluidsynth(soldict) else: raise ValueError("Unexpected type: {0}".format(type(solution))) try: fluidsynth.play_Track(track) fluidsynth.main_volume(1, 127) except Exception as e: print e return False return True
def play(self, melody, chords, bpm, scores, bars, key, mode, modeToPass, tra, file, out_dir): t2 = Track() sh = progressions.to_chords(chords, key) for i in range(0, len(sh)): b = Bar(None, (4, 4)) if len(chords[i][0]) > 5: b.place_notes(None, 1) else: b.place_notes(NoteContainer(sh[i]), 1) t2 + b fluidsynth.pan(1, 25) fluidsynth.pan(2, 120) fluidsynth.main_volume(2, 50) fluidsynth.play_Tracks([melody, t2], [1, 2], bpm) # sleep(500000) button = Button(text='Clique para rearmonizar!', command=lambda: self.checkReharmonize( chords, scores, bars, key, mode, modeToPass, tra, bpm, file, out_dir), bg='brown', fg='white', font=('helvetica', 9, 'bold')) self.canvas1.create_window(200, 250, window=button)
def play_smart_solo_over_chords(chord_list): fluidsynth.set_instrument(13, 45) fluidsynth.set_instrument(10, 108) fluidsynth.main_volume(13, 75) fluidsynth.main_volume(10, 100) solo = Track() bars = generate_solo(chord_list) for i in range(len(bars)): chord = NoteContainer(chords.from_shorthand(chord_list[i])) bar = bars[i] fluidsynth.play_NoteContainer(chord, 13) fluidsynth.play_Bar(bar, 10) fluidsynth.stop_NoteContainer(chord, 13) solo.add_bar(bar) return solo
def play(self): fluidsynth.set_instrument(1, 73) # chords fluidsynth.set_instrument(2, 32) # bass fluidsynth.set_instrument(3, 1, 128) # drums fluidsynth.main_volume(1, 50) fluidsynth.main_volume(2, 100) fluidsynth.main_volume(3, 30) for bars in self._next_bar(): fluidsynth.play_Bars(bars, [1, 2, 3], 110) yield self.current