2

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());
    }
};
Max N
  • 1,134
  • 11
  • 23
PgsPT
  • 21
  • 3

1 Answers1

0

libPD is basically wrapper code together with the PD engine. You can find what exact functions are called from the wrapper and use those directly if possible (in your coding environment) once you allocated your pd patch.

Not all compilers support mix of coding language so easy. But i am pretty sure you will find what you need when you look into the wrapper code. You will also find what parameters are needed with those functions. Also be careful with those parameters as some of the wrapper functions help evaluating before handing them over to the pd engine and vice versa.

Ol Sen
  • 3,163
  • 2
  • 21
  • 30