In ofxEspeakSynth, the method to set callbacks only takes a static method as an argument:
I was hoping if I changed the method to non-static, I could have multiple instances of espeak in play at once. Maybe the lib itself just doesn’t support this, but asking just in case there’s something I can do on the c++ side. I confess that I don’t yet understand typedef usage and lib-interface…
Here are the src files anyway:
src.zip (4.0 KB)
you can use
std::bind to make a class member function work. It is how it is done most often.
@roymacdonald std::bind() requires me to include the method arguments, but it looks like these would normally be set from inside the api as synthcall is defined, but never called in the src files except for when it’s set as a callback:
so would I need to fiddle around with the source code of the lib…?
hi, you have to pass placeholders for the arguments.
So, the following should work if called from within ofxEspeakSynth.
std::bind(&ofxEspeakSynth::synthcall, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
Sorry, I don’t quite get what to do. So I’ve commented out the static keyword in ofxEspeakSynth.h:
commented out the declarations of the static members:
and now I’m trying to figure out what to do with the code you gave me:
The espeak_setSynthCallback takes an argument of type t_espeak_callback*, but the original code accepts a static method name. How can I use the bound method as an argument?
hi. sorry for the delay. were you able to fix it?
@roymacdonald So espeak_SetSynthCallback() takes as an argument a method without parentheses, but only works with static methods. How would I use std::bind in this situation?