def __init__(self, sf2_path): super(FluidSynthPlayer, self).__init__() self.fs = F.Synth(gain=0.7, bsize=2048) # make a synth self.fs.start() # set default output driver and start clock self.sfid = self.fs.sfload(sf2_path) self.fs.program_select(0, self.sfid, 0, 0) self.p = F.Player(self.fs) # make a new player self.duration_in_ticks = 0 # length of midi file self.pause_time = 0 # time in midi ticks where player stopped
def __init__(self, sf2_path): super(FluidSynthPlayer, self).__init__() self.fs = F.Synth(bsize=2048) # make a synth self.driver_name = F.onLinux and 'pulseaudio' or 'dsound' self.fs.start(self.driver_name) # set default output driver and start clock self.sfid = self.fs.sfload(sf2_path) self.fs.program_select(0, self.sfid, 0, 0) self.p = F.Player(self.fs) # make a new player self.duration_in_ticks = 0 # length of midi file self.pause_time = 0 # time in midi ticks where player stopped self.set_gain(0.7)
def render_to_file(self, midi_path, output_path): fs = F.Synth(gain=1.0, bsize=2048, output_path=output_path) soundfont_path = self.pending_soundfont if not soundfont_path: soundfont_path = self.soundfont_path sfid = fs.sfload(soundfont_path) if sfid < 0: return 0 # not a sf2 file fs.program_select(0, sfid, 0, 0) player = F.Player(fs) # make a new one player.add(midi_path) player.play() samples = player.renderLoop() # print(samples) player.delete() fs.delete()
def __init__(self, sf2_path): super(FluidSynthPlayer, self).__init__() self.fs = F.Synth(gain=1.0, bsize=2048) # make a synth driver = None if is_linux: driver = 'pulseaudio' self.fs.start(driver) # set default output driver and start clock self.soundfont_path = sf2_path self.sfid = self.fs.sfload(sf2_path) self.fs.program_select(0, self.sfid, 0, 0) self.p = F.Player(self.fs) # make a new player self.duration_in_ticks = 0 # length of midi file self.pause_time = 0 # time in midi ticks where player stopped self.pending_soundfont = None
def __init__(self, sf2_path): super(FluidSynthPlayer, self).__init__() import fluidsynth as F self.fs = F.Synth(bsize=2048) # make a synth self.driver_name = F.onLinux and 'pulseaudio' or 'dsound' self.fs.start( self.driver_name) # set default output driver and start clock self.sf2 = sf2_path self.sfid = self.fs.sfload(self.sf2) self.fs.program_select(0, self.sfid, 0, 0) self.p = F.Player(self.fs) # make a new player self.fnm = '' # current midi file self.dur = 0 # lenght of midi file self.playing = 0 self.pause_time = 0 # time in midi ticks where player stopped self.set_gain(0.2)
def reset(self): # the only way to empty the playlist ... self.p.delete() # delete player self.p = F.Player(self.fs) # make a new one self.set_loop_midi_playback(self.loop_midi_playback)
def reset(self): # the only way to empty the playlist ... self.p.delete() # delete player self.p = F.Player(self.fs) # make a new one