def note_off(self, channel: int, key: int): check_result( Lib.fluid_synth_noteoff( self.synth, c_int(channel), c_int(key), ))
def cc(self, chan: int, ctrl: int, val: int): check_result( Lib.fluid_synch_cc( self.synth, c_int(chan), c_int(ctrl), c_int(val), ))
def get_program(self, chan: int): sfont_id = c_int() bank_num = c_int() preset_num = c_int() check_result( Lib.fluid_synth_get_program(self.synth, c_int(chan), byref(sfont_id), byref(bank_num), byref(preset_num))) return sfont_id.value, bank_num.value, preset_num.value
def test_scales(): with Settings({"audio.driver": "alsa"}) as settings: with Synth(settings) as synth: with Player(synth) as player: with Driver(settings, synth) as driver: synth.sfload("/usr/share/sounds/sf2/FluidR3_GM.sf2", 1) scale = [ 0, 4, 7, 12, ] scale = scale + list(reversed(scale))[1:] programs = [10, 30, 59, 110, 120] for channel, program in enumerate(programs): synth.program_change(channel, program) for channel, j in enumerate(scale): for i in scale: notes = [k + i for k in [ 60 + j, 67 + j, ]] for note in notes: synth.note_on(channel, note, 100) time.sleep(.25) from pyfluidsynth2.lib import Lib x = ctypes.c_int() Lib.fluid_synth_pitch_bend(synth.synth, 0, ctypes.c_int(123)) Lib.fluid_synth_get_pitch_bend( synth.synth, 0, ctypes.byref(x)) print(x.value) for note in notes: try: synth.note_off(channel, note) except PyFluidSynth2Exception as e: print(e)
def get_pitch_wheel_sens(self, chan: int): val = c_int() check_result( Lib.fluid_synth_get_wheel_sens(self.synth, c_int(chan), byref(val)))
def program_change(self, channel, preset_num): check_result( Lib.fluid_synth_program_change(self.synth, c_int(channel), c_int(preset_num)))
def system_reset(self): check_result(Lib.fluid_synth_system_reset(self.synth))
def pitch_wheel_sens(self, chan: int, val: int): check_result( Lib.fluid_synth_pitch_wheel_sens(self.synth, c_int(chan), c_int(val)))
def sfont_select(self, chan: int, sfont_id: int): check_result( Lib.fluid_synth_sfont_select(self.synth, c_int(chan), c_int(sfont_id)))
def __init__(self, synth: Synth): self.player = Lib.new_fluid_player(synth.synth)
def note_on(self, chan: int, key: int, vel: int): check_result( Lib.fluid_synth_noteon(self.synth, c_int(chan), c_int(key), c_int(vel)))
def key_pressure(self, chan: int, key: int, val: int): check_result( Lib.fluid_synth_key_pressure(self.synth, c_int(chan), c_int(key), c_int(val)))
def sfload(self, sf2_path: str, reset_presets=True): check_result( Lib.fluid_synth_sfload(self.synth, sf2_path.encode(), c_int(reset_presets)))
def set_gain(self, gain: float): check_result(Lib.fluid_synth_set_gain(self.synth, c_float(gain)))
def set_channel_type(self, chan: int, _type: int): check_result( Lib.fluid_synth_set_channel_type(self.synth, c_int(chan), c_int(_type)))
def __exit__(self, exc_type, exc_val, exc_tb): check_result(Lib.delete_fluid_synth(self.synth))
def all_sounds_off(self, chan: int): check_result(Lib.fluid_synth_all_sounds_off(self.synth, c_int(chan)))
def __init__(self, settings: Settings): self.synth = Lib.new_fluid_synth(settings.settings)
def unset_program(self, chan: int): check_result(Lib.fluid_synth_unset_program(self.synth, c_int(chan)))
def channel_pressure(self, chan: int, val: int): check_result( Lib.fluid_synth_channel_pressure(self.synth, c_int(chan), c_int(val)))
def __exit__(self, exc_type, exc_val, exc_tb): return Lib.delete_fluid_audio_driver(self.driver)
def bank_select(self, chan: int, bank: int): check_result( Lib.fluid_synth_bank_select(self.synth, c_int(chan), c_int(bank)))
def program_select_by_sfont_name(self, chan: int, sfont_name: str, bank_num: int, preset_num: int): check_result( Lib.fluid_synth_program_select_by_sfont_name( self.synth, c_int(chan), sfont_name.encode(), c_int(bank_num), c_int(preset_num)))
def __exit__(self, exc_type, exc_val, exc_tb): return Lib.delete_fluid_player(self.player)
def get_pitch_bend(self, chan: int): pitch_bend = c_int() check_result( Lib.fluid_synth_get_pitch_bend(self.synth, c_int(chan), byref(pitch_bend))) return pitch_bend.value
def get_cc(self, chan: int, ctrl: int): val = c_int() check_result( Lib.fluid_synth_get_cc(self.synth, c_int(chan), c_int(ctrl), byref(val))) return val.value
def program_reset(self): check_result(Lib.fluid_synth_program_reset(self.synth))
def __init__(self, settings: Settings, synth: Synth): self.driver = Lib.new_fluid_audio_driver(settings.settings, synth.synth)
def program_select(self, chan: int, sfont_id: int, bank_num: int, preset_num: int): check_result( Lib.fluid_synth_program_select(self.synth, c_int(chan), c_int(sfont_id), c_int(bank_num), c_int(preset_num)))