Configuring Eclipse to work with Processing+libPd in Android

When we first came up with the idea of making Circle Synth, this was way before either Varun or I had any experience in developing for Android. The existence of libPd made life a lot easier from the sound design perspective, but we were still at a loss with respect to the visuals and animation. Developing natively presented a steep learning curve which like all good things in life, was going to take some time, which again, not many of us are blessed with in abundance. We wanted to create a test product really quickly, mostly for prototyping purposes and learn creative coding on Android quickly. Enter Processing.

To be honest, working with Processing hasn’t been as simple as writing your first ‘Hello, World’ program when you are learning a new programming language, but the fact that it has been tailored to make life easier for visual artists made a lot of things easier for us too. If you are like us, wanting to create quick interactive apps with some quality visual and audio content and you don’t really have the time or patience to learn native audio or animation programming, I would seriously recommend you check Processing and libPd out, if you haven’t already. It’s not going to be the most efficient implementation of what you want to do, but at least for us, it has been a really quick alternative.


  • Let’s get rid of the obvious. You need libPd, Processing and the Android development environment set up in Eclipse. Try out the ADT bundle if you haven’t already. It comes pre-installed with the ADT plugin, which in my opinion, saves a lot of trouble
  • All done? Let’s get started.

To access the libPd libraries, you need to import all the projects under pd-for-android into your eclipse workspace. The Processing lib file can be a bit of a pain, as we discovered. It seems that simply copying the core.jar file from processing into our libs folder isn’t a huge help, as it is configured to work in the Java mode when you are using the Processing native client. You need the processing-core.jar file, which as you might have guessed, isn’t available off the bat. The processing-core.jar file is generated when you export an android project from the native Processing client itself. What we are going to do is use that particular file and paste it into our android project’s ‘libs’ folder.

Now now, all your immediate problems may be solved by simply downloading the sample template project. It might make your life easier, and you can pray for our well-being in gratitude.

Now I am assuming you have some experience in Android development and Eclipse doesn’t totally freak you out, because if it does that is completely OK. I have spent countless hours questioning my sanity while working with Eclipse. So if you are still with me, read on.

Import the sample project into your workspace, and the first thing you will notice is – errors. This is simply because the libPd libraries are referenced locally, so you need to right-click on your project, go to properties –> Android and then assuming you have imported the pd-for-android sources into your workspace correctly, you can simply fix the path under the Library section.

Fix the local path to PdCore library project

Fix the local path to PdCore library project

Look for the little green tick

Look for the little green tick

Now, the errors “should” have all disappeared and you will have a perfectly working super simple touch-synth app at your disposal. Go ahead. Install it on your android device. Tell me you don’t find it fun.

Now the important bits about using Processing here. First off, you need to extend your activity as a PApplet instead of Activity as you do in apps which don’t use Processing. Make sure you import the relevant references(cmd+shift+O on OSX). Secondly, if you notice lines 29-39

public int sketchWidth() {

return displayWidth;


public int sketchHeight() {

return displayHeight;


public String sketchRenderer() {

return JAVA2D;

you will come across three sketch parameters which you might just be unfamiliar with. These callbacks ensure that the device screen width, height and the graphics renderer is specified properly, which you can then go on to use later on. The sample app uses these values to normalise the touch co-ordinates which is then passed onto Pd.

Ah, now that I mentioned Pd, the values from Processing are sent to Pd in the dispatchTouchEvent method. This method takes into consideration a few touch actions, viz, ACTION_DOWN(When the user touches the screen), ACTION_MOVE(When the user moves a finger across the screen) and ACTION_UP(When the user lifts the finger off the screen). Each of these events gets called depending on the action initiated, and then those values are passed off into Pd using the PdBase methods. In this case,


sends a value of 1 to the receiver named “pd_toggle” inside our tiny patch, thereby switching the synth on. Similarly, you can send bangs, messages, lists etc. to Pd from your java interface and let Pd handle the patch on its own.

A couple of things to be noted in this sample app. Pd is run as a background service, so DO NOT forget to add

<service android:name="">

to your Manifest.xml file in Eclipse. This sample app has everything pre-configured, but when you do want to create your own project, do keep this subtlety in mind. Another change in the Manifest file would be to add


to your existing app configuration. This becomes helpful in a multi-tasking scenario. This is basically to tell your app to refer to the single instance created in the activity stack, rather than create another one on top of it when you switch back to the app, or say, come back to your app from a phone call, or a text message. What happens otherwise, is you might end up having a new sketch on top of your existing sketch giving rise to a frustrating evening. Some other way might work for you, but this usually works best for us depending on what we want the app to do when it is minimised.

So here we are, all set up and rearing to go. Let’s have a quick look at what is happening inside the code.

Pd is setup as a background service. Feel free to re-use the boilerplate code from lines 49-122.

The wonderful thing is, now you can directly start coding in Eclipse as if you are programming in the Processing native client. You have your standard setup() and draw() methods as shown in the app. There might have to be a few adjustments made here and there, but hey, you are all set up and you can focus more on your awesome looking, eargasmic sounding android app than having to worry about getting the libraries to work with Eclipse in the first place!

This was the first in a three-part series of us documenting our struggle with programming Circle Synth. Watch out for more detailed posts soon, and if you already are super interested, check out the source code for Circle Synth right here on GitHub.

Give us a shout if this helped or made life tougher for you. Follow us on twitter or on Facebook.