in reply to Re: Compare wav files
in thread Compare wav files

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Compare wav files
by temporal (Pilgrim) on Apr 17, 2012 at 15:02 UTC

    I'm assuming you are tackling the slightly trickier problem of finding individual sound frequencies within the .wav file.

    To do this you will have to unpack the time domain data in the .wav (which you can do using Audio::Wav::Read or unpack) and then perform a Fourier transform to get this data into the frequency domain (Math::FFT). I recommend reading up on DSP a bit to learn the theory.

    You might also try Audio::Analyzer =)

      Suppose I have two .wav files having same sound but different pitch(one sound taken from near the mic and same sound from keeping the mic far away). So how can I identify at what second the sound has been produced?

      Will both the wav sound be having same sample rate?

        So what you actually want is to synchronize the two files? That is to find the delay of the one that starts later so that you could play them as stereo?

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.

        It would seem that the OP has two .wav files recorded in a system like this:

        We have two identical audio sources triggered at the same time. Audio source 1 is a negligible distance from the recording mic. Audio source 2 is a distance x from the recording mic. We activate them both and record a .wav file.

        The OP notes that the more distant audio file has a different pitch, probably due to higher frequencies dropping off more quickly than lower ones over a distance.

        We really need to calculate the distance x then we can solve for the time using the speed of sound. If you know (or can figure out) the rate of frequency attenuation through your medium, that would work. I suspect there would be some amplitude attenuation that you could use as well which is a more common calculation for this problem.

Re^3: Compare wav files
by tobyink (Canon) on Apr 17, 2012 at 13:36 UTC

    What do you mean by "frequency"? The frequency of the sound waves, or the sample frequency (a.k.a. sample rate)? If the latter, that's shown in my example.

    If you mean the frequency of the sound wave, that's a more complex matter. Most non-trivial audio files will contain sounds of many different frequencies. Even something simple like a violin playing a single long note will have a complex range of harmonics layered on top of the base note. Only things like sine wave generators will generate a single frequency.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re^3: Compare wav files
by zwon (Abbot) on Apr 17, 2012 at 13:35 UTC
    They call it sample rate, not frequency