We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hello,
i am trying to use preloaded audio files to seed point information using vertex(x, y). in my setup, i successfully load audio files from the data folder and perform fft. (i am using minim.) when i create an array of data points, the resulting array is filled with zeroes even though the files have been loaded. i can make the arrays in draw(), but then i'll have multiple copies of them. but, when i do create the arrays in draw(), the arrays are filled with numbers other than zero.
here is a sample of my code:
float ax[][];
float ay[][];
setup()
{
ax = new float[27][1024];
ay = new float[27][1024];
for(int i = 0; i <= tracks.length; i ++)
{
for(int j = 0; j < ffts[i].specSize(); j ++)
{
ax[i][j] = scale * ffts[i].getBand(j);
ay[i][j] = scale * ffts[i].getBand(j);
println(ffts[i]); //lists addresses of files in memory in the form: ddf.minim.analysis.FFT@1c33a141
println(audioFiles[i]); //lists addresses of files in memory in the form: ddf.minim.AudioPlayer@19fc0de
println(ffts[i].getBand(j)); //0.0 for every fft[i]
println(i + ": " + ax[i][j] + ", " + ay[i][j]); //0.0 for every (ax[i][1024], ay[i][1024])
}
}
}
what's going wrong?
thanks in advance,
destro
Answers
pls post the entire code
e.g. you must load and set path after using size() in setup().
hi chrisir,
i have loaded the files and set the path after size().
the code is rather large. i'll make a small excerpt and re-post.
thanks.
hello again,
i've extracted part of the code:
i figured out one problem, but i don't know how to solve it...
the problem is that in order to get fft.getBand(), the files needs to be mixed. however, the mix needs to occur in draw(). i need to populate the array in setup to prevent extra copies of it, right? so, how can i populate the array in setup if the values can't be generated until after the fft.mix in draw. the fft.mix does not work in setup.
You can check if it's the first frame:
Or use your own counter for the same effect.
edit for clarity: in draw(), that is.
hi velvet, i don't understand your response. could you elaborate a bit about what i'd be checking?
after switching to using audiofile.left.get(), i noticed the same behavior; it doesn't read values in setup so i couldn't populate my array until i was in draw(). however, my graphics are slow and it seems they are being drawn multiple times since i have to make the arrays in draw().
velvetkevorkian meant that you should do your array initialization in the first frame of draw(), since that's where things happens. Then, on the upcoming frames, you just use this data. frameCount is 1 on the first frame (first call of draw()), 2, 3, etc. on the following ones.
Side note: please, read To newcomers in this forum: read attentively these instructions. At least to learn how to format your code!
hi philho,
after going back to try to get a feasible solution, i figured that i had to do just what you're suggesting. the reason i didn't want to that even though it worked was because it slowed down my sketch so much, even freezing at times from using printlns to debug. i seemed to have worked through it. thanks for your reply.