1

Can I find a way to get frequency of each frame on a audio file like .mp3 or .wav or any other sound format using "fmod" or "cwave" libraries or even other libraries? How can I find out this frequency in C/C++?

Erfan Loghmani
  • 607
  • 4
  • 7
  • 2
    What MPEG Audio Layer III calls a "frame" is a block of 1152 samples, i.e. there is no such thing as "frequency of each frame". I suggest you do some reading (like, how MP3 or WAV are actually constructed, and the API documentation of your library of choice), then return when you can ask a more specific question. – DevSolar Jun 01 '12 at 13:03
  • The question equals: How can I get the color of a specific video frame? – Franz Ebner Jun 01 '12 at 13:06
  • Thanks. But I didn't find a good source for mp3 or wav construction. And can I have a frequency of a mili second (or something like that) of an audio file? – Erfan Loghmani Jun 01 '12 at 13:07
  • 2
    There is a whole bunch of frequencies present at the same time... – Franz Ebner Jun 01 '12 at 13:12
  • If you "didn't find a good source for MP3 or WAV construction", you didn't look hard enough. Do you think I knew the first thing about MP3 construction when I first looked at your question? I used a search engine, using "audio frame" as keywords. If you cannot search, *ask* for reference material. Asking for a *specific* solution usually gets less useful answers as a question that shows you're willing to invest some research of your own. – DevSolar Jun 01 '12 at 13:41
  • I think I had bad keywords. Best regards. – Erfan Loghmani Jun 01 '12 at 17:25

2 Answers2

2

The FFTW library is a set of very fast implementations of different fourier transformations.

Herr von Wurst
  • 2,571
  • 5
  • 32
  • 53
0

If you have a number of samples of digitized audio, you pretty much have, in total, as many frequencies and phases as you've got samples. Suppose you've got just two samples of audio. In order to faithfully represent them, you need one frequency and one phase -- so again, two values. There is no "single" frequency to represent multiple samples of digitized audio.

You can of course, akin to the question of "How can I get the color of a specific video frame?", ask what is the average frequency. Or you can ask what is the most prominent frequency (the one with highest amplitude). Or you can ask what is the frequency that with its harmonics carries the most energy in the signal (assuming the signal was physical, like electrical current sampled in time).

In all those cases, you'd probably want to use a premade library that internally uses the FFT or a similar discrete transform to get the signal from the time domain to a frequency or a similar domain (quefrency domain, for example, and it's not a typo). It's hard to get what you want from a plain FFT, you'd need some mathematical training to process raw FFT results into what you're after. I'm sure there are libraries for it, I just can't think of any right now. Perhaps someone who deals with such work can edit the answer.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313