admsyn / ofxAudioUnit

An openFrameworks addon which makes it easy to work with Audio Units on OSX and iOS
MIT License
121 stars 24 forks source link

fft analysis?! #1

Closed joaodafonseca closed 11 years ago

joaodafonseca commented 11 years ago

hi there is it possible to do some audio FFT analysis with ofxAudioUnit??

admsyn commented 11 years ago

Hi @joaodafonseca, no need to close this, it's something I've thought of doing myself :) At the moment, I envision this being related in functionality to the ofxAudioUnitTap, where you just do something like getFFT() whenever you want to get an FFT representation of the last batch of samples to have passed through.

It will involve a bit of work to the structure of the addon, as it's not as extensible as I'd like right now. Keep an eye on this issue for updates though and I'll see what I can do.

admsyn commented 11 years ago

@joaodafonseca you can get easy FFT analysis with ofxAudioUnit now, by using the ofxAudioUnitFftNode. It's used similar to how the ofxAudioUnitTap works. Stick the FftNode in between some audio units, then call getFft() on it to extract an fft sample. I'm going to add a general DSP example soon, once I've added a few more features and fleshed out the DSP chain a bit better.

You'll need to pull the "fft" branch of ofxAudioUnit, and ofxAudioUnitFftNode should be considered super-alpha at this point. Its API will most certainly change in the future.

https://github.com/admsyn/ofxAudioUnit/tree/fft

joaodafonseca commented 11 years ago

Super! Gonna check it out! Thks mate!

polyren commented 8 years ago

@admsyn

Hi! I'm trying to use ofxAudioUnitFftNode to analysis FFT, but I found that you have removed the tree fft example. Where can I find it?

stephanschulz commented 6 years ago

@admsyn do you think you have a simple FFT example kicking around that would help me understand how to set the bin size and extra the values from each FFT bin? thx

stephanschulz commented 6 years ago

would this be enough? seems a bit jumpy with the mic input. [notice ] 0.142857 [notice ] 1 [notice ] 1 [notice ] 0.545455 [notice ] 1 [notice ] 1 [notice ] 0.0238098 [notice ] 0.340661

 fft.setFftBufferSize(12);
 input.connectTo(tap).connectTo(fft).connectTo(output);
vector<float> outAmplitude;
    fft.getAmplitude(outAmplitude);

    int ww = 20;
    ofPushMatrix();
    ofTranslate(100,300);
    for(int i=0; i<outAmplitude.size(); i++){
        if(i == 0) ofLog()<<outAmplitude[i];
        ofDrawRectangle(i*ww,0,ww,-outAmplitude[i]*100);
    }
    ofPopMatrix;
admsyn commented 6 years ago

Hey Stephan, you probably want .setFftBufferSize() to be more like 512 or 1024, and you could try experimenting with the scale as well.