Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

How can I remain the drawn boxes?

$
0
0

@bemoregt wrote:

Hi, All.

I have made Spectrogram of mp3 files.

But, in draw() method, drawn boxes are not remained.
How can I remain the drawn boxes ?

//--------------------------------------------------------------
void ofApp::setup(){
dog.load("/Users/mun/Desktop/woman.mp3");
j=0;
ofBackground(55);
}
//--------------------------------------------------------------
void ofApp::update(){
// by taking maximums, as peaks and then smoothing downward
float * val = ofSoundGetSpectrum(nBandsToGet);
for (int i = 0;i < nBandsToGet; i++){
// let the smoothed value sink to zero:
fftSmoothed[i] *= 0.96f;

	// take the max, either the smoothed or the incoming:
	if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i];
}

}
//--------------------------------------------------------------
void ofApp::draw(){
float width = (float)(512) / nBandsToGet;
//
for (int i = 0;i < nBandsToGet; i++){
col= fftSmoothed[i]*125000;
if(col>255) col=255;
ofSetColor(col);
ofDrawRectangle(j, i, 1, 1);
}
j+=1;
if(j > 512) j=0;
}

Thanks.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles