Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Compare wav files

by tobyink (Abbot)
on Apr 17, 2012 at 12:41 UTC ( #965502=note: print w/ replies, xml ) Need Help??


in reply to Compare wav files

use 5.010; use Audio::Wav; my $file1 = Audio::Wav->read("file1.wav"); my $file2 = Audio::Wav->read("file2.wav"); say "Files same length (in seconds)" if $file1->length_seconds == $file2->length_seconds; say "Files same sample rate" if $file1->details->{sample_rate} == $file2->details->{sample_rate};
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: Compare wav files
Download Code
Re^2: Compare wav files
by asha_mail (Novice) on Apr 17, 2012 at 13:04 UTC

    How to find the frequency of both .wav files? Comparing the frequency.

      They call it sample rate, not frequency

      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'

      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?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://965502]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-07-28 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (189 votes), past polls