public void CreateFingerprintsInsertThenQueryAndGetTheRightResult() { const int SecondsToProcess = 10; const int StartAtSecond = 30; var tagService = new BassTagService(); var info = tagService.GetTagInfo(PathToMp3); var track = new TrackData(info.ISRC, info.Artist, info.Title, info.Album, info.Year, (int)info.Duration); var trackReference = modelService.InsertTrack(track); var hashDatas = fingerprintCommandBuilder .BuildFingerprintCommand() .From(PathToMp3, SecondsToProcess, StartAtSecond) .WithDefaultFingerprintConfig() .UsingServices(bassAudioService) .Hash() .Result; modelService.InsertHashDataForTrack(hashDatas, trackReference); var queryResult = queryFingerprintService.Query(modelService, hashDatas, new DefaultQueryConfiguration()); Assert.IsTrue(queryResult.IsSuccessful); Assert.AreEqual(1, queryResult.ResultEntries.Count); Assert.AreEqual(trackReference, queryResult.ResultEntries[0].Track.TrackReference); }
public void CreateFingerprintsFromDefaultFileAndAssertNumberOfFingerprints() { const int StaticStride = 5115; var tagService = new BassTagService(); var fingerprintCommand = fingerprintCommandBuilder.BuildFingerprintCommand() .From(PathToMp3) .WithFingerprintConfig(config => config.Stride = new IncrementalStaticStride(StaticStride)) .UsingServices(bassAudioService); double seconds = tagService.GetTagInfo(PathToMp3).Duration; int expectedFingerprints = (int)(seconds * fingerprintCommand.FingerprintConfiguration.SampleRate / StaticStride * StaticStride / StaticStride) - 2; // ? new file generates 1 fingerprint less; var fingerprints = ((FingerprintCommand)fingerprintCommand).Fingerprint().Result; Assert.AreEqual(expectedFingerprints, fingerprints.Count); }
public void CreateFingerprintsFromDefaultFileAndAssertNumberOfFingerprints() { const int StaticStride = 5115; var tagService = new BassTagService(); var audioFingerprintingUnit = fingerprintCommandBuilder.BuildFingerprintCommand() .From(PathToMp3) .WithFingerprintConfig(config => { config.Stride = new IncrementalStaticStride(StaticStride, config.SamplesPerFingerprint); }) .UsingServices(bassAudioService); double seconds = tagService.GetTagInfo(PathToMp3).Duration; int samples = (int)(seconds * audioFingerprintingUnit.FingerprintConfiguration.SampleRate); int expectedFingerprints = (samples / StaticStride) - 1; var fingerprints = audioFingerprintingUnit.Fingerprint().Result; Assert.AreEqual(expectedFingerprints, fingerprints.Count); }