private AcoustID.FingerprintAcoustID MakeAcoustIDFinger(string key, string filename) { // resample to 11025Hz IAudioDecoder decoder = new BassDecoder(); try { decoder.Load(filename); ChromaContext context = new ChromaContext(); context.Start(decoder.SampleRate, decoder.Channels); decoder.Decode(context.Consumer, 120); if (context.Finish()) { FingerprintAcoustID fingerprint = new FingerprintAcoustID(); fingerprint.Reference = key; fingerprint.DurationInMS = (long)decoder.Duration * 1000; fingerprint.SignatureInt32 = context.GetRawFingerprint(); return(fingerprint); } } catch (Exception e) { // Probleem waarschijnlijk met file. Console.Error.WriteLine(e.ToString()); } finally { decoder.Dispose(); } return(null); }
public void Test2SilenceRawFp() { short[] zeroes = new short[1024]; ChromaContext ctx = new ChromaContext(ChromaprintAlgorithm.TEST2); ctx.Start(44100, 1); for (int i = 0; i < 130; i++) { ctx.Feed(zeroes, 1024); } ctx.Finish(); int[] fp = ctx.GetRawFingerprint(); Assert.AreEqual(3, fp.Length); Assert.AreEqual(627964279, fp[0]); Assert.AreEqual(627964279, fp[1]); Assert.AreEqual(627964279, fp[2]); }