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

[controlP5]Two ScrollableLists

$
0
0

Hi. I'm in a project that involves two scrollableLists. I need the result of the first list to determine what will the results of the second one will be. the full congressmen list in on a cvs file, with name, party,origin state and vote status.

actually. i'm doing a parliamentary vote map. so the first sL is a state lists(27 states). the second scrollable list should be the state congressmen. so if i choose state 6 on the first, it should list all that state's congressmen on the second sL. actually i can retrieve all the data from the table and read it correctly with a state filter. what i cannot do is add these names to the second list.

how can do that?

void setup(){

    cp5 = new ControlP5(this);

        cp5.addScrollableList("dropdown")
          .setPosition(20, 40)
            .setCaptionLabel("ESTADO")
              .setSize(60, 200)
                .setItemHeight(25)
                  .setBarHeight(30)
                    .addItems(estado)
                      .setType(ScrollableList.LIST)
                        ;


        cp5.addScrollableList("dropdown2")
          .setPosition(100, 40)
            .setCaptionLabel("DEPUTADO")
              .setSize(300, 150)
                .setItemHeight(25)
                  .setBarHeight(30)
                      .setType(ScrollableList.LIST)
                        ;
   }

     void dropdown(int n) {
        String estado=cp5.get(ScrollableList.class, "dropdown").getItem(n).get("name").toString();
        println(estado);

        cp5.get(ScrollableList.class, "dropdown2").clear();

        for (TableRow row : table.findRows (estado, "estado")) {
          int depId=row.getInt("id");
          String depNome=row.getString("nome");
          String depEstado=row.getString("estado");
          String depPartido=row.getString("partido");
          println(depId + " " + depNome + ": " + depEstado+"|"+depPartido);

        }
       // cp5.get(ScrollableList.class,"dropdown2").addItems(nomes);
      }

How to make keyCode == ENTER update string?

$
0
0

I have my programme here, where you can see I have a string called "S", and a void Get Temperature. At the bottom where keypresses are processed, it has an else If statement with ENTER. I want it so that when you press enter, it updates the string (s) to whatever you have typed, and then load it into the "SetAddress" field. How would I go about this?

    import com.temboo.core.*;
    import com.temboo.Library.Yahoo.Weather.*;
    import ddf.minim.*;
    AudioPlayer player;
    Minim minim;
    PImage bg;
    String myText;
    PFont Bold;
    PFont Thin;
    TembooSession session = new TembooSession("goldsmiths-c", "myFirstApp", "CNgLbwqnqzGdsnk6wHXPfAnQNSmV0Fmr");
    String s = "London";
    int prev = frameCount;
    //KeyPressed KeyPressed = new KeyPressed();

    void setup() {
      size(960, 540);
      bg = loadImage("mountains.jpg");
      minim = new Minim(this);
      player = minim.loadFile("song.mp3");
      player.play();
      player.loop();
      runGetTemperatureChoreo();
      Bold = createFont ("TTFirsBlackItalic.otf", height);
      Thin = createFont ("TTFirsThin.otf", height);
      frameRate (10);
    }

    void draw() {
      background(bg);
      fill (0);
      textFont (Bold);
      textSize (48);
      fill(255, 255, 255);
      text(myText, 10, 390);
      fill(255, 255, 255);
      textFont (Thin);
      textSize (48);
      text(s, 10, 500);
      print(mouseY);
    }

    void runGetTemperatureChoreo() {
    loop();
      GetTemperature getTemperatureChoreo = new GetTemperature(session);

      getTemperatureChoreo.setAddress(s);
      getTemperatureChoreo.setUnits("c");

      GetTemperatureResultSet getTemperatureResults = getTemperatureChoreo.run();
      myText = (s) + (getTemperatureResults.getTemperature() + ("°c"));
      print(getTemperatureResults.getTemperature());
    }
    void keyPressed()
    {
      if (keyPressed && prev <= frameCount-10) { //If a key is being pressed, and the security/delay is fine with it
        prev = frameCount; //re-Init the clock
        if (keyCode == BACKSPACE) { //Delete a char!
          if (s.length() > 0) {
            s = s.substring(0, s.length()-1);
          }
        } else if (keyCode == DELETE) {
          s = "";
        } else if (keyCode == ENTER && s.length() != 0) {
          s += key;
        } else if (keyCode != SHIFT && keyCode != CONTROL && keyCode != ALT && s.length() < 20) { //It's an ok char, add it to the String
          s += key;
        }
      }
    }

error when adding sound

$
0
0

hi, i got this error when i added the sound file stuff and i get this error: RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (hw:0,3), Device or resource busy.

terminate called after throwing an instance of 'std::runtime_error' what(): RtApi::openStream: a non-NULL output StreamParameters structure cannot have an nChannels value less than one. Could not run the sketch (Target VM failed to initialize). For more information, read revisions.txt and Help → Troubleshooting.

I don't know what is means so please help

this is the code:

import processing.sound.*; SoundFile file;

void setup() { size(800, 600); //fullScreen(1); keysIn = new ArrayList ();

myball = new Ball();

player1 = new Player(); player2 = new Player();

player1.PlayerY = height / 2; player2.PlayerY = height / 2;

player1.points = 0; player2.points = 0;

file = new SoundFile(this, "song.mp3"); // the song IS called song.mp3 file.play(); }

void draw() { background(0); println(keysIn);

myball.run();

myball.bounce(player1.PlayerY, player2.PlayerY);

player1.playerNo = 1; player1.run();

player2.playerNo = 2; player2.run();

player1.Decpoints(myball.ballX); player2.Decpoints(myball.ballX);

textSize(100); text(player1.points, 40, 100); text(player2.points, 40, 700); }

void keyTyped() { if (!keysIn.contains(key)) { keysIn.add(key); } }

void keyReleased() { if (keysIn.contains(key)) { keysIn.remove(new Character(key)); } }

if you want me to post the rest of the code (and 2 other tabs) please say so

PS: it worked before i added the sound file PPS: im in processing 3

ControlP5: ScrollableList getValue()

$
0
0

Hi,

I want to read from my draw() what's the value of the selected item in a ScrollableList object. I don't want to read after changing the item selection. I want to read the selected item from the draw().

That works, but I guess there is a easier way. It's fine with 1 scrollableList, but it doesn't look very nice with 20 scrollableList.

void draw() {

 selectedItem = (int)cp5.get(ScrollableList.class, "myScroll").getValue();
  int filterNameID = (int)cp5.get(ScrollableList.class, "myScroll").getItem(selectedItem).get("value");

}

Any suggestion?

Thanks.

How to access toxiclibs voronoi center points

$
0
0

Hi, beeing a complete rooky when it comes to processing I wanted to try out the toxiclibs library. I would like to make something like this (moving voronoi points) but I don't know how to access the position of a point I add to the mesh and change its position.

Help much appreciated ;) .

ControlP5 dropdownList question

$
0
0

hi, i havent used this library since processing 1.5.1 and i could use the dropdown list inside void draw(), but i cannot figure out how to do it with 2.0...

this is the code from example with the dropdownlist

import controlP5.*;

ControlP5 cp5;

DropdownList d1, d2;

int cnt = 0;

void setup() {
  size(700, 400, P3D);

  cp5 = new ControlP5(this);
  // create a DropdownList
  d1 = cp5.addDropdownList("myList-d1")
    .setPosition(100, 100)
      ;

  customize(d1); // customize the first list

  // create a second DropdownList
  d2 = cp5.addDropdownList("myList-d2")
    .setPosition(400, 100)
      .setSize(200, 200)
        ;

  customize(d2); // customize the second list
  d2.setIndex(10);
}


void customize(DropdownList ddl) {
  // a convenience function to customize a DropdownList
  ddl.setBackgroundColor(color(190));
  ddl.setItemHeight(20);
  ddl.setBarHeight(15);
  ddl.captionLabel().set("dropdown");
  ddl.captionLabel().style().marginTop = 3;
  ddl.captionLabel().style().marginLeft = 3;
  ddl.valueLabel().style().marginTop = 3;
  for (int i=0;i<40;i++) {
    ddl.addItem("item "+i, i);
  }
  //ddl.scroll(0);
  ddl.setColorBackground(color(60));
  ddl.setColorActive(color(255, 128));
}



void keyPressed() {
  // some key events to change the properties of DropdownList d1
  if (key=='1') {
    // set the height of a pulldown menu, should always be a multiple of itemHeight
    d1.setHeight(210);
  }
  else if (key=='2') {
    // set the height of a pulldown menu, should always be a multiple of itemHeight
    d1.setHeight(120);
  }
  else if (key=='3') {
    // set the height of a pulldown menu item, should always be a fraction of the pulldown menu
    d1.setItemHeight(30);
  }
  else if (key=='4') {
    // set the height of a pulldown menu item, should always be a fraction of the pulldown menu
    d1.setItemHeight(12);
    d1.setBackgroundColor(color(255));
  }
  else if (key=='5') {
    // add new items to the pulldown menu
    int n = (int)(random(100000));
    d1.addItem("item "+n, n);
  }
  else if (key=='6') {
    // remove items from the pulldown menu  by name
    d1.removeItem("item "+cnt);
    cnt++;
  }
  else if (key=='7') {
    d1.clear();
  }
}

void controlEvent(ControlEvent theEvent) {
  // DropdownList is of type ControlGroup.
  // A controlEvent will be triggered from inside the ControlGroup class.
  // therefore you need to check the originator of the Event with
  // if (theEvent.isGroup())
  // to avoid an error message thrown by controlP5.

  if (theEvent.isGroup()) {
    // check if the Event was triggered from a ControlGroup
    println("event from group : "+theEvent.getGroup().getValue()+" from "+theEvent.getGroup());
   if (theEvent.getGroup().getValue()==1) {
      ellipse(100, 100, 100, 100);
    }
    else if (theEvent.getGroup().getValue()==2) {
      rect(200, 200, 200, 200);
    }
  }

  else if (theEvent.isController()) {
    println("event from controller : "+theEvent.getController().getValue()+" from "+theEvent.getController());
  }
}

void draw() {
  background(128);
}

my question is this: inside the controlEvent function (lines 94-98), how to i make the circle or the rect or whatever i want to draw to stay until i choose something else from the list, here it gets drawn really fast and disappears

thanks!

Leap motion library - tool tracking not working?

$
0
0

Hi, I am using this leap motion library https://github.com/voidplus/leap-motion-processing

I tested with example provided in the library, everything works well, but it does not track tools.

I tried many different objects like pen, straw, chopstick, brush and such, but no data from it.

Does anyone have similar trouble with me?

This is the code.

import de.voidplus.leapmotion.*;

LeapMotion leap;

void setup(){ size(800, 500, OPENGL); background(255); // ...

leap = new LeapMotion(this); }

void draw(){ background(255); // ... int fps = leap.getFrameRate();

// ========= HANDS =========

for(Hand hand : leap.getHands()) {

// ----- BASICS -----

int     hand_id          = hand.getId();
PVector hand_position    = hand.getPosition();
PVector hand_stabilized  = hand.getStabilizedPosition();
PVector hand_direction   = hand.getDirection();
PVector hand_dynamics    = hand.getDynamics();
float   hand_roll        = hand.getRoll();
float   hand_pitch       = hand.getPitch();
float   hand_yaw         = hand.getYaw();
boolean hand_is_left     = hand.isLeft();
boolean hand_is_right    = hand.isRight();
float   hand_grab        = hand.getGrabStrength();
float   hand_pinch       = hand.getPinchStrength();
float   hand_time        = hand.getTimeVisible();
PVector sphere_position  = hand.getSpherePosition();
float   sphere_radius    = hand.getSphereRadius();




  for(Tool tool : leap.getTools())
  {


    // ----- BASICS -----

    int     tool_id           = tool.getId();
    PVector tool_position     = tool.getPosition();
    PVector tool_stabilized   = tool.getStabilizedPosition();
    PVector tool_velocity     = tool.getVelocity();
    PVector tool_direction    = tool.getDirection();
    float   tool_time         = tool.getTimeVisible();


    // ----- DRAWING -----
     println(tool_position);
     tool.draw();


    // ----- TOUCH EMULATION -----

    int     touch_zone        = tool.getTouchZone();
    float   touch_distance    = tool.getTouchDistance();

    switch(touch_zone){
      case -1: // None
        break;
      case 0: // Hovering
        // println("Hovering (#"+tool_id+"): "+touch_distance);
        break;
      case 1: // Touching
        // println("Touching (#"+tool_id+")");
        break;
    }
  }

}

// ========= DEVICES =========

for(Device device : leap.getDevices()){ float device_horizontal_view_angle = device.getHorizontalViewAngle(); float device_verical_view_angle = device.getVerticalViewAngle(); float device_range = device.getRange(); }

}

// ========= CALLBACKS =========

void leapOnInit(){ // println("Leap Motion Init"); } void leapOnConnect(){ // println("Leap Motion Connect"); } void leapOnFrame(){ // println("Leap Motion Frame"); } void leapOnDisconnect(){ // println("Leap Motion Disconnect"); } void leapOnExit(){ // println("Leap Motion Exit"); }

Mapping color/tint values to ControlP5 slider

$
0
0

Hi folks, Novice user here, just with a simple question. I am working on a program that can take a picture of a car using PImage, and then manipulate the color of it using a controlP5 slider. I have been able to play with the tint, but can't seem to get the slider to change it. Say the original image is a blue car; I want to be able to make it red, green,etc.

Thanks!

Here is my code:

PImage img; PImage dest; ControlP5 cp5; int sliderValue = 127; int textValue = 0;

void setup() { background(255, 255, 255); noStroke(); colorMode(HSB, 100); for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { stroke(i, j, 100); point(i, j); } }

size(960, 540); img = loadImage("car1.png"); strokeWeight(10); cp5 = new ControlP5(this); cp5.addSlider("slide", 0, 255, sliderValue, 100, 50, 100, 20); cp5.addTextfield("text", 100, 100, 100, 20); }

void draw() { textSize(25); { fill(0); text("Real-Time Tuning", 370, 60); } fill(1000); image(img, 0, 0); fill(sliderValue); stroke(textValue); }

public void slider(int val) { sliderValue = val; }

public void text(String val) { textValue = Integer.parseInt(val); }


Hello, I am having troubles with my image popping up right away. Also need help with another issue.

$
0
0

I am having troubles with my image popping up right away. I was trying to make it where once you press spacebar the image pops up for 10 seconds then goes away after. Also, I wanted to add a timer using the controlP5 library, but I don't know where to place it in my code. I don't want it following the mouse I just want it to be above the drawing area and have a button to activate it and it turns off once it hits 1:30 seconds. Here is my code so far below:

import controlP5.*;
ControlP5 cp5;
int brushSize = 5;
boolean brushType = false;
boolean eraserType = false;
color c = color(128, 0, 255);
ControlTimer t;
Textlabel l;
PImage Celtic_Pattern;

/*******************************/
void setup() {
size(800, 800);
frameRate(60);

cp5 = new ControlP5( this );
cp5.addColorWheel("c", 596, 3, 200 ).setRGB(c);
noStroke();
background(0, 255, 255);
t = new ControlTimer();
l = new Textlabel(cp5,"--",100,100);
t.setSpeedOfTime(1);
Celtic_Pattern = loadImage("Celtic_Pattern.png");

//Below is the drawing area black border.
stroke(0);
strokeWeight(8);
rect(10, 220, 780, 570);
rect(600, 260, 170, 180);
fill(255);

PFont font;
font = loadFont("UrbanClass-10.vlw");

//Instructions are below in this code.
String s = "Your objective is to complete the following drawing in 1 minute 30 seconds. If you don't finish then restart and try again! This is only a beta. Draw freely too if you just want to create a cool image of your own.";
fill(50);
text(s, 10, 10, 400, 200); // Text wraps within text box

//Below is "Draw Here!" inside of rect.
textFont(font, 13);
fill(0);
text("Draw Here!", 360, 240);
text("Draw this image below!", 595, 240 );
noStroke();
noLoop();
}
/*******************************/

void draw() {

l.setValue(t.toString());
l.draw(this);
l.setPosition(mouseX, mouseY);

if (keyPressed == true) {
if (key == ' ') {

image(Celtic_Pattern, 605, 265, 160, 170);
}
}
println(mouseX + " " + mouseY);
if ( mouseX < 780 && mouseX > 21 )
if ( mouseY > 235 && mouseY < 780 ) {

if (brushType) {
fill(c); // Call fill() before drawing so the previous frame's fill() doesn't overlap.
ellipse(mouseX, mouseY, brushSize, brushSize);
} else if (eraserType) {
fill(255);
ellipse(pmouseX, mouseY, brushSize, brushSize);
}
}
}
/*******************************/
void mousePressed() {

if (mouseButton == RIGHT) {
eraserType = true;
} else if (mouseButton == LEFT) {
brushType = true;
}
loop();
}


/*******************************/
void mouseReleased() {
eraserType = brushType = false;
noLoop();
}


/*******************************/
void mouseWheel(MouseEvent event) {
int g = int(event.getCount());
if (g < 0) {
if (brushSize >= 1)
brushSize += g;
println(g + " -- " + brushSize);
} else {
brushSize += g;
println(g + " ++ " + brushSize);
}
}

void keyPressed() {
t.reset();
}

how to combine two different codes together. webcam and ellipses

$
0
0

I am trying to make the the wave that I have follow my face on openCV face detector but i can't seem to rearrange it so it works. right now it works with just the wave following the mouse but how do I make it follow my face on my webcam instead of the mouse. how do i rearrange it so it works? any help would be very much appreciated! this is the code I have right now:

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

Capture video;
OpenCV opencv;
// creating the wave -> (ellipses transform into wave as it grows and dies
class Wave {

  PVector loc;
  int farOut;

  Wave() {
    loc = new PVector();
    loc.x = mouseX;
    loc.y = mouseY;


    farOut = 1;

    //colour stroke on wave set on random so it flashes.
    stroke(random(255), random(255), random(255));
  }

  void update() {
    farOut += 1;
  }
  void display() {
    ellipse(loc.x, loc.y, farOut, farOut);
  }

  boolean dead() {

    if(farOut > 90) {
      return true;
    }
    return false;
  }
}
//array list of waves
ArrayList<Wave> waves = new ArrayList<Wave>();

void setup() {
  size(640, 480);
  video = new Capture(this, 640/2, 480/2);
  opencv = new OpenCV(this, 640/2, 480/2);
  //dectating just the face
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
 ellipseMode(CENTER);
  video.start();

}

void draw() {
  scale(2);
  opencv.loadImage(video);
  image(video, 0, 0 );

  fill(255, 255, 255, 50);
  noStroke();
  //face detector code with openCV
  Rectangle[] faces = opencv.detect();
  println(faces.length);

  for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);
    ellipse(faces[i].x, faces[i].y, 10, 10);

 Wave w = new Wave();
    //array list -> creating new waves
    waves.add(w);
  }

  //run through each of the waves
  //wave size will grow
  for(int i = 0; i < waves.size(); i ++) {
    //show waves - > each wave updated and displayed
    waves.get(i).update();
    waves.get(i).display();

   //kill the wave
    if(waves.get(i).dead()) {
      waves.remove(i);
    }
  }
}

void captureEvent(Capture c) {
  c.read();
}

Tracing shadow image when using peasyCam

$
0
0

Whenever I use peasyCam or a slider function there is an unwanted "ghost" image that follows my actual. Here I have made a simple box, but there is a "ghost" box that trails it. How can I fix this issue? Duplicate Example import peasy.*; import peasy.org.apache.commons.math.*; import peasy.org.apache.commons.math.geometry.*; import peasy.test.*; import controlP5.*; import shapes3d.*; import shapes3d.animation.*; import shapes3d.utils.*; ControlP5 jControl; PeasyCam cam;

void setup(){

size(600,600,OPENGL);

background(0); cam = new PeasyCam(this, 100);

cam.setMinimumDistance(50); cam.setMaximumDistance(500); } void draw(){

lights();

fill(255);

translate(300,300,0);

box(10); }

Blob detection

$
0
0

I was just wondering if it is possible to use blob detection to trigger a key board press. so if my hand went over to a certain part of the screen where i want it to correlate to the letter "w" for example it signals that "w" was pressed on the keyboard?

i have downloaded the blob detection library but im not to sure how to use it what i want to do is have 4 different buttons so when blob detection picks up the blob it that specific area it would either play a video or signal a keyboard press to play a video in resolume?

How to use the video library in Eclipse

$
0
0

I am trying to Processing 3.0.2 with the video library in Eclipse on Osx with little success.

I have added the gstreamer-java.jar, jna.jar and video.jar to the build path (as well as the core and OpenGL jars) and have copied the dynamic library files (.dylib) files to the same folder as gstreamer-java.jar but I get this error

Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: Could not load library: gstreamer
    at org.gstreamer.lowlevel.GstNative.load(GstNative.java:53)
    at org.gstreamer.lowlevel.GstNative.load(GstNative.java:43)
    at org.gstreamer.Gst.(Gst.java:101)
    at processing.video.Video.initImpl(Unknown Source)
    at processing.video.Video.init(Unknown Source)
    at processing.video.Movie.initGStreamer(Unknown Source)
    at processing.video.Movie.(Unknown Source)
    at quiz.QuizTest_01.setup(QuizTest_01.java:32)

I already found this on the forum but it didn't work for me.

Any ideas?

Myo + Processing holding movement

$
0
0

Hello guys, I'm trying to control a 3D shape using Myo armband and I don't know how to make what I want. Basically I want to move left the 3D shape using wave-in movement. For the moment I made it move as in the direction I want with a given distance, but I want it to be smoother. I want it to move progressively pixel by pixel while I'm holding the "wave-in" movement.

How to continuously search for a twitter hashtag in Processing

$
0
0

Hi all, I am working on a project that requires Processing to continuously search for twitter hashtag. I've figured out how to search for multiple hashtags at one time but am still confused with how to modify the code below to meet my need. Anyone can help? Much thanks!

    import twitter4j.conf.*;
    import twitter4j.api.*;
    import twitter4j.*;
    import java.util.*;
    import ddf.minim.*;
    float z = 0;
    float a = 0;
    PImage bg;
    float theta1 = PI/2;
    String name = "";
    String msg = "";
    boolean stopr = true;
    PImage img;

    ConfigurationBuilder cb;
    Query query1;
    Query query2;
    Query query3;
    Query query4;
    Twitter twitter;
    AudioPlayer player;
    Minim minim;

    void setup() {
      size(508, 512);
      img = loadImage("");
      imageMode(CENTER);
      minim = new Minim(this);
      player = minim.loadFile("", 1024);
      player.play();
      player.loop();


      cb = new ConfigurationBuilder();      //Acreditacion
      cb.setOAuthConsumerKey("");
      cb.setOAuthConsumerSecret("");
      cb.setOAuthAccessToken("J");
      cb.setOAuthAccessTokenSecret("");

      twitter = new TwitterFactory(cb.build()).getInstance();
      queryTwitter();
    }



    void queryTwitter() {
      //Search for four hashtags on Twitter
      query1 = new Query("#nyu");
      query2 = new Query("#nyc");
      query3 = new Query("#acbuilding");
      query4 = new Query("#Inthecity");

      query1.setCount(1);
      query2.setCount(1);
      query3.setCount(1);
      query4.setCount(1);

      //Start searching
      try {
      QueryResult result1 = twitter.search(query1);
      QueryResult result2 = twitter.search(query2);
      QueryResult result3 = twitter.search(query3);
      QueryResult result4 = twitter.search(query4);

      //Get a list of data from Twitter
       ArrayList tweets1 = (ArrayList) result1.getTweets();
       ArrayList tweets2 = (ArrayList) result2.getTweets();
       ArrayList tweets3 = (ArrayList) result3.getTweets();
       ArrayList tweets4 = (ArrayList) result4.getTweets();

      //Confirm if
      for (int i = 0; i < tweets1.size(); i++) {
        Status t = (Status) tweets1.get(i);
        User user = t.getUser();
        name = user.getName();
        //boolean a = boolean(name);
        msg = t.getText();
        //boolean b = boolean(msg);
        println(name + ": " + msg);
    }


      for (int i = 0; i < tweets2.size(); i++) {
        Status t = (Status) tweets2.get(i);
        User user = t.getUser();
        name = user.getName();
        //boolean c = boolean(name);
        msg = t.getText();
        //boolean d = boolean(msg);
        println(name + ": " + msg);
    };

    }

      catch (TwitterException te) {
        println("Couldn''t connect: " + te);
      }
    }


    void draw(){

        z = a + z;

        bg = loadImage("clock.jpg");
        background(bg);
        image(img, width/2 - img.width/2, height - img.height/4);
        //strokeWeight(30);
        //stroke(255, 0, 0);
        pushMatrix();
        translate(width/2, height/2);
        rotate(z);
        image(img, 0, 0);
        //line(0, 0, 0, -height/2);
        popMatrix();

        if (name != "" && msg != "") {
        stopr = false;
        } else {
        stopr = true;
        }

        if (stopr == false) {
          a = 0.01;
        }

       if (stopr == true) {
         a = 0;
       }

    }

How to Display Images based on frequency?

$
0
0

Is there a way to display images based on how high the frequency the program is detecting? Like if the program detects a frequency of around 1000 Hz, it will display one image representing an emotion, but around 500 a different image is displayed instead. I'm also working with an array for 4 images so far.

Peasycam incompatible with transparency?

$
0
0

Sometimes I get transparency working but most times I don't ... is that too be expected!?

How does one put sound from a live site into an audio visualizer.

$
0
0

As of now my sound is just coming from a file on my computer but I would like to load live sounds from a site?

G4P GWindow noLoop?

How can apply two filters to an audio input?

$
0
0

I want to have amplitude values from highpass filtered and from a lowpass filtered audio signal so i can work with both.

import processing.sound.*;

//i made two signal streams to give each filter its own audio signal (which is actually unnecessary i think)
//i did this just to be sure:
Amplitude ampHP;
Amplitude ampLP;
AudioIn inHP;
AudioIn inLP;
LowPass lP;
HighPass hP;
//an index getting increased each frame in draw() function for visual stuff:
int i = 0;
int[][] randArr = new int[3][3];
//variables for containing the volume level value:
int volHP;
int volLP;

void setup(){
  size(800, 800);
  background(0);
  frameRate(30);

  //lowpass:
  ampLP = new Amplitude(this);
  inLP = new AudioIn(this, 0);
  lP = new LowPass(this);

  inLP.start();
  lP.process(inLP, 80);
  ampLP.input(inLP);
  lP.stop();

  //highpass:
  ampHP = new Amplitude(this);
  inHP = new AudioIn(this, 0);
  hP = new HighPass(this);

  inHP.start();
  hP.process(inHP, 500);
  ampHP.input(inHP);

}

void draw(){
  //getting the values from the filtered streams:
  volHP = int(ampHP.analyze()*500);
  volLP = int(ampLP.analyze()*500);
  println(volHP, volLP); //for debugging. it looks like nothing at all happens to the audio

  //fancy stuff happening below. but not important for my question..
  background(0);
  translate(height/2, height/2);
  noFill();
  stroke(255);

  for(int j = 0; j < 3; j++){
    for(int k = 0; k < 3; k++){
      randArr[j][k] = int(random(10, 500)) - 250;
    }
  }

  if(volLP >= 180){
    noFill();
    strokeWeight(random(2, 50));
    for(int j = 0; j < 5; j++){
      ellipse(sin(radians(i))*height/5 + randArr[0][0]*0.7, cos(radians(i))*height/5 + randArr[0][1]*0.7, randArr[0][2], randArr[0][2]);
    }
  }

  if(volHP >= 180){
    fill(255);
  }
  strokeWeight(1);
  ellipse(0, 0, volHP, volLP);
  //sin(radians(i))*height/5
  i+=10;

}
Viewing all 2896 articles
Browse latest View live


Latest Images