Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Need a Method for compair 2 waves

Status
Not open for further replies.

ajex

Member level 4
Joined
Nov 7, 2009
Messages
70
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Location
Sri lanka
Activity points
1,813
Need a Method for compare 2 waves

hello all..

This is my problem..
* I have two different sound clips ( actually those are Phonemes in sinhala language) and I have Attached in to this Thread
* now i want to compare those wave forms and need to prove, that those are approximately same wave forms. (frequency and shape)

Please tell me a method to do that, thank you very much...............!
 

Attachments

  • TwoWaveFiles.rar
    21.8 KB · Views: 104

try converting them into digital format and then run them through a comparator or subtractor circuits as they may find both the difference and the location of the difference in your sound clips
 

I think you have use a tool like Matlab or Scilab (freeware). Both of them can load directly the .wav file extracting also the sampling frequency information. Once the two files are read, take the FFT of both of them and compare one each other. Eventually normalize the amplitude of the main peak in order to equalize the two speech amplitudes. I obtained this Immagine.jpg

x-axis (frequency) in Hz
y-axis (amplitude) in dB
 
Last edited:
  • Like
Reactions: ajex

    ajex

    Points: 2
    Helpful Answer Positive Rating
Thank you albbg, I have MATLAB and I did FFT, but problem is i want to prove the wave shapes and frequency are approximately same.
That mean those are same sound(approximately ) and only difference is the length of the total wave.
 

Since a signal is the summation of many sinusoidal signals at different frequencies, so you can compare any signals by comparing their frequency components.
The FFT will give you all the frequency components of the signal and then you can check your signals that they are the same or not. If their frequency component are the same, then both signals are the same.
That is the method albbg suggested to you in his post.
 

In my view what you can have cross correlation between them such that correlation coefficient can be a good measure for signal comparison...

The problem with frequency domain aspect is you can only have comparison of the ratios of the frequencies in the amplitude spectrum as the cartieria ( I am taking signal with same length, it they are not of same length one need to re sample them to one size for this kind of analysis ) but there is one more big side of signal analysis called as phase spectrum ....and most of the time the information is phase spectrum is more important than the amplitude spectrum ... so better to have cross correlation coefficient as first measure ....


Good Luck
 
  • Like
Reactions: ajex

    ajex

    Points: 2
    Helpful Answer Positive Rating
hello..

milind.a.kulkarni please help me to do cross correlation for this waves. I haven't idea and I searched google and found some articles but couldn't get a proper idea..

Thank you..
 

Hi Ajex,

As per my understanding you may be using matlab....correct me if I am wrong ....First get your wave files in the term of sequence or array of samples ....then you can check that the length of array is same or not....if yes you do not have problem....if not you need to re-sample them to get equal length between them....and then you can use xcorr function of matlab for getting cross -correlation coefficients ....

Good Luck
 
  • Like
Reactions: ajex

    ajex

    Points: 2
    Helpful Answer Positive Rating
yes I did, this is my code..

clear all;
clc;
[A, Fs] = wavread('D:\TESTING SOFTWARE\matlab\1a.wav');
[B, Fs] = wavread('D:\TESTING SOFTWARE\matlab\1aa.wav');
maxlags = length(B);
[c,lag]=xcorr(A,B,maxlags);

I have taken one wave length from each 1a.wav and 1aa.wav signals. In here length(B) was larger than length(A) so no need to resample and xcorr will zero padded to A data. and then how can judge by looking the data whether those are approximately same wave shapes. please help..
 

For your first problem of resample.....you try resize or resample command in matlab - refer

https://www.mathworks.in/help/techdoc/ref/reshape.html
https://www.mathworks.in/help/toolbox/signal/ref/resample.html

Now related to to judge the signals....there will be two methods
1) Visual method - In this method plot both signals simultaneously and then take a visual case
2) Root mean square method- what you can do is compute the difference of two signal as Diff=A-B ( Kindly note A and B must be of same length if after re sampling) and then take the square of each element of of Diff array and take a summation of them if you take the square root of that entity you will get root mean square error....that is a good measure....

Now in order to comparison of the two signal the c=xcorr(A,B_resampled) will very from 0 to 1 and then you simply multiply the coefficients c by 100 to get the value in the percentage....this will tell you how much you first signal match with other in the percentage....

Good Luck
 
  • Like
Reactions: ajex

    ajex

    Points: 2
    Helpful Answer Positive Rating
Going to try this, I'll let you know the results.. hope this will work.. :)
 

Finally did it... Thanks friends for helping me...! I'll post here steps to do that, I think It will help to beginners..


1st wave >> A
2nd wave >> B

Steps :

1. find xcorr (A)
2. find xcorr (B)
2. find xcorr (A,B)

calculate p^2 = ( xcorr (A,B))^2 / xcorr (B) * xcorr (A)

if 1.0 > P > 0.8 those signals are approximately same shape.


Special thanks to Mr. milind.a.kulkarni
 

Hi Ajex,

Only one question why did you want to do the auto-correlation operation I mean xcorr(A) and xcorr(B)...If it is normalization aspect....In my view you can do the cross-correlation alone to find out how much A and B are matching with respect to each other.... what you could have been done is p^2 = (xcorr((A/max(A)),(B/(max(B))) /(N^2)) ....the reason that I am saying this bcz movement you do the auto-correlation you are making N^2 operation for each correlation so it is computationally expensive.....I hope you understand my point....

Good Luck
 

A comparison of waveforms will not work. Two sounds may sound identical having very different waveforms.
Indeed, your two "a" sounds have different intonation (different fundamental frequencies) but the same intelligibility. Cross-correlation between them will not be high.
Regards

Z
 

Mr zorro your point is correct but here my "a" and "aa" sounds are Short vowel "a" and long vowel "a", so those are in same fundamental frequencies. thank you for your point...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top