Hi Arturo. Can I ask u sth?
Now, I get the 4-channel signals and draw them in time domain.
1. How can I do FFT for the four signals and draw them in frequency domain?
Here are some code I searched for FFT using ofSoundStream:
indent preformatted text by 4 spaces
const int N = 256; //Number of bands in spectrum, time domain samples
float spectrum[ N ]; //Smoothed spectrum values
int bandRad = 2; //Band index in spectrum, affecting Rad value
int bandVel = 100; //Band index in spectrum, affecting Vel value
void ofapp::setup(){
sound.loadSound( "surface.wav" );
sound.setLoop( true );
sound.play();
for (int i=0; i<N; i++) {
spectrum[i] = 0.0f;
}
}
void ofApp::update(){
ofSoundUpdate();
float *val = ofSoundGetSpectrum( N );
for ( int i=0; i<N; i++ ) {
spectrum[i] *= 0.97; //Slow decreasing
spectrum[i] = max( spectrum[i], val[i] );
}
}
void ofApp::draw(){
ofSetColor( 0, 0, 0 );
for (int i=0; i if ( i == bandRad || i == bandVel ) {
ofSetColor( 0, 0, 0 ); //Black color
}
else {
ofSetColor( 128, 128, 128 ); //Gray color
}
ofRect( 10 + i * 5, 700, 3, -spectrum[i] * 100 );
}
}`indent preformatted text by 4 spaces`
2.How can I get the Start Point,Max Amp,Mode Frequency,Attack of the 4-channel signals?
Thanks a lot!!!
B,
Yuan