12,448,709 members (52,771 online)
Rate this:
See more:
hello friend....

I need to match two audio files and it should return how much it matches......

i recording the audio file using MCI.
Posted 14-Dec-12 20:59pm

Rate this:

## Solution 1

```function compareAudio(){
var audio1 = "Source1Path";
var audio2 = "Source2Path";
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+' %.');```
Rate this:

## Solution 2

Quote:
create a File-Compare function in Visual C#

```Create a new Visual C# Windows Application project. By default, Form1 is created.
Add two textbox controls to the form.
Add a command button to the form.
On the View menu, click Code.
Add the following USING statement to the Form1 class:

using System.IO;

Add the following method to the Form1 class:```

```// This method accepts two strings the represent two files to
// compare. A return value of 0 indicates that the contents of the files
// are the same. A return value of any other value indicates that the
// files are not the same.
private bool FileCompare(string file1, string file2)
{
int file1byte;
int file2byte;
FileStream fs1;
FileStream fs2;

// Determine if the same file was referenced two times.
if (file1 == file2)
{
// Return true to indicate that the files are the same.
return true;
}

// Open the two files.
fs1 = new FileStream(file1, FileMode.Open);
fs2 = new FileStream(file2, FileMode.Open);

// Check the file sizes. If they are not the same, the files
// are not the same.
if (fs1.Length != fs2.Length)
{
// Close the file
fs1.Close();
fs2.Close();

// Return false to indicate files are different
return false;
}

// Read and compare a byte from each file until either a
// non-matching set of bytes is found or until the end of
// file1 is reached.
do
{
// Read one byte from each file.
}
while ((file1byte == file2byte) && (file1byte != -1));

// Close the files.
fs1.Close();
fs2.Close();

// Return the success of the comparison. "file1byte" is
// equal to "file2byte" at this point only if the files are
// the same.
return ((file1byte - file2byte) == 0);
}

Paste the following code in the Click event of the command button:

private void button1_Click(object sender, System.EventArgs e)
{
// Compare the two files that referenced in the textbox controls.
if (FileCompare(this.textBox1.Text, this.textBox2.Text))
{
MessageBox.Show("Files are equal.");
}
else
{
MessageBox.Show("Files are not equal.");
}
}

Save and then run the sample.
Supply the full paths to the two files in the textboxes, and then click the command button.
```

Top Experts
Last 24hrsThis month
 OriginalGriff 295 Jochen Arndt 155 ppolymorphe 145 F-ES Sitecore 145 Richard Deeming 135
 OriginalGriff 5,683 Karthik Bangalore 3,335 ppolymorphe 3,262 Maciej Los 2,872 Richard Deeming 2,695