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

Problem with "Sound" library

$
0
0

I'm trying to run the example in the documentation for the "Sound" library (https://processing.org/reference/libraries/sound/SoundFile.html) but I'm getting an error. I'm running v1.3.2 of the library, under Processing 3.1.1 and Windows 7 Pro. I tried both the 32-bit and 64-bit versions of Processing. The only change I made to the code was to change line 9 to point to the mp3 file on my hard drive. But when I try to open the file, I get this error message:

The constructor "SoundFile(SoundFile, String)" does not exist.

The error message doesn't make any sense, at least to me. I'm passing "this" as the first parameter, just as in the example, and a string with the full path name of the mp3 file as the second parameter. Why does it think "this" is a SoundFile?

Is the "Sound" library still working?

Here's my code, although as I said, I only changed the one line which opens the file.

import processing.sound.*;
SoundFile file;

void setup() {
  size(640, 360);
  background(255);

  // Load a soundfile from the /data folder of the sketch and play it back
  file = new SoundFile(this,"C:\\Users\\owner\\Music\\% Attac\\01 Tonino Carotone & Manu Chao - La Trampa.mp3");
  file.play();
}

void draw() {
}

Using camera within eclipse

$
0
0

Im using Camera class from video library in an eclipse project, while it works fine within that particoular project when i try to invoke camera functions from within my framework i get the warning

(javaw.exe:3840): GStreamer-WARNING **: Failed to load plugin 'C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\libgstvorbis.dll' ecc... on 30+ plugins.

Basically i got a "view" project with all view logics and some working tests and a "root" project that instantiates the view,the controller and link them togheter.

Problem is that apparently the directory from which im running the main affects some jna related property, so if i run my application from "root" project i get the above warnings and consequent fails. To test the above sentence i made a one line main in "root" project that invokes a working test in "view" project, and run the same test directly in "view" project. the first fails the second not.

What i would like to do is to keep things as are now(all the dlls in "view" project) to keep my MVC like pattern and make it work, is that possible?

Unexpected token: void()

$
0
0

Hi, I'm (really) new with processing. Can anyone help me with this code? please :) I cannot find why I get unexpected token: void() in this code:

import processing.video.*; Capture webcam; int w=400; int h=400; int pixn=w*h; int keyhits; PImage img; int i= 0

void setup() { size(w, h); webcam = new Capture(this, 400, 400); webcam.start(); loadPixels(); }

void captureEvent(Capture webcam) { webcam.read(); } void draw() { image(webcam, 0, 0); }

void keyPressed() {

if ( key == '1' ) { save("capture" + ++keyhits + ".jpg"); }

img = loadImage("capture"+keyhits+".jpg"); int x = int(img.width); int y = int(img.height); float r = red(img.pixels[i]); float g = green(img.pixels[i]); float b = blue(img.pixels[i]);

for (int i=0; i<pixn; i++) { float sumar = sumar + red(img.pixels[i]); float sumag = sumag + green(img.pixels[i]); float sumab = sumab + blue(img.pixels[i]); }

float mediar = sumar / pixn); float mediag = sumag / pixn); float mediab = sumab / pixn);

if ( key == '2' ) { fill(mediar, mediag, mediab, 255); rect(0, 0, 400, 400); save("average_color"+ keyhits + ".jpg"); } }

Problem with "Sound" library

$
0
0

I'm trying to run the example in the documentation for the "Sound" library (https://processing.org/reference/libraries/sound/SoundFile.html) but I'm getting an error. I'm running v1.3.2 of the library, under Processing 3.1.1 and Windows 7 Pro. I tried both the 32-bit and 64-bit versions of Processing. The only change I made to the code was to change line 9 to point to the mp3 file on my hard drive. But when I try to open the file, I get this error message:

The constructor "SoundFile(SoundFile, String)" does not exist.

The error message doesn't make any sense, at least to me. I'm passing "this" as the first parameter, just as in the example, and a string with the full path name of the mp3 file as the second parameter. Why does it think "this" is a SoundFile?

Is the "Sound" library still working?

Here's my code, although as I said, I only changed the one line which opens the file.

import processing.sound.*;
SoundFile file;

void setup() {
  size(640, 360);
  background(255);

  // Load a soundfile from the /data folder of the sketch and play it back
  file = new SoundFile(this,"C:\\Users\\owner\\Music\\% Attac\\01 Tonino Carotone & Manu Chao - La Trampa.mp3");
  file.play();
}

void draw() {
}

What's wrong with this 'if/if else' statement?

$
0
0

I am using the ControLP5 library to create a list box and each item in the list box has an assigned value (0.0, 1.0, 2.0, 3.0 etc).

As you can see in the if statement below, when the user clicks on an item with a certain value, a function runs. The problem is that when any of them are clicked, the function only runs for an extremely short amount of time.

My question is, how do I get the function to run indefinitely until the next else if is activated?

I'm guessing its such an easy bit of code but I cant quite figure it out.

Please see the if statement below:

    void controlEvent(ControlEvent theEvent) {

        if (theEvent.getController().getValue() == 0.0){

           drawPathToOutpatients();
        }

        else if (theEvent.getController().getValue() == 1.0){

          drawPathToRestaurant();
        }

        else if (theEvent.getController().getValue() == 2.0){

          drawPathToPharmacy();
        }

         else if (theEvent.getController().getValue() == 3.0){

          drawPathToWard1A();
        }
    }

Please see the function that is called below:

    void drawPathToOutpatients(){

      strokeWeight (3);
      dottedLine(720, 700, 720, 580);
      dottedLine(720, 580, 1080, 580);
      dottedLine(1080, 580, 1080, 670);
      dottedLine(1080, 670, 1160, 670);
      fill (0, 153, 102);
      text ("You Are Here", 690, 730);
      ellipse(720, 700, 20, 20);
      fill(0, 102, 153);
      ellipse(1160, 670, 20, 20);
      text("Outpatients", 1130, 720);
    }

Video library only working with one example

$
0
0

I'm having massive problems with the Video library, somehow the only example that works is the Mirror, not Mirror2 nor GettingStartedCapture. I'm using the latest version of Processing 3 and video library and the webcam on a Lenovo Yoga laptop. I have also tried the example code in the official documentation without success https://processing.org/reference/libraries/video/Capture.html . The camera is detected but it wont start or read.

Any ideas on what might be the problem? I'm coming from a Java background and I was really looking forward to using Processing for a computer vision project.

How to trigger video based on time

$
0
0

Hi all,

So I've been using Processing for the last couple of weeks, and have been trying to incorporate it in to my final project for University. I've so far created a working clock based on the designs of the old BBC clocks that used to play when the channels shut down for the night, and what I'm looking to do is essentially trigger a video to play at a certain time of the day (on the hour is ideal), play through, finish, return to the clock, and repeat. Now, I have a rough idea of how I could do it, but I want to see if there are any easier ways to go about this than what I was thinking.

Thanks!

Change properties of every controller of a group at once in controlP5

$
0
0

Is there an option to change properties of every controller of a Group at once? Say for example setLabelVisible(false) for every controller of a group by calling the method within the function invoked by an other controller's change event?


Is mouse over sphere in 3D?

$
0
0

I have a sphere somewhere, and its location is known. However, I'm also using PeasyCam, so a problem remains - I don't know the camera vectors. So, how to check if the mouse (or any other vector for that) is over the sphere?

My code so far-

import peasy.*;

PeasyCam cam;

float x = 0, y = 0,z = 0;

void setup(){
  size(720, 720, P3D);
  cam = new PeasyCam(this, 200);
}

void draw(){
  translate(x, y, z);
  sphere(100);//being minimalistic

  x += sin(y);//random methods, real code is different
  y += cos(z);
  z += random(1);

  println(mouseOverSphere(x, y, z, 100);
}

boolean mouseOverSphere(float posX, float posY, float posZ, float size){
  //What to do here??
}

record past 15 seconds of microphone with Minim

$
0
0

Hi everyone,

I'd like to be able to record from the microphone using minim, but with a caveat. When the user presses the record button I want to be able to save the past 15 seconds (before the user pressed a button) and the next 15 seconds (after the user pressed a button) to a file (total=30 seconds).

I thought I might be able to do it by setting the buffer to 15 seconds and then have a timer that starts when the user presses the button and when the timer finishes (after 15 seconds) the buffer is saved to a file. I've implemented it below, but I get unexpected results.

Any idea/suggestions how I can record the last 15 seconds of an input stream. I've seen it referred on the next as a "ring buffer" or a "circular buffer" because it keeps recording the last 15 seconds and overwriting things older than 15 in memory. Any ideas?

Thanks. Below is my code.

    import ddf.minim.*;
    Minim minim;
    AudioInput in;
    AudioRecorder recorder;
    Timer timer;

    void setup()
    {
      size(512, 200, P3D);

      minim = new Minim(this);

      int totalDuration = 15; //total buffer size in seconds
      in = minim.getLineIn(Minim.STEREO, 44100 * totalDuration);
      // create a recorder that will record from the input to the filename specified
      // the file will be located in the sketch's root folder.
      recorder = minim.createRecorder(in, "myrecording.wav");

      textFont(createFont("Arial", 12));
    }

    void draw()
    {
      background(0);
      stroke(255);

      if (recorder.isRecording() && timer.isFinished())
      {
        recorder.endRecord();
        recorder.save();
        println("Done saving.");
      }

      if ( recorder.isRecording() )
      {
        text("Currently recording...", 5, 15);
      } else
      {
        text("Not recording.", 5, 15);
      }
    }

    void keyPressed()
    {
      if ( key == 'r' )
      {
        // to indicate that you want to start or stop capturing audio data, you must call
        // beginRecord() and endRecord() on the AudioRecorder object. You can start and stop
        // as many times as you like, the audio data will be appended to the end of the buffer
        // (in the case of buffered recording) or to the end of the file (in the case of streamed recording).
        recorder.beginRecord();
        timer = new Timer(15000);
        timer.start();
      }
    }

class Timer {

  int savedTime; // When Timer started
  int totalTime; // How long Timer should last

  Timer(int tempTotalTime) {
    totalTime = tempTotalTime;
  }

  void start() {
    savedTime = millis();
  }

  boolean isFinished() {
    int passedTime = millis()- savedTime;
    if (passedTime > totalTime) {
      return true;
    } else {
      return false;
    }
  }
}

running teapot.pde on windows 10

$
0
0

while trying to run mputeapot i receive the error toxi.geom and toxi.processing not found thank you

Problem with my network pong

$
0
0

Hello everyone,

I want to make a pong in network but I can't understand why it doesn't work ? My architecture is : I will send the position of the bot paddle and the ball by the server to the client like this the client would display everything. And the client have to send the position of the top paddle like that the server could display everything. Sorry if my english is bad, i'm not an english native speaker. My program works if i make few modifications to play with two players on the same keyboard.

import processing.net.*;

Server server;
Client client;
String input;
int data[];

boolean gameover= false, right = false, left = false;
int topscore=0;
int bottomscore=0;
int time;
float changespeed=0;
Paddle bot;
Ball pongball;
Paddle top;

void setup()
{
  server = new Server(this, 12012); // Start a simple server on a port
  frameRate(100);
  noStroke();
  pongball= new Ball();
  bot=new Paddle();
  top=new Paddle();
  top.y=0;
  size(1000, 1000);
}

void keyPressed()
{
  if (keyCode == LEFT)  left = true;
  if (keyCode == RIGHT) right = true;
}

void keyReleased()
{
  if (keyCode == LEFT)     left = false;
  if (keyCode == RIGHT)    right = false;
}

void draw()
{
  drawMyPong();
}

void drawMyPong(){
  if (gameover==false)
  {
    background(0);
    bot.showThePaddle();
    top.showThePaddle();

    if (left==true)  bot.moveLeft();
    if (right==true) bot.moveRight();

    pongball.ballSettingInMotion();
    pongball.bounce();
    pongball.showTheBall();

    if (pongball.positionY<-8)
    {
      gameover=true;
      bottomscore++;
    }
    if (pongball.positionY>1008)
    {
      gameover=true;
      topscore++;
    }
    //send the position of the bot paddle and the position of the ball
    server.write(bot.x + " " + pongball.positionX + " " + pongball.positionY + "\n");

    // Receive data from client, position of the top paddle
    client = server.available();
    if (client != null) {
      input = client.readString();
      input = input.substring(0, input.indexOf("\n"));  // Only up to the newline
      data = int(split(input, ' '));  // Split values into an array
      //Draw the ball and the bot paddle
      top.x = data[0];

    }
  }
}

class Paddle
{
  int x, y;

  Paddle()
  {
    x=500;
    y=996;
  }

  void showThePaddle()
  {
    fill(46, 178, 253);
    rect(x, y, 120, 4);
  }

  void moveLeft()
  {
    if (x>=0)  x-=5;
  }
  void moveRight()
  {
    if (x<=880)  x+=5;
  }
}

class Ball
{
  int positionX, positionY;
  boolean up, right;

  Ball()
  {
    positionX=16;
    positionY=484;
    up=true;
    right=true;
  }

  void ballSettingInMotion()
  {
    if (up==true)     positionY=int(positionY-2-changespeed/2);
    else              positionY=int(positionY+2+changespeed/2); //up==false
    if (right==true)  positionX=int(positionX+1+changespeed);
    else              positionX=int(positionX-1-changespeed); //right==false
  }
  void bounce()
  {
    if (get(int(positionX)-8, int(positionY))!=color(0))          right=true;
    if (get(int(positionX)+8, int(positionY))!=color(0))          right=false;
    if (get(int(positionX), int(positionY)-8)==color(46, 178, 253))  up=false;
    if (get(int(positionX), int(positionY)+8)==color(46, 178, 253))
    {
      up=true;
      changespeed+=0.5;
    }
  }

  void showTheBall()
  {
    fill(255, 255, 255);
    ellipse(positionX, positionY, 22, 22);
  }
}

Here is my Client Program :

import processing.net.*;

Server server;
Client client;
String input;
int data[];

boolean gameover= false, right = false, left = false;
int topscore=0;
int bottomscore=0;
int time;
float changespeed=0;
Paddle bot;
Ball pongball;
Paddle top;

void setup()
{
  client = new Client(this, "localhost", 12012); // Start a simple server on a port
  frameRate(100);
  noStroke();
  pongball= new Ball();
  bot=new Paddle();
  top=new Paddle();
  top.y=0;
  size(1000, 1000);
}

void keyPressed()
{
  if (keyCode == LEFT)  left = true;
  if (keyCode == RIGHT) right = true;
}

void keyReleased()
{
  if (keyCode == LEFT)     left = false;
  if (keyCode == RIGHT)    right = false;
}

void draw()
{
  drawMyPong();
}

void drawMyPong(){
  if (gameover==false)
  {
    background(0);
    bot.showThePaddle();
    top.showThePaddle();

    if (left==true)  top.moveLeft();
    if (right==true) top.moveRight();

    pongball.ballSettingInMotion();
    pongball.bounce();
    pongball.showTheBall();

    if (pongball.positionY<-8)
    {
      gameover=true;
      bottomscore++;
    }
    if (pongball.positionY>1008)
    {
      gameover=true;
      topscore++;
    }
    //WITHOUT THIS PART, it goes correctly
    //send the position of the bot paddle and the position of the ball
    client.write(top.x + "\n");

    // Receive data from client, position of the top paddle
    client = server.available();
    if (client != null) {
      input = client.readString();
      input = input.substring(0, input.indexOf("\n"));  // Only up to the newline
      data = int(split(input, ' '));  // Split values into an array
      //Draw the ball and the bot paddle
      bot.x = data[0];
      pongball.positionX = data[1];
      pongball.positionY = data[2];

    }
  }
}

class Paddle
{
  int x, y;

  Paddle()
  {
    x=500;
    y=996;
  }

  void showThePaddle()
  {
    fill(46, 178, 253);
    rect(x, y, 120, 4);
  }

  void moveLeft()
  {
    if (x>=0)  x-=5;
  }
  void moveRight()
  {
    if (x<=880)  x+=5;
  }
}

class Ball
{
  int positionX, positionY;
  boolean up, right;

  Ball()
  {
    positionX=16;
    positionY=484;
    up=true;
    right=true;
  }

  void ballSettingInMotion()
  {
    if (up==true)     positionY=int(positionY-2-changespeed/2);
    else              positionY=int(positionY+2+changespeed/2); //up==false
    if (right==true)  positionX=int(positionX+1+changespeed);
    else              positionX=int(positionX-1-changespeed); //right==false
  }
  void bounce()
  {
    if (get(int(positionX)-8, int(positionY))!=color(0))          right=true;
    if (get(int(positionX)+8, int(positionY))!=color(0))          right=false;
    if (get(int(positionX), int(positionY)-8)==color(46, 178, 253))  up=false;
    if (get(int(positionX), int(positionY)+8)==color(46, 178, 253))
    {
      up=true;
      changespeed+=0.5;
    }
  }

  void showTheBall()
  {
    fill(255, 255, 255);
    ellipse(positionX, positionY, 22, 22);
  }
}

Union of algorithms from the EyeTribeProcessing library

$
0
0

How do I join the EyeTribeProcessing library's Calibration and WeightedGrid codes to a single screen

Concurrent Modification Exception trying to add objects on OSC event

$
0
0

I'm designing this generative visuals system that uses OSC data from a musician to produce these kind of abstract "asteroids" in real time. I'm running into this Concurrent Modification Exception which I'm assuming has to do with the fact that the OSC Event is another thread (or something? happening alongside my draw loop) and so maybe when iterating through my asteroid objects an asteroid is added, causing an error. I thought the synchronize trick would work, no such luck. Any help is appreciated!

Note: Just tried it with also protecting/removing the .remove() portion of the code, same error (although perhaps less frequent?)

// OSC STUFF
volatile boolean isBusy = false;

/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
    if (theOscMessage.addrPattern().equals("/peter/rhythm")) {
        if (!isBusy)
        asteroids.add(new Asteroid(0));
    }
}


// DRAW STUFF
void wormhole() {
    pg.background(bgColor, bgTrans);

    // there are stars from last scene, animate those suckers
    for (Star s : stars) {
        s.display();
    }

    isBusy = true;
    // update, display asteroids
    synchronized (asteroids) {
        for (Asteroid a : asteroids) {
            a.update();
            a.display();
        }
    }
    isBusy = false;
}


// DELETING ASTEROIDS STUFF FROM DRAW() maybe this needs synch too?
  // destroy anything that is offscreen
  for (int i = asteroids.size() - 1; i >= 0; i--) {
    Asteroid a = asteroids.get(i);
    if (a.dead()) {
      asteroids.remove(i);
    }
  }


// ASTEROID class
float asteroidTrans = 120;  // global transparency modifier for asteroids

class Asteroid {
  PVector pos;
  color cFill, cStroke;

  float r;  // rotation
  float rotateSpeed = .005;

  float sw = 2; //strokeWeight

  float ld = 5; // line distance

  float p;  // phase
  float pRate = .3;  // phase rate
  float pAdjust;  // use this number to add to s [or any other value)

  float speed = 1;
  float s = 1;  // starting size
  float growthRate = .05; // growth per frame

  int type = 0; // type of asteroid

  // properties
  // phase pulsates size of asteroid
  // corona gives it a circular outline
  // death color makes it change space bg color on impact w screen

  // behaviors
  boolean ROTATE, PHASE;
  // shape types
  boolean BOX, SPHERE, LINES, CORONA, TRI;
  // on death/ birth
  boolean DEATH_COLOR;
  // extras

  Asteroid(int type) {
    this.type = type;

    pos = new PVector(random(width), random(height), far);

    // randomize its initial rotation
    r = random(TWO_PI);

    switch (type) {
    case 0: // black cube
      cFill = color(0);
      cStroke = color(255);
      ROTATE = true;
      BOX = true;
      break;
    case 1: // colorful, pulsating circles, on death make bg that color
      sw = 0;

      // random colors
      cFill = color(random(255), random(255), random(255), random(20, 255));
      cStroke = cFill;

      ROTATE = true;
      PHASE = true;
      SPHERE = true;
      CORONA = true;
      DEATH_COLOR = true;
      break;
    case 2: // line creature..?
      LINES = true;
      PHASE = true;
      //CORONA = true;
      //pRate = .001;
      ld = 20;
      sw = 1;
      cStroke = color(255);
      break;
    case 3: // triangles
      TRI = true;
      ROTATE = true;
      PHASE = true;
      cFill = color(255);
      rotateSpeed = .01;
      break;

    }

  }

  void update() {
    // all asteroid types move towards you (and grow)
    pos.z += speed * hyperspaceModifier;
    s += growthRate * hyperspaceModifier;

    // rotating asteroids
    if (ROTATE) {
      r += rotateSpeed * hyperspaceModifier;
    }

    if (PHASE) {
      p += pRate; // inc phase
      pAdjust += sin(p) * .5;
    }
  }

  void display() {

    // TRIANGLE
    if (TRI) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      if (ROTATE) {
        pg.rotateZ(r);
      }
      pg.rotateX(3 * PI / 2);
      pg.stroke(255);
      if (PHASE) {
        float r = map(sin(p), -1, 1, 0, 255);
        float g = map(cos(p), -1, 1, 0, 255);
        float b = map(tan(p), -1, 1, 0, 255);
        cFill = color(r, g, b);
      }
      pg.fill(cFill);

      pg.beginShape(TRIANGLES);
      pg.vertex(-12, -12, -12);
      pg.vertex( 12, -12, -12);
      pg.vertex(   0,    0,  12);

      pg.vertex( 12, -12, -12);
      pg.vertex( 12,  12, -12);
      pg.vertex(   0,    0,  12);

      pg.vertex( 12, 12, -12);
      pg.vertex(-12, 12, -12);
      pg.vertex(   0,   0,  12);

      pg.vertex(-12,  12, -12);
      pg.vertex(-12, -12, -12);
      pg.vertex(   0,    0,  12);
      pg.endShape();

      //pg.triangle(0, -10, 8, 10, -8, 10);
      pg.popMatrix();
    }

    // LINE
    if (LINES) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      pg.stroke(cStroke);
      pg.strokeWeight(sw);

      int segments = 8;

      PVector[] linePV = new PVector[segments];
      linePV[0] = new PVector(0, 0, 0);
      for (int i = 1; i < segments; i++) {
        float x = cos( p + (segments / TWO_PI * i)) * ld * (i * .1);
        float y = sin( p + (segments / TWO_PI * i)) * ld * (i * .1);
        float z = linePV[i - 1].z - ld;

        linePV[i] = new PVector(x, y, z);

        pg.line(linePV[i - 1].x, linePV[i - 1].y, linePV[i - 1].z, x, y, z);
      }

      pg.popMatrix();
    }

    // CORONA
    if (CORONA) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      pg.stroke(cStroke, asteroidTrans);
      pg.noFill();
      pg.strokeWeight(sw + 4 + pAdjust);
      pg.ellipse(0, 0, (s + pAdjust) * 1.3, (s + pAdjust) * 1.3);
      pg.popMatrix();
    }

    // BOX
    if (BOX) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      if (ROTATE) rotate();
      pg.fill(cFill, asteroidTrans);
      pg.strokeWeight(sw);
      pg.stroke(cStroke);
      pg.box(s + pAdjust);
      pg.popMatrix();
    }

    // SPHERE
    if (SPHERE) {
      pg.pushMatrix();
      pg.translate(pos.x, pos.y, pos.z);
      pg.strokeWeight(sw);
      pg.stroke(cStroke);
      pg.fill(cFill, asteroidTrans);
      //pg.sphereDetail(7);
      //if (ROTATE) rotate();
      //pg.sphere(s + pAdjust);
      pg.ellipse(0, 0, s + pAdjust, s + pAdjust);
      pg.popMatrix();
    }
  }

  boolean dead() {
    // if object gets totally offscreen...
    if (pos.z > 1000) {
      // DEATH COLOR asteroids change bg color on impact
      if (DEATH_COLOR) {
        bgColor = cFill;
      }
      return true;  // destroy object
    } else {
      return false;
    }
  }

  // if this asteroid is a rotater
  void rotate() {
    pg.rotateY(r);
    pg.rotateZ(r * 2);
    pg.rotateX(r * 3);
  }
}

Use a video as a texture and map it to squares/cubes

$
0
0

Hello to the Forum! I've been using Processing for quite a while and i really love it. So far i was able to do anything that came up my mind without having to ask here. But now I cannot figure out how to do this:

I want to divide the sketch screen into a set of cubes/squares, e.g. 6x4 and have 1 video to play on all of them, making it look like there is just 1 video playing. Later I will want to move some of the cubes on the z axis while the video is playing for audio-visualization. I was trying to use the video as a texture. While processing was not returning any errors, i could only see a blank screen. I have then tried to work around it with a PImage tex which i load with myMovie.get(0,0, width, height). It was applied as a texture to the cube, but the video would only update every few seconds. I have been searching a lot, but I cannot find any examples for what i want to do. I am not sure if using textures is a a good appoach to this problem. So I am hoping there is somebody here who has a better idea or who can tell me how to properly use a video as a texture and apply it to the cubes.


Problem with Sound Library

$
0
0

Hey, II have this error message when I use the current processing sound library.

java.lang.UnsatisfiedLinkError: no LIBWINPTHREAD-1 in java.library.path
    at processing.opengl.PSurfaceJOGL$2.run(PSurfaceJOGL.java:479)
    at java.lang.Thread.run(Thread.java:745)

Can anybody help me? I use Netbeans 8.2.

Geomerative | Text question

$
0
0

I am trying to modify an example script that uses geomerative as well as fisica to have letters with dynamic properties.

The issue I am having is that it currently only works with single letters and I want it to work with words.

The code that I need to figure out is probably this part.

 m_shape = RG.getText(txt);
    m_poly_group = RG.polygonize(m_shape);

    if (m_poly_group.countChildren() < 1) return;
     m_poly = m_poly_group.children[1];    // which letter

If I change the children[1] to children[2] for instance it will work with the 2nd letter of my string.

There is also function RGroup myGroup = font.toGroup(txt); that I think is needed.

Below is a link to my sketch.. (https://www.dropbox.com/s/5ao1s5b82n21lbb/Words.zip?dl=0)

Any tips would be great.

Thanks.

Phil

hi everyone. guys helpme. i want to scan from 100 to 380 of my video.height

$
0
0

import processing.video.*; Capture video;

void setup() { size(640, 480); // Uses the default video input, see the reference if this causes an error video = new Capture(this, width, height); video.start();
noStroke(); smooth(); }

void draw() { if (video.available()) { video.read(); image(video, 0, 0, width, height); // Draw the webcam video onto the screen int brightestX = 0; // X-coordinate of the brightest video pixel int brightestY = 0; // Y-coordinate of the brightest video pixel float brightestValue = 0; // Brightness of the brightest video pixel // Search for the brightest pixel: For each row of pixels in the video image and // for each pixel in the yth row, compute each pixel's index in the video video.loadPixels(); int index = 0; for (int y =0 ; y < video.height; y++) { for (int x = 0; x < video.width; x++) { // Get the color stored in the pixel int pixelValue = video.pixels[index]; // Determine the brightness of the pixel float pixelBrightness = brightness(pixelValue); // If that value is brighter than any previous, then store the // brightness of that pixel, as well as its (x,y) location if (pixelBrightness > brightestValue) { brightestValue = pixelBrightness; brightestY = y; brightestX = x; pixelBrightness = color(256); } index++; } } // Draw a large, yellow circle at the brightest pixel fill(255, 204, 0, 128); ellipse(brightestX, brightestY, 50, 50); text("brightestX: " + brightestX, 20,20); text("brightestY: " + brightestY, 20,40); text("brightnesslevel: " + brightestValue, 20, 60); } }

How to listen to system audio with minim

$
0
0

Hello! I'd like to analyse systemsound. Until now i have done this with a cable from lineOut to lineIn. But in future I'd like to use the internal "Stereomix", because the way with the cable reduces the audio-quality of my monitors. My problem: the "Stereomix" register no sound. I've played with different drivers, audiodevices and qualities...

Output Stereomix

Is there someone who has the same problem? (and sorry for my bad swiss-english)

Hemesh: Create mesh from points (or alternative to HEC_ConvexHull)

$
0
0

Hi there,

I am currently working on a project that creates a 3D mesh from a set of points. These points have been translated from latitude/longitude coordinates and a depth. I have used a HEC_Geodesic icosahedron as a base shape, which then gradually gets deformed over time as more points get added.

I can't post the entire codebase as there's a lot more going on, but this is the important stuff.

public Globe( ArrayList<GlobePoint> points ) { this.points = points; this.creator = new HEC_Geodesic(); this.creator.setRadius( Configuration.Mesh.GlobeSize ); this.creator.setB( 1 ); this.creator.setC( 1 ); this.creator.setType( HEC_Geodesic.ICOSAHEDRON ); this.icosahedron = new HE_Mesh( creator ); this.icosahedronPoints = icosahedron.getPoints(); this.fillBuffer(); }

public WB_Point[] getPoints( ) { return this.points; }

I then use a HEC_ConvexHull to create a mesh from the points returned by the getPoints() method of the Globe class (which essentially merges the points from the Icosahedron, and the points added over time.

void drawMesh( color colour, WB_Point[] points ) { HEC_ConvexHull creatorGlobe = new HEC_ConvexHull(); WB_Render3D render = new WB_Render3D( this ); creatorGlobe.setPoints( points ); HE_Mesh globeMesh = new HE_Mesh( creatorGlobe ); noFill(); render.drawEdges( globeMesh ); render.drawPoints( globeMesh.getPoints(), 2 ); }

This is how the WB_Points are calculated. The depth is always between 0 and 1.

public static class Geography { public static WB_Point CoordinatesToWBPoint( double latitude, double longitude, double radius, double depth ) { double phi = (90-latitude)*(Math.PI/180); double theta = (longitude+180)*(Math.PI/180); double x = ((radius) * Math.sin(phi)*Math.cos(theta)); double z = ((radius) * Math.sin(phi)*Math.sin(theta)); double y = -((radius) * Math.cos(phi)); double scale = ( depth / Configuration.Data.Depth.Max ); WB_Point point = new WB_Point( x, y, z ).scale( 1 - scale ); return point; } }

Now, I suppose it's expected behaviour that the convex hull ignores any points below the surface, because they simply don't show up at all. This is just the basic Icosahedron.

Screenshot:

If I change this line however so that the scale is 1 PLUS the depth scale, instead of MINUS, the points show up again, which I guess is also expected.

WB_Point point = new WB_Point( x, y, z ).scale( 1 + scale );

Screenshot:

My question essentially is: Is there a way to easily create a mesh from a WB_Point[] array that will include/connect every WB_Point in an array? I can't seem to find anything in the Hemesh source code that gets close to it, so I assume it's a bit more involved.

Viewing all 2896 articles
Browse latest View live