Re: Basic sample code for FFT audio frequency spectrum?
Re: Basic sample code for FFT audio frequency spectrum?
- Subject: Re: Basic sample code for FFT audio frequency spectrum?
- From: Evan Olcott <email@hidden>
- Date: Sat, 7 Jul 2007 14:41:58 -0500
Matt
I know you're looking for an easy answer, but what you're looking for
isn't easy, and people (like myself) spend months implementing and
perfecting the things you're trying to describe, and make a living
doing it. We're not about to give up all our answers and all our hard
work when we have commercial products available that we sell that do
this very thing.
I realize that you're looking for something a little bit different,
but let me give you a quick run down of why what you're looking for
is a little bit complex and will not be an "easy app":
1. Loading an entire audio file into memory is NOT a good idea,
especially when you're dealing with large multi-track files that
you're talking about. Loading 30MB into memory for a single track
will bring your system to a grinding halt before too long. You will
need to set up multiple reading buffers that read from specific
positions in files at any given time. If you want to deal with
different file formats (AIFF, WAV, SDII, CAF), you'll have to treat
them all differently. That in itself is a complex task.
2. Getting an FFT of an audio file "as a whole" is not really the way
to approach this, as frequencies of certain tracks may change over
time. A simple average may not be a useful approach, not to mention
what would be the optimal FFT window to use for such a task. Some
tracks, like a Kick, may be consistent throughout the song, but drum
overheads would not be. You would probably want to do it in groups,
or windows, with respect to time - which then brings us to issue 3:
3. Drawing. If you are drawing a spectrogram, be prepared to get into
some math regarding logarithmic versus linear in order to get a
readable output. Brush up on your algebra and logarithms - be ready
for it to be a handful more complex if you want it resizable,
scrollable or zoomable. Since a spectrogram is a 2D snapshot (unless
you want to animate it), you lose the time dimension. If you want to
have respect for time over the course of the song, you'll need to do
a sonogram, where you'll have to start thinking about color gradients
with respect to amplitudes and how to draw them efficiently in
addition to the spectrogram drawing complexities. If you want to do
it with any sort of visual speed, brush up on your OpenGL.
4. Implementation. If you're dealing with looking at multiple audio
tracks, is your app recording them? Or is this a "sidecar" app for a
multitrack app? Why would a user switch back and forth between your
app and a multitrack to see a frequency spectrum, when it might just
be implemented by the multitrack app eventually anyway? Are you going
to monitor all changes to the files the multitrack app makes and
update your FFTs? Or are you writing a brand new multitrack app?
Besides the already saturated multitrack market, I can tell you that
there are other audio companies (not ours) already making new ones as
well -- and you may have just given them a new idea.
What you're aiming for is an interesting goal, and I can appreciate
the idea. But believe you me, it's not just a simple task, and any
developer worth their salt would be investing 6 mo or more in this to
get it right, even with a basic implementation. Perhaps you're not
looking to make a commercial app out of this, perhaps it's a hobby
app...that I can understand. But understand that what you're
undertaking is not something that a lot of us are going to just come
out and give you the answers for. As they say in tech support, RT(F)M...
You'll need to read up on a lot of different disciplines to do this:
Quartz, OpenGL, Accelerate.framework, AudioBufferList, calloc/malloc/
general memory management, various audio file format specs, and the
list goes on. It's possible to learn it, and it is fun to do, take it
from me - I love it. But if you expect us to walk you through it and
give you the answers outright, it ain't gonna happen. I don't want to
come off as being mean, but you gotta do some of the work yourself.
Tough love, indeed.
Ev
Technical Knowledge Officer
Head Programmer/Designer
Audiofile Engineering
http://www.audiofile-engineering.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden