Esempio n. 1
0
        public void GetProminentFrequencies_Multiple_Frequencies(params int[] frequencies)
        {
            var sampleRate       = 44100;
            var fftSize          = 1024;
            var amplitude        = 1;
            var frequencyIndices = Enumerable.Range(0, frequencies.Length);
            var sineWaves        = frequencies
                                   .Select(frequency => Generate.Sinusoidal(
                                               sampleRate,
                                               sampleRate,
                                               frequency,
                                               amplitude)
                                           .ToList());
            var samples = frequencyIndices
                          .Select(index =>
                                  sineWaves
                                  .Select(sineWave => sineWave[index])
                                  .Sum())
                          .ToArray();

            var prominentFrequencies = Fingerprinting.GetProminentFrequencies(samples, sampleRate);

            var expectedBins = frequencies.Select(frequency => FrequencyToBin(sampleRate, fftSize, frequency));

            Assert.All(prominentFrequencies, actualBins => Assert.Equal(expectedBins, actualBins));
        }
Esempio n. 2
0
        public void GetProminentFrequencies_Single_Frequency(int frequency)
        {
            var sampleRate = 44100;
            var fftSize    = 1024;
            var amplitude  = 1;
            var samples    = Generate.Sinusoidal(sampleRate, sampleRate, frequency, amplitude);

            var prominentFrequencies = Fingerprinting.GetProminentFrequencies(samples, sampleRate);

            var expectedBin  = FrequencyToBin(sampleRate, fftSize, frequency);
            var expectedBins = new[] { expectedBin };

            Assert.All(prominentFrequencies, actualBins => Assert.Contains(expectedBin, actualBins));
            Assert.All(prominentFrequencies, actualBins => Assert.Equal(expectedBins, actualBins));
        }
Esempio n. 3
0
 static void Main(string[] args)
 {
     // Analyser.AnalysePcmFile(440, "../js/signals/440.pcm");
     // Analyser.AnalyseGenerated(440);
     Fingerprinting.GetProminentFrequencies("../js/signals/almost-blue.pcm");
 }