public void DurationOfReadAudioIsCorrect()
        {
            var audioSamples = bassAudioService.ReadMonoSamplesFromFile(PathToMp3, SampleRate);

            Assert.AreEqual(193.07, audioSamples.Duration, 0.01);
            Assert.AreEqual(PathToMp3, audioSamples.Origin);
        }
Example #2
0
        public void DurationOfReadAudioIsCorrect()
        {
            var audioSamples = bassAudioService.ReadMonoSamplesFromFile(PathToMp3, SampleRate);

            Assert.IsTrue(Math.Abs(232.80333 - audioSamples.Duration) < Epsilon);
            Assert.AreEqual(PathToMp3, audioSamples.Origin);
        }
        public void ComparePreStoredSameplesWithCurrentlyReadAudioSamples()
        {
            BinaryFormatter serializer = new BinaryFormatter();

            using (Stream stream = new FileStream(PathToSamples, FileMode.Open, FileAccess.Read))
            {
                float[] samples     = (float[])serializer.Deserialize(stream);
                float[] readSamples = bassAudioService.ReadMonoSamplesFromFile(PathToMp3, SampleRate);
                Assert.AreEqual(samples.Length, readSamples.Length);
                for (int i = 0; i < samples.Length; i++)
                {
                    Assert.IsTrue(Math.Abs(samples[i] - readSamples[i]) < 0.0000001);
                }
            }
        }
Example #4
0
        public void CreateFingerprintsFromFileAndFromAudioSamplesAndGetTheSameResultTest()
        {
            const int SecondsToProcess = 20;
            const int StartAtSecond    = 15;
            var       audioService     = new BassAudioService();

            float[] samples = audioService.ReadMonoSamplesFromFile(PathToMp3, SampleRate, SecondsToProcess, StartAtSecond);

            var hashDatasFromFile = fingerprintCommandBuilder
                                    .BuildFingerprintCommand()
                                    .From(PathToMp3, SecondsToProcess, StartAtSecond)
                                    .WithDefaultFingerprintConfig()
                                    .UsingServices(bassAudioService)
                                    .Hash()
                                    .Result;

            var hashDatasFromSamples = fingerprintCommandBuilder
                                       .BuildFingerprintCommand()
                                       .From(samples)
                                       .WithDefaultFingerprintConfig()
                                       .UsingServices(bassAudioService)
                                       .Hash()
                                       .Result;

            AssertHashDatasAreTheSame(hashDatasFromFile, hashDatasFromSamples);
        }
        private void RecodeFileToWaveFile(string tempFile)
        {
            var samples = bassAudioService.ReadMonoSamplesFromFile(PathToMp3, 5512);

            bassWaveFileUtility.WriteSamplesToFile(samples.Samples, 5512, tempFile);
        }