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

Help with Audio Visualizer

$
0
0

Hello! I am trying to create an audio visualizer. I am using live sound. The problem I keep coming into is the nullpointer exception error. Please take a look at this code and give me some tips on how to fix this! Thank you.

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

Minim minim; AudioPlayer jingle; AudioInput input; FFT fft; int[][] colo = new int[100][10];

float color1 = 35;> float color2 = 45; float color3 = 65; float color4 = 75;

void setup() { size(512, 400); background(0); colorMode(HSB,100,100,100,100);

minim = new Minim(this);

input = minim.getLineIn();

fft = new FFT(input.bufferSize(), input.sampleRate());

}

void draw() { background(0); noStroke(); fill(0, 5); rect(0, 0, width, height); pushMatrix(); translate(width/2, height/2); rotate(radians(frameCount % 360 * 2));

fft.forward(input.mix);

for(int i = 0; i < fft.specSize(); i++) {

  if(jingle.mix.get(i)*200 > fft.specSize()) {
    stroke(color1,100,100);
  }
  else {
    stroke(color2,100,100);
  }

  line(cos(i)*50, sin(i)*50, cos(i)*abs(jingle.left.get(i))*200 + cos(i)*50, sin(i)*abs(jingle.right.get(i))*200 + sin(i)*50);
}

for(int j = fft.specSize(); j > 0; j--) {

    if(jingle.mix.get(j)*200 > fft.specSize()) {
    stroke(color3,100,100);
  }
  else {
    stroke(color4,100,100);
  }


  line(cos(j)*50, sin((j))*50, cos(j)*abs(jingle.right.get(j))*200 + cos(j)*50, sin(j)*abs(jingle.left.get(j))*200 + sin(j)*50);
}

popMatrix(); }

void keyPressed() {

if(key == 'r') { color1 = 0; color2 = 5; color3 = 90; color4 = 95; }

if(key == 'g') { color1 = 35; color2 = 45; color3 = 65; color4 = 75; } }


Viewing all articles
Browse latest Browse all 2896

Trending Articles