Comment 4 for bug 2047656

Revision history for this message
Michael Mehl (mmehl) wrote :

Here is the test in python (you can chooses any midifile and adapt the variable midifile accordingly).
You can also adapt the lib variable.

--

from ctypes import c_int, c_double, c_char_p, byref, CDLL
import logging
import time

lib="./libfluidsynth.so.3.2.2"
fluidsynth = CDLL(lib)
def b(s):
    return s.encode("latin-1")

midifile="airwolf.mid"
settings = fluidsynth.new_fluid_settings()
fluidsynth.fluid_settings_setnum(settings, c_char_p(b('synth.gain')), c_double(0.2))

synth = fluidsynth.new_fluid_synth(settings)
filename="/usr/share/sounds/sf2/FluidR3_GM.sf2"
soundfont = fluidsynth.fluid_synth_sfload(synth, c_char_p(b(filename)), 0)

player = fluidsynth.new_fluid_player(synth)

fluidsynth.fluid_settings_setstr(settings, c_char_p(b('audio.driver')), c_char_p(b('pulseaudio')))

audio_driver = fluidsynth.new_fluid_audio_driver(settings, synth)

errcode = fluidsynth.fluid_player_add(player, c_char_p(b(midifile)))
if (errcode!=0): logging.warning("add midi failed")

errcode = fluidsynth.fluid_player_seek(player, 0)
if (errcode!=0): logging.warning("seek failed")

total_ticks = fluidsynth.fluid_player_get_total_ticks(player)

errcode = fluidsynth.fluid_player_play(player)
if (errcode!=0): logging.warning("play failed")

total_ticks = fluidsynth.fluid_player_get_total_ticks(player)

time.sleep(1)

errcode = fluidsynth.fluid_player_stop(player)
if (errcode!=0): logging.warning("stop failed")

current_tick = fluidsynth.fluid_player_get_current_tick(player)
total_ticks = fluidsynth.fluid_player_get_total_ticks(player)

errcode = fluidsynth.fluid_player_play(player)
if (errcode!=0): logging.warning("continue failed")