Hi,
I am using the FMOD audio-library with the pyFMOD python bindings. pyFMOD uses
ctypes. It is possible to register callback functions with FMOD that are
called at certain points in the processing pipeline or when certain events
happen.
I am expecially interested in the one that fires when a currently playing
stream ends. This is what the declaration in pyFMOD looks like:
_FSOUND_Stream_ SetEndCallback =
getattr(fmod,"_ FSOUND_Stream_S etEndCallback@1 2")
_FSOUND_Stream_ SetEndCallback. restype = c_byte
def FSOUND_Stream_S etEndCallback(s tream, callback, userdata):
result = _FSOUND_Stream_ SetEndCallback( c_int(stream), c_int(callback) ,
c_int(userdata) )
if not result: raise fmod_exception( )
I cannot make it work, however. I tried:
def _sound_end_call back(stream,buf ,len,userdata):
print "_sound_end_cal lback(): Stream has reached the end."
as simplest possible callback function. I am registering it like this:
pyFMOD.FSOUND_S tream_SetEndCal lback(_currentt rack,_sound_end _callback,0)
And this is how my program dies:
File "d:\projekte\ec lipse\workspace \gettone\getton esound.py", line 175, in
sound_tick
pyFMOD.FSOUND_S tream_SetEndCal lback(_currentt rack,_sound_end _callback,0)
File "c:\programme\P ython23\lib\sit e-packages\pyFMOD .py", line 690, in
FSOUND_Stream_S etEndCallback
result = _FSOUND_Stream_ SetEndCallback( c_int(stream), c_int(callback) ,
c_int(userdata) )
TypeError: int expected instead of function instance
I am very new to Python and have zero idea what the problem is nor how to
solve it. In some of my other languages I would have to explicitly make a
function pointer and possibly have to cast that to an int to pass it to
SetEndCallback, but that seems very inappropriate in Python...
Ciao, MM
--
Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013.
"Wir brauchen keine Opposition, wir sind bereits Demokraten."
I am using the FMOD audio-library with the pyFMOD python bindings. pyFMOD uses
ctypes. It is possible to register callback functions with FMOD that are
called at certain points in the processing pipeline or when certain events
happen.
I am expecially interested in the one that fires when a currently playing
stream ends. This is what the declaration in pyFMOD looks like:
_FSOUND_Stream_ SetEndCallback =
getattr(fmod,"_ FSOUND_Stream_S etEndCallback@1 2")
_FSOUND_Stream_ SetEndCallback. restype = c_byte
def FSOUND_Stream_S etEndCallback(s tream, callback, userdata):
result = _FSOUND_Stream_ SetEndCallback( c_int(stream), c_int(callback) ,
c_int(userdata) )
if not result: raise fmod_exception( )
I cannot make it work, however. I tried:
def _sound_end_call back(stream,buf ,len,userdata):
print "_sound_end_cal lback(): Stream has reached the end."
as simplest possible callback function. I am registering it like this:
pyFMOD.FSOUND_S tream_SetEndCal lback(_currentt rack,_sound_end _callback,0)
And this is how my program dies:
File "d:\projekte\ec lipse\workspace \gettone\getton esound.py", line 175, in
sound_tick
pyFMOD.FSOUND_S tream_SetEndCal lback(_currentt rack,_sound_end _callback,0)
File "c:\programme\P ython23\lib\sit e-packages\pyFMOD .py", line 690, in
FSOUND_Stream_S etEndCallback
result = _FSOUND_Stream_ SetEndCallback( c_int(stream), c_int(callback) ,
c_int(userdata) )
TypeError: int expected instead of function instance
I am very new to Python and have zero idea what the problem is nor how to
solve it. In some of my other languages I would have to explicitly make a
function pointer and possibly have to cast that to an int to pass it to
SetEndCallback, but that seems very inappropriate in Python...
Ciao, MM
--
Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013.
"Wir brauchen keine Opposition, wir sind bereits Demokraten."
Comment