fft real time input audio..?


#1

call me stupid, but is it possible to analyse the frequencies of real-time (eg: microphone input) audio? from my limited understanding of audio stuff, it strikes me that to sample the frequencies you need to buffer the data?

I could only get the OF frequency stuff to work with pre-recorded sound files as per the example…

any suggestions? and apologies if this isnt really the right forum.
:slight_smile:


#2

hi -

grimus has posted an example here:

http://forum.openframeworks.cc/t/audio-input-fft-example/186/0

that does fft of the mic input…

you are already getting the input buffered (you set the buffer size when you kick off ofSoundStream) and the amounts you get it in (256, 512, etc) are reasonable for doing fft. with bigger buffers, you can detect lower frequencies.

hope that helps!
zach


#3

There’s also an example of how to use FMOD to do an FFT on an input stream in the FMOD C/C++ code examples which you get once you download the FMOD API at www.fmod.org

So if you are up to it, a little bit of hacking the ofSoundPlayer code will enable you to achieve this. I can post some code if you are interested. Otherwise my other example should work fine as well.


#4

This might not be an appropriate thread here, but I have a problem using the FFT example.
I’ve got the FFT example working with OF v2.0(thanx for the source).
But I want to use some of OF v4.0 features with it, and I’ve got 2 error messages when I ran the FFT code with v4.0 frames.
I can’t post the whole error message because it really is messy, I am wondering if I can morph this code into the current OF version.
Thanks.


#5

many thanks for the assistance chaps, am checking out the suggested code.
I have to say, these forums are **GREAT **!!
I’ve been working on a public facing project and decided to use OF, and I have had a few things pop up… once the hecticness has calmed, I’ll be able to verify my findings and post up. cheers again.


#6

Hee – please just copy the error messages or take a screenshot, and then zip up the whole project, otherwise it’s impossible to help you w/ it… thanks! zach


#7

Sorry, I thought there might be a common route to change the old ver to new ver.
Here’s the code.

Code-&-Screenshot

Thanks for quick reply;)


#8

hi hee,

I can’t see clearly from the image what the errors are, can you copy the build results into a message here, or widen the window when you take the screenshot??

thanks!
zach


#9

Here the errors.
Sorry for draggin this too far.

  
Building target “openFrameworks” of project “openFrameworks” with configuration “Release” — (2 errors)  
	    cd /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01  
    /Developer/usr/bin/gcc-4.0 -x c++ -arch ppc -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -mtune=G4 -fvisibility=hidden -fvisibility-inlines-hidden -mmacosx-version-min=10.4 -I/Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/Release -I/Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/Release/include -I/Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -Wall -D__MACOSX_CORE__ -lpthread -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-fbjgfeumfotlvwguooqnhjiptpak/Carbon.h -c /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/../../libs/openFrameworks/sound/ofFmodUtils.cpp -o /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/ppc/ofFmodUtils.o  
powerpc-apple-darwin8-gcc-4.0.1: /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/../../libs/openFrameworks/sound/ofFmodUtils.cpp: No such file or directory  
		powerpc-apple-darwin8-gcc-4.0.1: /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/../../libs/openFrameworks/sound/ofFmodUtils.cpp: No such file or directory  
		powerpc-apple-darwin8-gcc-4.0.1: /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/../../libs/openFrameworks/sound/ofFmodUtils.cpp: No such file or directory  
	    cd /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01  
    /Developer/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -fmessage-length=0 -fvisibility=hidden -fvisibility-inlines-hidden -mmacosx-version-min=10.4 -I/Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/openFrameworks.build/Release/openFrameworks.build/openFrameworks.hmap -mdynamic-no-pic -F/Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/Release -I/Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/Release/include -I/Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/openFrameworks.build/Release/openFrameworks.build/DerivedSources -Wall -D__MACOSX_CORE__ -lpthread -isysroot /Developer/SDKs/MacOSX10.4u.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/Carbon-hfozjpkbyoxrvvhiebijkkftqwle/Carbon.h -c /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/../../libs/openFrameworks/sound/ofFmodUtils.cpp -o /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/build/openFrameworks.build/Release/openFrameworks.build/Objects-normal/i386/ofFmodUtils.o  
i686-apple-darwin8-gcc-4.0.1: /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/../../libs/openFrameworks/sound/ofFmodUtils.cpp: No such file or directory  
		i686-apple-darwin8-gcc-4.0.1: /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/../../libs/openFrameworks/sound/ofFmodUtils.cpp: No such file or directory  
		i686-apple-darwin8-gcc-4.0.1: /Users/Hee/Desktop/THESIS/of_preRelease_v0.04_xcode/app/SMtest01/../../libs/openFrameworks/sound/ofFmodUtils.cpp: No such file or directory  
Build failed (2 errors)  

Thanks a million for helping me fixing the prob.
Hee


#10

hi hee,

you can’t use an older xcode project in 0.04, you just need to copy the source / etc into a 0.04 project.

“libs/openFrameworks/sound/ofFmodUtils.cpp” was removed, thus xcode is complaining. this is why.

we restructure OF from release to release (see the changelog) so older proejcts don’t work in new versions of OF (and vice versa)…

hope that helps explain the error, just try making a 0.04 project and bringing the source code (“src”) in including the fft.cpp, etc.

take care
zach


#11

Thanks, Zach.
I’m glad this was a simple problem, I forgot the step while going though sleepy midnight programming session. Thanks, I would’ve spend hours of time if you didn’t point this out.

Hee