A couple of (hopefully) simple problems from a nooooob!
in
Contributed Library Questions
•
2 years ago
Hello everyone, this is my first post here. I've done a bit of reading around processing and finally decided to dive in with a project. I've predictably hit up against a couple of problems and was hoping that one of you might help me. I'm sure that this will be super easy to those of you with much more experience than me. So...
I started playing with
Ess because I have a background in sonic art and was interested in the FFT bits and wanted to play around with them. I've got a patch up and running which kind of does what I want, here you go:
import krister.Ess.*;
FFT myfft;
AudioInput myinput;
int bufferSize=256;
void setup() {
size(1000,500, P3D);
frameRate(30);
background(255);
smooth();
Ess.start(this); //start this window
myinput=new AudioInput(bufferSize);
myfft=new FFT(bufferSize*2);
myinput.start();
myfft.damp(.3);
myfft.equalizer(true);
myfft.limits(.005,.05);
}
void draw() {
rotateY(radians(-17)); //rotates Y
rotateX(radians(-10)); // rotates X
background(255);
int d=0;
for (int i=0; i<bufferSize;i++) { //i defines the FFT to fill
if (i==0){
d++;
}
pushMatrix();
translate(i+400, height/2, d);
box(1, myfft.spectrum[i]*-400, 1);
popMatrix();
println(d);
}
}public void audioInputData(AudioInput theInput) {
myfft.getSpectrum(myinput);
}
One problem relates to the variable "d". What I would like to happen is that every time the variable "i" hits 0, 1 gets added to "d" and the final argument for translate gets increased, so bringing the image ever closer. I've created a println(d); object to monitor whats going on, but all that seems to happen is that the number 0 and 1 fluctuate (seemingly) randomly. I've highlighted the relevant parts in
green.
My second problem is that I don't want what has transpired to be deleted with each frame. The idea is that FFT frequency analysis is carried out and, when the "i" variable hits 0, the image moves forward and the past FFT window can still be made out. What I want to end up with is a 3d representation of a sound wave.
Any help would be greatly appreciated!!!
1