// Get Spectrum

Hi !

I’ve got a strange problem with getSpectrum… I think It’s just my ( weird ) way of coding. I will try to resume my problem with a resumen of my code.

I’m trying to catch the Spectrum of a soundPlay, and then utlize it in another loop.

  
//--------------------------------------------------------------  
void testApp::update(){  
	ofSoundSetUseSpectrum(true);  
	float * val = ofSoundGetSpectrum(8);		  
	for (int i = 0;i < 8; i++){  
		if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i];  
		fftSmoothed[i] *= 0.90f;  
	}  
//--------------------------------------------------------------  
  
// res is the variable I want to use to scale or move graphics form, using this   
// "doble for" and getSpectrum  
  
  
void testApp::processTheData() {  
 for (int i = 0; i < 320; i = i + res){  
  for (int j = 0; j < 240; j = j + res){  
  
		R = vidGrabber.getPixels()[(j*VidWidth+i)*3 + 0];  
		G = vidGrabber.getPixels()[(j*VidWidth+i)*3 + 1];  
		B = vidGrabber.getPixels()[(j*VidWidth+i)*3 + 2];  
                  
                ofSetColor(R,G,B);  
		ofRect (i*4,j*4,16*res,16*res);      
  
          }   
      }  
}  
//--------------------------------------------------------------  
  
void testApp::draw(){  
  
		processTheData();  
  
		for (int i = 0;i < 8; i++){  
			if ( (fftSmoothed[i]) < 1 ) // keep the positive valor  
			{ } else {  
			res = fftSmoothed[i] * 200;   // catch the variable  
			}  
	}  
}  
	  
  

And … It’s just crashing ! …

I’m searching and experimenting since some hours and I don’t find the solution.

Any ideas ?

Thanks.