Hey,
first post here in the forum. I tried to make 3d music visualisation. Its working but some of thepatches or quads in my case
are not drawn, or are not there? I dont really understand it because it should iterate through and the fft size is stays the same.
so here what if got till now...
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer player;
FFT fft;
PeasyCam cam;
Waves w;
boolean init=true;
void setup(){
frameRate(30);
// smooth();
size(600,600,P3D);
minim = new Minim(this);
player = minim.loadFile("test.mp3",512);
player.loop();
fft = new FFT (player.bufferSize(), player.sampleRate());
fft.logAverages(12,12);
cam = new PeasyCam(this,200);
println("anfang");
}
void draw(){
lights();
if (init){
w = new Waves(300);
init=false;
}
background(255);
w.step();
w.display();
}
class Waves{
ArrayList<Wave> waves;
Waves(int nbr){
waves = new ArrayList <Wave>();
for (int i = 0; i < nbr; i++){
Wave w = new Wave(i*-10);
w.display();
waves.add(w);
}
}
void step(){
for (int i = waves.size(); i > 0; i--){
if (i > 1){
Wave nw = waves.get(i-2);
Wave w = waves.get(i-1);
for (int j = 0; j < w.pts.length; j++){
PVector p = nw.pts[j];
p.z -=10;
w.pts[j] = p;
}
} else {
Wave w = new Wave(0);
waves.set(i-1,w);
}
}
}
void display(){
for (int i = 0; i< waves.size()-1;i++){
Wave w = waves.get(i);
//w.display();
Wave nw = waves.get(i+1);
for (int j = 0; j < w.pts.length-1; j++){
// println(i +" i : j "+j);
PVector p0= w.pts[j];
PVector p1= w.pts[j+1];
PVector p2= nw.pts[j+1];
PVector p3= nw.pts[j];
noStroke();
//line (p1.x,p1.y,p1.z,p0.x,p0.y,p0.z);
fill(120);
beginShape();
vertex(p0.x,p0.y,p0.z);
vertex(p1.x,p1.y,p1.z);
vertex(p2.x,p2.y,p2.z);
vertex(p3.x,p3.y,p3.z);
endShape();
}
}
}
}
class Wave{
PVector[] pts;
PVector col = new PVector(random(255),random(255),random(255));;
Wave(float zpos){
createWave(zpos);
}
void createWave(float zpos){
fft.forward(player.mix);
pts = new PVector[fft.avgSize()];
float theta = 0;
float t = fft.avgSize();
float plus = 360/t;
for (int i=0; i< fft.avgSize(); i++){
int r = int( fft.getAvg(i)+100);
float x = r * cos(radians(theta));
float y = r * sin(radians(theta));
PVector tp= new PVector(x,y,zpos);
pts[i] = tp;
theta+=plus;
}
}
void display(){
for (int i = 0; i<pts.length;i++){
if (i>1){
PVector p = pts[i];
PVector mp;
mp= pts[i-1];
stroke(col.x,col.y,col.z);
strokeWeight(1);
line (p.x,p.y,p.z,mp.x,mp.y,mp.z);
}
}
}
}
thanks for any kind of advice
and im using the 1.5.1 Version of Processing
hmschlesi