Hi guys! well I have a beginner’s question. So I made an animated video interactive with sound. I get the interactivity and the sensitivity by fftSmooth.
for a example:
// update the sound playing system:
ofSoundUpdate();
//grab the fft, and put in into a "smoothed" array
float * value = ofSoundGetSpectrum(bands);
//request 512 values for fft
for (int i = 0; i < bands; i++){
//smooth
fftSmooth[i] *= 0.99f;
// take the max, either the smoothed or the incoming:
if ( fftSmooth[i] < value[i]){
fftSmooth[i] = value[i];
}
}
and the movement for a line is like that:
for (int i = 0; i < bands; i++) {
ofDrawLine(0, fftSmooth[i]*300, ofGetWidth(), fftSmooth[i]*300);
}
But I made a class with moving rectangles but I cant figure out how can I insert the fftSmooth for more interactive movement. I add on the class all the fftSmooth update but sometimes the program crushed.
This is the ccp file from my class:
ofBall::ofBall(float _x, float _y, int _w, int _h)
{
x = _x;
y = _y;
w = _w;
h = _h;
speedY = 0;
noiseSeed = ofRandom(100);
}
void ofBall::update(){
if(x > ofGetWidth() ){
x = -20;
}
speedX = ofNoise(noiseSeed) *10;
noiseSeed = noiseSeed + 0.01;
x+=speedX;
y+=speedY;
}
void ofBall::draw(){
ofSetColor(255);
ofFill();
ofRect(x,y, w, h);
}
I want to add the ffSmooth into to speedX. for example speedX = ofNoise(noiseSeed) * (fftSmooth[i]*10)
Do anyone have any idea?
Thank you!!
yk