I'm working with Pure Data to build sound-sensitive apps on Android. After all the patching done, I now want to be able to not rely on libpd methods (such as set listeners, and information receiving methods) so I can use Pd with any Activity with a couple of lines of code.
The problem is that I want to be able to treat the output I get from Pd differently depending on the Activity (I now have a multi-activity app). But I can't seem to find a way to do this without overriding the listener on Pd dispatcher, resulting in confusing code and excess of boilerplate code.
I've been searching for a way to build my own custom listener that is called when libpd receives information from Pd, but this adds a lot more lines of code to the Activity itself!
This is how I treat information on each Activity now (simplified).
pd.getMyDispatcher().addListener("bonk-cooked", new PdListener.Adapter() {
@Override
public void receiveList(String source, Object... objects) {
String bonkOutput;
int template = (int) Double.parseDouble(objects[0].toString());
float velocity = Float.parseFloat(objects[1].toString());
}
};