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

Array of objects

$
0
0

Hello, i have this error when i'm running the sketch: NullPointerException. Here the code:

import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
AudioPlayer player;
BeatDetect beat;
FFT fft;
Obj obj;
// var metodi //////////////////////////
float xPan;
float eRadius;

// var temp ///////////////////////////
float band = 20;
float freq = 1000;
float xEasing;
float easing = 0.001;
// var Node //////////////////////////

float xPos, yPos;

void setup()
{
  size(1280, 800, P3D);
  smooth();
  minim = new Minim(this);
  player = minim.loadFile("homeostasie.aif");
  beat = new BeatDetect();
  fft = new FFT(player.bufferSize(), player.sampleRate());
  Obj[] obj = new Obj[player.bufferSize()];

  for (int i=0; i<obj.length; i++) {
    obj[i] = new Obj(width/2, height/2, 1, 0);
  }
}

void draw()
{
  fill(255, 200);
  rect(0, 0, width, height);
  for (int i = 0; i < player.bufferSize(); i++)
  {
    xPos = (player.left.get(i)*200 + width/2);
    yPos = (player.right.get(i)*200) + height/2;
    xEasing = xEasing + ((xPos + yPos)/2 - xEasing) * easing;
    float alpha = 255 - (i);
    noStroke();
    fill(0, map(alpha, 0, 255, 10, 255));
    obj.display(xPos, yPos, 1 + beatDetection(), alpha);
    //ellipse(xPos, yPos, beatDetection() + 1, beatDetection() + 1);
  }
}

If i write the line 49 like this : obj[i].display(xPos, yPos, 1 + beatDetection(), alpha); i have this error: The type of the expression must be an array type but it resolved to HomeostasieReactive2.Obj

Thank you in advance


Viewing all articles
Browse latest Browse all 2896

Trending Articles