[mad-dev] Re: How to know the frequency of a frame
Adam Luter
Adam.Luter@matchwave.com
Fri, 1 Aug 2003 16:34:51 -0500
Mp3s store information based on frequencies, instead of time. That is,
instead of an x-axis of time, there is an x-axis of frequency -- like
you are saying. However, it has been pointed out here on this list that
while this data is available from libmad, you will get somewhat
inaccurate results (that is, mp3s do not store the exact frequencies).
What you probably want to do is a fourier transform on the result of
decoding the mp3 (that is a pcm or wav file). A fourier transform takes
data in the time domain and brings it to the frequency domain (like you
want). Take a look at the fftw library (fastest fourier transform in
the west).
My player utilizes this for it's spectrum meter, you can take a look at
it's source code at sv.gnu.org, the project name is 'squash'. It's not
1.0 code yet, and there are several thousand lines, but what you want to
look in is play_mp3.c (to see how to use libmad to decode things), and
also in spectrum.c (to see how to use fftw to transfrom pcm data into a
spectrum bitmap).
Hope this helps.
-Adam Luter (Gryn)
On Fri, Aug 01, 2003 at 02:16:26PM -0700, Shiming Dong wrote:
> But I found the samplerate for all the frames are the
> same. And I think for each frame the frequency, which
> is the X-axis value of visualized mp3 player for each
> tone will be different. (When you use mp3 player to
> play a CD, the X-axis displays the frequency and the
> Y-axis is the volume I think. I want to know the
> X-axis value for each frame. )How do I get this
> information?
>
> Thank you!
>
> shiming