I am trying to compare audio waveform from input waveform (A) to preset waveform (B)from in the device.
I try to lookup everywhere. Most likely someone give such a source code as follow :
function compireAudio(){
var audio1 = "http://soundjax.com/reddo/86502%5Ealarm.mp3";
var audio2 = "http://soundjax.com/reddo/44368%5EALARME.mp3";
var i,j,d;
var matching = 0;
var t = 0;
var i,j,d;
var matching = 0;
var t = 0;
var audio1Arr = Array();
var audio1Len = audio1.length;
for (i = 1; i<=audio1Len; i++) {
//reverse so its like a stack
d = audio1.charCodeAt(audio1Len-i);
for (j = 0; j < 8; j++)
{
audio1Arr.push(d%2);
d = Math.floor(d/2);
}
}
var audio2Len = audio2.length;
for (i = 1; i<=audio2Len; i++) {
//reverse so its like a stack
d = audio2.charCodeAt(audio2Len-i);
for (j = 0; j < 8; j++)
{
if(d%2 == audio1Arr[t])
{
matching++;
}
d = Math.floor(d/2);
t++;
}
}
var avarage = Number(matching)/((Number(t)+Number(audio1Arr.length))/Number(2))*Number(100);
alert('The Matching with the two audio is '+avarage+' %.');
And most people said this is not correct because it compare the stream instead of the audio content.
Anyway, I have think of compare every samples after normalization (ensure that amplitude is not a factor here). However, a phase is another problem here.
I have solution is cross-correlation between A and B and find the biggest convolution as output. In this case, they should be in same phase.
In short. WAS Question is What are the common methods for two waveform comparison ?
UPDATE Maybe I should ask What are the common characteristic of a audio waveform for comparing audio waveform ?
P.S. I read this Question and answer. The bottom method seems work, but the comment said No.