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")
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")
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" new_fluid_ settings( ) fluid_settings_ setnum( settings, c_char_ p(b('synth. gain')) , c_double(0.2))
settings = fluidsynth.
fluidsynth.
synth = fluidsynth. new_fluid_ synth(settings) "/usr/share/ sounds/ sf2/FluidR3_ GM.sf2" fluid_synth_ sfload( synth, c_char_ p(b(filename) ), 0)
filename=
soundfont = fluidsynth.
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) )) warning( "add midi failed")
if (errcode!=0): logging.
errcode = fluidsynth. fluid_player_ seek(player, 0) warning( "seek failed")
if (errcode!=0): logging.
total_ticks = fluidsynth. fluid_player_ get_total_ ticks(player)
errcode = fluidsynth. fluid_player_ play(player) warning( "play failed")
if (errcode!=0): logging.
total_ticks = fluidsynth. fluid_player_ get_total_ ticks(player)
time.sleep(1)
errcode = fluidsynth. fluid_player_ stop(player) warning( "stop failed")
if (errcode!=0): logging.
current_tick = fluidsynth. fluid_player_ get_current_ tick(player) fluid_player_ get_total_ ticks(player)
total_ticks = fluidsynth.
errcode = fluidsynth. fluid_player_ play(player) warning( "continue failed")
if (errcode!=0): logging.