Re: Basic sample code for FFT audio frequency spectrum? Sarcasm Maybe? Thank You...
Re: Basic sample code for FFT audio frequency spectrum? Sarcasm Maybe? Thank You...
- Subject: Re: Basic sample code for FFT audio frequency spectrum? Sarcasm Maybe? Thank You...
- From: John Geelen <email@hidden>
- Date: Sun, 8 Jul 2007 22:06:31 +0200
I can suggest a good book which you can download for free at
www.dspguide.com
I can suggest OSX sample code at http://homepage.mac.com/chen/
index.html that can give you an idea how to do calculations on
streaming audio.
I used the book to build a spectrum analyzer under OS8.6 with Code
Warrior C++.
I don't have the code anymore but still have a copy of the project
that runs under OSX9
John Geelen, PAøJCG
Op 7-jul-2007, om 7:40 heeft IgnisFatuus het volgende geschreven:
Nigel,
Thanks for your feedback. That is the most intelligent feedback
I have got so far on this list. First I got links to products to
buy $$, then a one function do all response.
The last time I performed any DSP DFT or FFT was
at the assembly language level in college. I then
used an ADSP-2181 Analog Devices EZ-KIT Demo board
for senior design project for chorus and Reverb audio effects in a
Vacuum tube
Electric guitar amplifier I built for final exam... but LONG time
ago and in
assembly language and everything in real-time. Nothing "C" or
"Objective-C" levels.
Maybe the answer is right in front of my
face, but I am looking to deep for the answer? Or maybe I am
asking to high a level questions? Maybe I should have mentioned
the discrete-time fourier transform instead of the fast fourier
transform? Been to long. I need to get used to the types
of questions to ask since I am new to this forum.
From your great response I went and dug out my old DSP
college book to make sure I was asking the right question. FFT,
DFT, DTFT,
FIR, etc. and what fourier transform do I really
need to ask about? Or did my questions not clear that up with the
words
frequency analysis of an audio file? Sometimes it takes tough love
to understand and know which are the right questions to ask. Thanks.
Maybe I should have been more specific with my questions?
Everything should be as simple as possible but not simpler.
--Albert Einstein
How to...
1. Open an audio file and get that mono or stereo audio file into a
buffer and c/m/re/alloc the buffer size to the size of the audio file.
2. How to extract the audio file data samples (from audio file
buffer) to give to some of the fourier transform routines that
apple provides at the developer site in SDK.
Then once I have the 2D data from the fourier transform function, I
will plot in an NSView
the frequency, and the dB of each sample point that I am assuming gets
put into another buffer from the apple supplied fourier transform
routine? That way I will be able
to see the frequency spectrum of an audio file. All the way from
20Hz to 20kHz. Then I'll develop the code further so I can see in
an NSView
the frequency spectrum of different audio files layered on top of
one another.
Say for instance I recorded a band, there will most likely be lots
of individual tracks, kick drum, snare, electric guitar, bass
guitar, vocals, then
I can see how the different frequency spectrum of each track(diff
colored plot lines), or instrument
looks like, so I can provide the necessary frequency spectrum space
each instrument needs in the
mix EQ wise so all the instruments are heard in the final mix, and
not fighting
frequency wise.
That is my goal to learn how to do programming wise in Objective-C.
I haven't looked at the Audio Units developer info because I want
this to be an application,
and not just an AU that runs in real time. But maybe I need to
start looking at the AU
documentation instead for additional info?
I don't mean to ask loaded questions if that is what you meant from
below. But since I didn't know the lower level or higher level talk on
the forum when I signed up I figured to ask a higher level question
for starters for the knowledge. Thanks again.
Matt
Hi Matt,
The answer isn't so clear cut because it's a bit of a loaded
question... For instance, if you ask "I need to plot the response
my this low-pass filter I made... how do I figure out the
response?"--that's easy. If you talking about doing a spectrum
analyzer, then you're asking people to make a ton of implementation
decisions for you. Now, maybe you can find some source code that
does what you want, but of course you can google for that as well
as I can, so that doesn't seem to be the issue you're presenting.
(Or maybe it is and you couldn't find exactly what you want, and
you're hoping someone else has, but as James noted--"Everything I
have looked at is very complex and I am having trouble extracting
the basics"--you're not going so find a routine and a few function
calls and "ta-duh".)
An FFT converts one cycle of a repeating waveform to its harmonic
components. Implicit there is that you have exactly one cycle, and
that cycle repeat continuously. Well, that's really a DFT--an FFT
is an optimization that makes it more efficient, but stipulates
conditions on the number of samples that make up that one cycle--
typically a power of two. And the number of samples dictates the
frequency resolution as well, so you have to make a decision there.
First you are rarely going to be lucky enough to grab exactly one
cycle in the power-of-two you chose, and second, it's unlikely you
are trying to measure a static waveform.
From there, you begin your journey of decisions and trade-offs.
Basically, you can work around those FFT limitations by repeatedly
running FFTs and overlapping them, but that is only to say that the
can of worms is now open. There are well-known techniques of doing
this sort of thing, and whether it's complex or not pretty much
depends on your level of DSP expertise. It's not as complicated as
(musically-useful) pitch shifting, but it's a far cry from tossing
together a biquad.
I know this doesn't help much, except it might help you understand
why you're not getting deluged with source code. I would think you
can find something, but then it's probably up to you to search for
it, and figure out how you can use it.
Regards,
Nigel
On Jul 5, 2007, at 8:29 PM, IgnisFatuus wrote:
Sorry about this fools response to this forum listed below...
Cocoa has it all (now also 64-bit available)
Google for:
NSLoadAnAudioFile
NSPressTheButton
NSDisplayFrequencySpectrum
Some of us really appreciate honest feedback.
Maybe you should be kicked off this forum since
you don't seem to be of any help!
I wrote software for macs for years but not within
the audio realm! I know your above responses
are crap!
I like to start from the bottom foundation and
work my way up to the details so I can "learn".
If I couldn't find what I was looking for on the
Apple developers site... then I post for
directions or links etc. Not CRAP!
Like say when the audio file is loaded, and how to retrieve
that data for the FFT then the finished result so I can
plot in an NSView.
If all you have is crap to say... then you might as well
resign from this forum! You evidently don't have "any"
programming skills to help out!
Matt
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40hetnet.nl
This email sent to email@hidden
_______________________________________________
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