Hello everyone,

I am looking for a c# library, that would be able to sample the first 10 seconds of a mp3 song and than with a algorithm generate a unique songID from that mp3 song. With that SongID it would be possible to detect if there are several equal songs on a HD.

I have already found: which goes in this direction, but I was not able to make the c++ library run.

I would like that the methode for generating the ID would not use the Internet (No lookup for songname, Artist...) just give me a Unique SongID!

I would be extremly greatfull for any kind of help on this matther! Thanks, Andreas

Re: Visual C# General unique song identifier from an mp3


This doesn't quite answer your question, because it does require the internet - but if you use the "genpuid" app from the MusicDNS downloads, you won't have the same issues getting the c++ library to run with C#. You just need to be able to invoke an external process, and parse the resulting output as XML. If not using the net isn't a strict requirement, that may be good enough for you.

Re: Visual C# General unique song identifier from an mp3

Derek Smyth


Here is an idea. An mp3 file is just made up of bytes like any other file, so you could create a hash of the mp3s bytes, if you find two mp3's with the same hash you have the same file. Two files with equal bytes wil generate equal hash values, so in theory two mp3s that are the same have the same bytes and should create the same hash.

Of course this will depend though... on sampling rate, on any gaps at the start of the track, maybe, but mostly on the sampling rate of the mp3. I have no idea whether a normalised mp3 (i.e. re-encoding the mp3s so it's sampling rate is a common value) would work. In theory it should.

You'd need to look into it, try it out, see how it works with different files, just give it a go and see how likely it is to work. Here's an example of how to generate a hash value for a file using SHA1.

Code Snippet

using System;
using System.Collections.Generic;
using System.Text;

using System.IO;
using System.Security.Cryptography;

namespace HashOfAFile
class Program
static void Main(string[] args)
FileStream file =

new FileStream("C:\\Emails.mdb", FileMode.Open, FileAccess.Read);
byte[] fileAsBytes = new byte[file.Length];
file.Read(fileAsBytes, 0, fileAsBytes.Length);

SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
byte[] hash = sha1.ComputeHash(fileAsBytes, 0, fileAsBytes.Length);


Re: Visual C# General unique song identifier from an mp3


Hi guys,

Interesting ideas, I am certainly gone give it a shut!

Thanks a lot for your inputs!