0
votes

In other words, I am trying to play a .wav file and for doing this I need to know the frequency and how much it lasts; the API I am using has a method that need as parameter a vector with two fields (frequency and time)!

I tried to use fast fourier transformation but it gives me the frequency and the magnitude!

mag
/\ | | -|------> freq

But I need something like this: freq /\ | | -|------>time

I want to know if is possible to get these informations from a wav file!

1
Unless the WAV file just contains a single sine wave of constant frequency then there isn't just a single frequency to measure - for speech, music, etc there will be a complex assortment of time-varying components. What is it that you're actually trying to achieve ? Pitch detection ?Paul R
By "frequency" do you really mean sampling rate? Whatever you're using to open the wav file should give you that information.Mark Ransom
@PaulR I want to know if it's possible to describe the sound by it's frequency and time. For example: 132 HZ.....1ms, 350.....1ms, 300 Hz....5ms, and so on. I don't know if it's possible and that's why I'm askingdrs
You need to understand that in general there is no single "frequency" (except when you're dealing with a pure sinusoidal tone). At any given instant sound has a spectrum, which is a graph of magnitude versus frequency. So for a whole sound file you end up with a spectrogram, which is a 3D graph: usually time on the X axis, frequency on the Y axis, and magnitude as an intensity value (usually a colour palette is used for this). If you're actually looking for pitch rather than frequency, then that's a whole different story.Paul R

1 Answers

0
votes

A digital audio signal is series of pairs (amplitude, time). Or you can say it is a function of time. If you take a sequence of an audio signal and perform a Fourier Transformation (DFT/FFT) on this sequence, you will get a new sequence which contains pairs of (amplitude, frequency). Or you can say a function of frequency.

This sequence describes the properties of a signal in frequency domain. It does not contain any time information at all.

I guess, what you want, is a function, which describes the change of an audio signal's frequency components over time. This can not be done by a simple FFT.

What you can do is:

  • Take N samples of the audio data stream, samples (0, ..., N-1)
  • Perform a FFT
  • Take another N samples of the audio data stream, (m, ..., m+N-1) with m << N
  • Perform a FFT
  • Take another N samples of the audio data stream, (2m, ..., 2m+N-1)
  • Perform a FFT
  • and so on

If your sampling time is ts, you will get a new frequency analysis after T = m*ts.

Maybe, that is what you you want.