To register and login, use your Google, Twitter, Facebook, LinkedIn, or OpenID credentials.

This is allowing us to stop most spam registrations. We've deleted most of the spam accounts that got through, and we're closely watching for more.

Libpd + processing => desktop java application

berengerberenger Posts: 56
edited April 2013 in Pd Everywhere

Hello Everyone,

I tried to build a java application using processing and libpd I have a little trouble setting up a sample project. Basically I added processing-core.jar and libpd.jar to a new java project. I used the JavaSoundThread.java class from libpd samples, and i have trouble linking to the patch. Here is how it goes :

package test;

// p5 stuff import processing.core.*; import processing.data.*; import processing.event.*; import processing.opengl.*;

// java stuff import java.util.HashMap; import java.util.ArrayList; import java.io.File; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException;

//pd import org.puredata.core.*;

// main class : the PApplet extension seems to cause an issue with the hadling of exceptions

public class test extends PApplet {

 public static void main(String[] passedArgs) {
           String[] appletArgs = new String[] { "test" };
            if (passedArgs != null) {
              PApplet.main(concat(appletArgs, passedArgs));
            } else {
              PApplet.main(appletArgs);
            }

            JavaSoundThread audioThread = new JavaSoundThread(44100, 2, 16);
            int patch;
            patch = PdBase.openPatch("patch/test.pd"); // error
            audioThread.start();
            Thread.sleep(5000);  // error
                    audioThread.interrupt();
            audioThread.join(); // error
            PdBase.closePatch(patch);
      }


 // the rest is just processin stuff
public void setup() {
    size(600, 600);
    background(0);
}

public void draw() {
    fill(0, 25);
    rect(0, 0, width, height);

    for (int i = 0; i < 5; i++) {
        pushStyle();
        strokeWeight(5);
        stroke(255);
        point(random(600), random(600));
        popStyle();
    }

    if (mousePressed) {
        PdBase.sendFloat("hello", random(48, 72));
    }

}

}

Eclipse asks to add a throws declaration at the line loading the patch and also the Thread.sleep(5000); line aswell at the audioThread.join();

If I do so I get an error at the public static void main(String[] passedArgs) throws IOException stating that : Exception IOException is not compatible with throws clause in PApplet.main(String[])

Could somebody point me in the right direction to resolve this ?

Cheers

Answers

Sign In or Register to comment.