Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all 2896 articles
Browse latest View live

Where I can download this package ? (com.bric.image.transition)

$
0
0

Hello all,

I've found a programm where it is written "package com.bric.image.transition" but I've not this package and I don't find this.

So if you've an idea of where is the package and where it is possible to download it, please answer to me.

Thank you very much !! :)


Sound in processing program

$
0
0

Hello,
I am trying to generate a sound as part of a processing program.
I have tried the code below but it does not work.
I tried to store my sound file (Surf.wav) in a 'data' folder but still does not work.
I use 'filezilla' to load my sketch, so I have created the data folder below the 'public' folder.
I don't get any error message, just sound does not play.
Thanks for your help.

Vincent

code:

import ddf.minim.*;
Minim minim;
AudioPlayer player;
void setup() {
    minim = new Minim(this);
    player = minim.loadFile("data/Surf.wav");
    player.play();

Send an array throught Network (local only)

$
0
0

Hi everyone, I would like to know how to send an array throught the network, I've already tried but it don't seems to work Here is what i've already done :

Server side:

import processing.net.*;


boolean canIdraw = true ,envoye = false;

Server s;
Client c;
String input, pseudo;
int data[];
int [] data_terrain;



void setup() {
  size(500,500);
  background(204);
  stroke(0);
  data_terrain = new int[300]; // i generate an array w/ 300 int inside

  for ( int i = 0 ; i < 300 ; i++) {
    data_terrain [i] = int(random(20,150));  // data between 20 and 150
     }



    s = new Server(this, 12345);    // I start my server on this port 12345, for the moment everything is launched on the same computer
}


void draw() {

  if(envoye){
    envoye= false ;
  for ( int i = 0 ; i < 300 ; i++) { // It sends the array, value by value
 s.write(data_terrain[i]);
 println(data_terrain[i]);        // it print every value, to check they are the same between the two codes

}
}
}

void mousePressed(){                                      // If the mouse is pressed, then it starts sending the array
  envoye = true ;
}

Client Side :

import processing.net.*;


Client c;
String input= ".";
int data[];
int [] data_terrain ;
int i =0;



void setup() {
  size(700,300);
  background(204);
  stroke(0);
  data_terrain = new int[300];




  c = new Client(this, "127.0.0.1", 12345);// local, w/ the same port of course
}

void draw() {

  //if it receive data from server
  if (c.available() > 0) {
    input = c.readString();
   background(255);            // just change the background to know if there is a connection
   data_terrain[i]=int(input); // save the value received and print it.
   println(data_terrain[i]);
   println(i);
   i++; // increased i, and wait until the next value
  }
}

If you have the answer, please explain, 'cause I can't find a way to do it anywhere in the web.

Have a good day

PS: Sorry, my english is not perfect at all

Reading a color value from webcam.

$
0
0

Hello, I am making a small program that reads what color hat you are wearing and then performs a virtual key press via a robot to interact with a game. I got it sort of working so far in that it will detect red colors but not blue or green. I am using a hue color index to track the colors. Any idea of how I could do it differently or if there is anything I am missing.

// check for red pixels int redPixelCount = 0; int bluePixelCount = 0; int greenPixelCount = 0; int yellowPixelCount= 0; for (int x=0; x<640; x++) { for (int y=0; y<240; y++) { color c = get(x, y); int px = cam.pixels[y*width+x]; float h = hue(px); float s = saturation(px); float b = brightness(px); // if it's bright, saturated and a specific color if (b > 100 && s > 100 && (h < 20 || h > 230)) { redPixelCount++; } if (b > 100 && s > 100 && (h < 240 && h > 180)) { bluePixelCount++; } if (b > 100 && s > 100 && (h < 80 && h > 140)) { greenPixelCount++; } if (b > 100 && s > 100 && (h < 50 && h > 70)) { yellowPixelCount++; } } }

Structuring the code

$
0
0

Sorry to post it here, but I'm having a huge problem structuring my code. I have just started working with processing, so I'm more of a beginner. Would really appreciate if anyone could help me with this.

The idea behind my project is to be able to control the amount of negative and positive information we want to see. I tried to combine rss reader code of two different websites and make a working slider that would change the background colour. Headlines of the bad news would be displayed in black and the good news would be in white. Depending on type of information we want to see, the background would change from black to white revealing only headlines we want to read.

This is a v simple idea, been trying to structure it out so the headlines would work in colour too but I don't think I've got enough knowledge to do so.

rss code:

String[] titles;
String[] titles2;


PFont font;
//color textColor = 255;
void setup() {
  size(1450,860);
  background(0);
  noStroke();
  smooth();

  // Setup font
  font = loadFont("din.vlw");
  textFont(font, 18);

  // Load RSS feed

  String url = "https://feedity.com/reddit-com/W1FRU1ZV.rss";
  XML rss = loadXML(url);
  //println(rss.listChildren());

  // Get title of each element

  XML[] titleXMLElements = rss.getChildren("channel/item/title");
  titles = new String[titleXMLElements.length];
  for (int i = 0; i < titleXMLElements.length; i++) {
    String title = titleXMLElements[i].getContent();


    titles[i] = title;
  }

    String url2 = "https://feedity.com/reddit-com/W1FRU1ZW.rss";
  XML rss2 = loadXML(url2);
  // Get title of each element
  //println(rss2.listChildren());

  XML[] title2XMLElements = rss2.getChildren("channel/item/title");
  titles2 = new String[title2XMLElements.length];
  for (int i = 0; i < title2XMLElements.length; i++) {
    String title2 = title2XMLElements[i].getContent();
    // Store title in array for later use
    titles2[i] = title2; }

}

void draw() {
background(255);

  for (int i = 0; i < titles.length; i++) {
    float y = (i+1) * 15;

    fill(0, 220);
    text(titles[i], 100, y*6, 500, 200);

  }

  for (int i = 0; i < titles2.length; i++) {
    float y = (i+1) * 15;

    fill(0);
    text(titles2[i], 800, y*6, 500, 100);
}
}

Slider ( got this one from http://www.sojamo.de/ and been trying to use some parts of it)

PGraphics letters;   //news headlines
PGraphics sliders;   //control sliders/background colour

import controlP5.*;

ControlP5 cp5;

int myColor = color(255);
int c1,c2;
float n,n1;


void setup() {
  size(400,600);
  noStroke();
  cp5 = new ControlP5(this);

  letters = createGraphics(width, height);
  sliders = createGraphics(width, height);



  // create a new button with name 'buttonA'
  cp5.addButton("colorA")
     .setValue(0)
     .setPosition(100,100)
     .setSize(200,19)
     ;

  // and add another 2 buttons
  cp5.addButton("colorB")
     .setValue(100)
     .setPosition(100,120)
     .setSize(200,19)
     ;



}

void draw() {
  background(myColor);
  myColor = lerpColor(c1,c2,n);
  n += (1-n)* 0.1;
}

public void controlEvent(ControlEvent theEvent) {
  println(theEvent.getController().getName());
  n = 0;
}

// function colorA will receive changes from
// controller with name colorA
public void colorA(int theValue) {
  println("a button event from colorA: "+theValue);
  c1 = c2;
  c2 = color(0,0,0);
}

// function colorB will receive changes from
// controller with name colorB
public void colorB(int theValue) {
  println("a button event from colorB: "+theValue);
  c1 = c2;
  c2 = color(255);
}


public void play(int theValue) {
  println("a button event from buttonB: "+theValue);
  c1 = c2;
  c2 = color(0,0,0);
}

I have been trying to use PGraphics but again, I cannot think what's the best way to structure my code. I'd really appreciate any help,

Thank you!!

processing.data.JSONObject to org.json.JSONObject conversion

$
0
0

I am using PubNub to publish data coming from my processing script. The trouble I am having is that the publish command expects a org.json.JSONObject and I cannot for the life of me get processing to make a org.json.JSONOnject. I have the libraries installed in the sketch and the processing IDE recognizes the class, but I get the error: "Unhandled exception type JSONException". At this point I am just using a very simple example JSON builder code for org.json taken from this site: http://theoryapp.com/parse-json-in-java/ but I have tried many different combinations. Here is my current code:

 import org.json.*;

  void setup() {
     String str = "{ \"name\": \"Alice\", \"age\": 20 }";
     org.json.JSONObject obj = new org.json.JSONObject(str);
     String n = obj.getString("name");
     int a = obj.getInt("age");
     println(n + " " + a);
   }

  void draw() {
   }

I am wondering if anybody has used org.json.JSONObject successfully or if there is someway to make a processing JSON object recognizable by others as a viable org.json.JSONObject.

unsatisfied link error in java.library.path

$
0
0

Hi all -

I'm trying to work with a streaming video library named red5streaming.jar, which I've put in /libraries/red5streaming/library/ (as well as dragged onto my sketch window). I've been able to import some classes from this jar file, but I'm getting UnsatisfiedLinkError: no red5streaming in java.library.path.

Im getting the same error when I create the sketch using Eclipse, new Processing Project....

Can anyone help me resolve this?

thank you stf

How to make the webcam capture window go away or put images over it

$
0
0

I'm using a webcam for the beginning of my project, but after a while I want to clear the screen and start a whole new page. I can probably do this by covering up the screen with a big white rectangle, however, nothing will cover up the webcam window. The camera part of my code looks like this:

String[] cameras = Capture.list(); cam = new Capture(this, cameras[000]); cam.start();

and then

void draw() { if (cam.available() == true) { cam.read(); }

Since it says if(cam.available() == true), I tried to set cam.available to false, but even that wouldn't work, giving the error, "the field capture.available is not visible." I'm very desperate.

As an alternative, does anyone know a way to make different pages, so when you click a button, it takes everything you've already done away completely? I've looked into it a lot, and found people saying setting the background(255) at the beggining of draw, or doing multiple draws, but I couldn't get it to work. I also tried the redraw() and clear() functions without any success.

PLEASE help


Please help me before the 09/05/16 !

$
0
0

hey i have some problem with this program. When i want to jump it's make a strange thing. Can you help me with this ?

`Camera worldCamera; int appuye=0; int reappuye=0; int montee=0; int Yp=0; int Pg=0; int Yb=210; int xb=20; int deplacementB=1; void setup(){ size(400,400); worldCamera = new Camera(); ellipse(xb,Yb,10,10);

}

void draw(){ background(255); /PImage background = loadImage("bg_campagne.jpg"); image(background,-xb,-50);/ translate(-worldCamera.pos.x, -worldCamera.pos.y); worldCamera.draw(); fill(255,0,0); MAP(); Redessiner_Tout();

//déplacement de la balle if (appuye==1){ if(reappuye==0){ reappuye=1; montee=1; Yp=0; }else{ if(montee==1 && reappuye==1 && Yp==0){ Pg=Pg+1; Yb=Yb-(Pg/Pg); }else{ if(Pg==50){ montee=0; Pg=0; appuye=0; }else{ if(Yp!=0){ Yb=Yp; reappuye=0; }else{ Yb=Yb-1; }}}}} //fin déplacement }

void MAP (){ plateforme(0,200,50,10); plateforme(80,160,50,10); plateforme(160,120,50,10); plateforme(240,80,50,10); plateforme(280,120,50,10); plateforme(320,160,100,10); plateforme(440,120,50,10); plateforme(520,80,50,10); plateforme(600,80,100,10); plateforme(720,80,100,10); plateforme(840,120,50,10); plateforme(880,160,100,10); plateforme(1000,320,200,10); plateforme(1200,280,50,10); plateforme(1280,240,50,10); plateforme(1360,200,50,10); plateforme(1440,160,100,10); plateforme(1560,160,50,10); plateforme(1640,160,50,10); plateforme(1720,160,50,10); plateforme(1760,200,50,10); plateforme(1800,240,50,10); plateforme(1840,280,100,10); plateforme(1960,240,50,10); plateforme(2040,200,50,10); plateforme(2120,160,50,10); plateforme(2200,120,200,10); plateforme(2360,80,50,10);

} void plateforme(int x,int y,int h,int l){ rectangle(x,y,h,l); physique(x,y,h,l); }

void rectangle(int x,int y,int h,int l){ rect(x,y,h,l); }

int physique(int x,int y,int h,int l){ Yp=y-10; return Yp; }

class Camera { PVector pos; Camera() { pos = new PVector(0,0); }

void draw() { xb=xb+2; pos.x = xb-20; } } void Redessiner_Tout() {

fill(255); ellipse(xb,Yb,15,15); fill(255);
} void keyPressed(){//SAUT if (key ==' '){ appuye = 1;}}

` PS: sorry for my bad english i'm french ;)

MIDIBus on 64-bit OSX 10.11.3: Errors

$
0
0

I am currently trying to run one of the example codes for MIDIBus on a 64-bit OS X machine, and I run across this error:

"A library relies on native code that's not available. Or only works properly when the sketch is run as a 32-bit application."

The error rises specifically from this line:::

MidiBus.list();

Does anyone know how to resolve the situation? Or pointers on some other MIDI libraries that have been known to work on a 64-bit environment if that is the problem?

Thanks in advance!

Processing.net launch Client running on a thread

$
0
0

Hello,

I'm trying to improve the performance of a program using threads for the development of the heaviest tasks.

However, I have problems with this code, and I can´t find a solution.

What I can do?

import processing.net.*;


Client myClientC;

public class ClientThread extends Thread {


    public ClientThread(String str) {
        super(str);
    }
    public void run() {
      try{println("OK");
      Client myClientC = new Client(this, "192.168.1.88" , 6025);
      }catch(Error e){}
    }
}
void setup(){
        ClientThread AAA = new ClientThread("ClientThread 1");
        AAA.start();
     }

void draw()
{
}

How to send an array trought the network ?

$
0
0

Everything is in the question I can't find a proper way to do it.

Thanks for answering !

How to play a video using keyPressed etc.?

$
0
0

Hi. I am very very new to Processing. I am working on a project that involves Makey Makey, and I need to figure out how to make a video play smoothly using keys or a mouse. I am using keyPressed now for this, but the video comes out all twitchy, probably because you have to hold the key for the whole duration of the movie in order for it to play. Is there a better way to do it? I was thinking that mouseClicked or keyReleased or keyTyped would be better for this purpose, but I am not sure how to do it. Anyway, here is my code:

import processing.video.*;
Movie myMovie1, myMovie2, myMovie3;
boolean playMovie1=true;
boolean playMovie2=false;
boolean playMovie3=false;



void setup()
{
  size (displayWidth, displayHeight);
  background (0);


 myMovie1 = new Movie(this, "1.mp4");

 myMovie2 = new Movie(this, "2.mp4");

 myMovie3 = new Movie(this, "3.mp4");

}

void draw(){
background(0);
if(playMovie1==true){

myMovie1.play();
image(myMovie1,0, 0);
if(myMovie1.time()>=myMovie1.duration()){
myMovie1.stop();
playMovie1=false;

playMovie2=true;
}
}




if(playMovie3==true){

myMovie3.play();
image(myMovie3,0,0);
if(myMovie3.time()>=myMovie3.duration()){
myMovie3.stop();
playMovie3=false;
}
}
}


void movieEvent(Movie m){
m.read();
}

void keyPressed()

{

// PRESS LEFT OR RIGHT AFTER FIRST VIDEO
  if ((keyCode == RIGHT) || (keyCode == LEFT))

{
 if(playMovie2==true){

myMovie2.read();
myMovie2.play();
image(myMovie2,0,0);
if(myMovie2.time()>=myMovie2.duration()){
myMovie2.stop();
playMovie2=false;
playMovie3=true;
}}


 }}

Cannot find SMT (Simple Multi-Touch) Toolkit

$
0
0

Hi, well, as the topic says, I was looking for the source code on the GitHub repository, but I'm afraid that the page is not found, also tried from another pages and same result. I dunno if someone of you may have that source code and its proper documentation, or a repository that has it will be more than enough.

Those were both the links I remember searching: https://github.com/vialab/SMT.html http://vialab.science.uoit.ca/smt/SMT.zip

Thanks in advance, greetings.

How To Put Admob In the Sketch?

$
0
0

Hello, I want to know how to put ADMOB in processing sketch. any help would be nice. Thanks in advance.


Movie playback in Linux Ubuntu 16.04

$
0
0

Hello there.

I'm trying to use the movie examples, but I can't get it to work. I had similar problems when using capture, but installing some libraries related and from gstreamer, I managed it to work. The same is not happening in what regards "Movie". I've found some posts in different forums about this same issue and all were pointing to the installation of libraries, which I did, but no luck so far.

I'm running Ubuntu Studio 16.04. I'm not getting any errors, which make difficult to locate what exactly is not working.

I appreciate any directions given, and if somebody out there is having the same problems, say hello and maybe we can try to find a solution together.

best regards, Gil

How can I use selectInput() in draw()?

$
0
0

Hi, I'm trying to open the File Selection window with a controlp5 button in draw() and choose an image. When I choose my image and I open it double-clicking the image, it appears in the program normally, but when I select the image and press "Open" or "Cancel" int he File Selection window, another window of selection appears again and again. Please I need help :/

Here is my code:

` import controlP5.*;

ControlP5 cp5;

PImage image; String file,pass;

void setup(){ size(1300,720);

cp5 = new ControlP5(this);

cp5.addButton("Open") .setValue(0) .setPosition(1000,100) .setSize(70,30) ; }

void draw(){

if (cp5.get(Button.class, "Open").isPressed()){ pass = "open"; file = "none"; selectInput("Select a file to process:", "fileSelected"); interrupt(); if (file != null && file != "nothing"){ image = loadImage(file); } else{ image = createImage(850,650,RGB); for (int i = 0; i < image.pixels.length; i++) { image.pixels[i] = color(0, 0, 0); } image.updatePixels();

}

}

if (pass == "open"){

image(image,0,0,800,600);

}

}

void fileSelected(File selection) { if (selection == null) { //println("Window was closed or the user hit cancel."); file = "nothing"; } else { //println("User selected " + selection.getAbsolutePath()); file = selection.getAbsolutePath(); } }

void interrupt() { while(file == "none") { noLoop(); } loop(); } `

cellnoise Library still around?

$
0
0

Hi there, I'm trying to locate the cellnoise lib, but had no luck so far. I want to use it but am not able to find a download location. It's not mentionend on processing.org / libs anymore and the download links are stale. Any hint is welcome. Thanks for your time and effort. Thanks. -Stefan

Problem with movie freezing when using movie.jump()

$
0
0

Hi, I created a sketch that makes my movie jump based on a list of time positions. Sometimes the transition is fast, but sometimes the movie freezes for a while. Here is the result:

Is there any way to reduce this delay?

Here is part of the code:

void draw() {
  background(0);

  if (!isPlaying) {
    currSub = subs.get(subIndex);
    myMovie.jump(currSub.start);
    isPlaying = true;
  }

  image(myMovie, 0, 0, width, height);

  //Draw subtitle
  text(currSub.speech, width/2, height - 25);

  //Check subtitle ending
  if (myMovie.time() >= currSub.end) {
    subIndex ++;
    isPlaying = false;
  }
}

// Called every start a new frame is available to read
void movieEvent(Movie m) {
  m.read();
}

thanks,

is this dead? (voce library speech recognition)

Viewing all 2896 articles
Browse latest View live