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

ofxFFTBase usage

$
0
0

@darthrivan wrote:

Hi there,

I've been using oF for some time now, but I have 2 project that are stuck. Here's the first one that uses ofxFFT (precisely ofxFFTBase) and I'll post another topic with the second project/problem.

The idea is that I want to inspect the Highs (for example) so I can make the figure react if highs are greater than some value. I have this in the Update function of ofApp (getting the code from an example) so I can see whats playing on the left channel:

vector<float> sampL = fftChannelL.getFftNormData();
int sampSizeL = sampL.size();

for (int i = 0; i < sampSizeL; ++i) {
    cout << sampL[i] << endl;
}

But I keep getting zeros (using either L and R channels), so it appears that it isn't reading anything although the code is getting audio correctly as it's the same of another version I have that the figure only reacts to the Volume.

I have this on the Setup function:

soundStream.setDeviceID(0);

ofSoundStreamSetup(0,2,this, 44100,BUFFER_SIZE, 4);

samplesChannelL.assign(BUFFER_SIZE, 0.0);
samplesChannelR.assign(BUFFER_SIZE, 0.0);

and my audioIn function looks like this:

void ofApp::audioIn(float* input, int bufferSize, int nChannels){
    for (int i = 0; i < BUFFER_SIZE; ++i) {
        samplesChannelL[i] = input[i * 2 + 0];
        samplesChannelR[i] = input[i * 2 + 1];
    }
    
    float* dataL = &samplesChannelL[0];
    float* dataR = &samplesChannelR[0];
    
    fftChannelL.audioIn(dataL);
    fftChannelR.audioIn(dataR);
}

Any help or comment would be really helpful.

Thanks

DarthRivan

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles