Get spectrum data from Direct output

Hello, i’m a objective-c coder, i recently write a little app with cinder, now i’m migrating to openFrameworks, i need to getSpectrum audio data exactly like the soundPlayerFFTExample does, BUT using a different source NOT a mp3.

For example -> Music playing on iTunes. Is possible to do that with ofx?

I would appreciate any example of implementation, many thanks,
Nahuel.

Assuming you’re talking about OSX, your best bet would to get a virtual loopback audio device like SoundFlower, set it as your audio input/output device, and then use an addon like ofxFft / ofxFFT to get the spectrum. Both addons come with examples that will explain how to get spectrum data from the input device.

If you want to send the audio back to your speakers, you’ll need specify your output device when setting up your OF app. See ofSoundStream’s setDeviceID()

Thanks, yes im currently working on OSX.
I evaluated soundflower, and i think is pretty uncomfortable for the end-user.
Finally, i’ll work over the playback callback, and get the fft data outside openframework, because i’ll need to apply some fx to the audio source, so i believe AudioUnit and AudioToolbox frameworks are suitable.
Thanks anyway, i recently discover openFramework and i am amazed.
Regads, Nahuel.

If you want to dip down to that level, you can check out ofxAudioUnit, which will give you access to the I/O units, effects, etc.

The problem you’ll run into, though, is that there’s isn’t an audio unit you can use to access the sound other applications are making, without using a loopback like SoundFlower (as far as I’m aware). There’s the Audio Hijack plugin Rogue Amoeba has to make Airfoil work, but I’m 99% sure that’s a proprietary thing without a public API.

In any case, good luck :slight_smile: