Esempio n. 1
0
 def note_off(self, channel: int, key: int):
     check_result(
         Lib.fluid_synth_noteoff(
             self.synth,
             c_int(channel),
             c_int(key),
         ))
Esempio n. 2
0
 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),
         ))
Esempio n. 3
0
 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
Esempio n. 4
0
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)
Esempio n. 5
0
 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)))
Esempio n. 6
0
 def program_change(self, channel, preset_num):
     check_result(
         Lib.fluid_synth_program_change(self.synth, c_int(channel),
                                        c_int(preset_num)))
Esempio n. 7
0
 def system_reset(self):
     check_result(Lib.fluid_synth_system_reset(self.synth))
Esempio n. 8
0
 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)))
Esempio n. 9
0
 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)))
Esempio n. 10
0
 def __init__(self, synth: Synth):
     self.player = Lib.new_fluid_player(synth.synth)
Esempio n. 11
0
 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)))
Esempio n. 12
0
 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)))
Esempio n. 13
0
 def sfload(self, sf2_path: str, reset_presets=True):
     check_result(
         Lib.fluid_synth_sfload(self.synth, sf2_path.encode(),
                                c_int(reset_presets)))
Esempio n. 14
0
 def set_gain(self, gain: float):
     check_result(Lib.fluid_synth_set_gain(self.synth, c_float(gain)))
Esempio n. 15
0
 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)))
Esempio n. 16
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     check_result(Lib.delete_fluid_synth(self.synth))
Esempio n. 17
0
 def all_sounds_off(self, chan: int):
     check_result(Lib.fluid_synth_all_sounds_off(self.synth, c_int(chan)))
Esempio n. 18
0
 def __init__(self, settings: Settings):
     self.synth = Lib.new_fluid_synth(settings.settings)
Esempio n. 19
0
 def unset_program(self, chan: int):
     check_result(Lib.fluid_synth_unset_program(self.synth, c_int(chan)))
Esempio n. 20
0
 def channel_pressure(self, chan: int, val: int):
     check_result(
         Lib.fluid_synth_channel_pressure(self.synth, c_int(chan),
                                          c_int(val)))
Esempio n. 21
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     return Lib.delete_fluid_audio_driver(self.driver)
Esempio n. 22
0
 def bank_select(self, chan: int, bank: int):
     check_result(
         Lib.fluid_synth_bank_select(self.synth, c_int(chan), c_int(bank)))
Esempio n. 23
0
 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)))
Esempio n. 24
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     return Lib.delete_fluid_player(self.player)
Esempio n. 25
0
 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
Esempio n. 26
0
 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
Esempio n. 27
0
 def program_reset(self):
     check_result(Lib.fluid_synth_program_reset(self.synth))
Esempio n. 28
0
 def __init__(self, settings: Settings, synth: Synth):
     self.driver = Lib.new_fluid_audio_driver(settings.settings,
                                              synth.synth)
Esempio n. 29
0
 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)))