TODO: Update summary.
Inheritance: IFeatureVectorConsumer
Exemplo n.º 1
0
        public Fingerprinter(FingerprinterConfiguration config, IFFTService fftService)
        {
            m_image = new Image(12);
            if (config == null)
            {
                config = new FingerprinterConfigurationTest1();
            }
            m_image_builder     = new ImageBuilder(m_image);
            m_chroma_normalizer = new ChromaNormalizer(m_image_builder);
            m_chroma_filter     = new ChromaFilter(config.FilterCoefficients, m_chroma_normalizer);
            m_chroma            = new Chroma(MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, m_chroma_filter);
            //m_chroma.set_interpolate(true);

            // TODO: inject IFFTService
            m_fft = new FFT(FRAME_SIZE, OVERLAP, m_chroma, fftService);
            if (config.RemoveSilence)
            {
                m_silence_remover           = new SilenceRemover(m_fft);
                m_silence_remover.Threshold = config.SilenceThreshold;
                m_audio_processor           = new AudioProcessor(SAMPLE_RATE, m_silence_remover);
            }
            else
            {
                m_silence_remover = null;
                m_audio_processor = new AudioProcessor(SAMPLE_RATE, m_fft);
            }
            m_fingerprint_calculator = new FingerprintCalculator(config.Classifiers);
            m_config = config;
        }
Exemplo n.º 2
0
        public Fingerprinter(FingerprinterConfiguration config, IFFTService fftService)
        {
            m_image = new Image(12);
            if (config == null)
            {
                config = new FingerprinterConfigurationTest1();
            }
            m_image_builder = new ImageBuilder(m_image);
            m_chroma_normalizer = new ChromaNormalizer(m_image_builder);
            m_chroma_filter = new ChromaFilter(config.FilterCoefficients, m_chroma_normalizer);
            m_chroma = new Chroma(MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, m_chroma_filter);
            //m_chroma.set_interpolate(true);

            // TODO: inject IFFTService
            m_fft = new FFT(FRAME_SIZE, OVERLAP, m_chroma, fftService);
            if (config.RemoveSilence)
            {
                m_silence_remover = new SilenceRemover(m_fft);
                m_silence_remover.Threshold = config.SilenceThreshold;
                m_audio_processor = new AudioProcessor(SAMPLE_RATE, m_silence_remover);
            }
            else
            {
                m_silence_remover = null;
                m_audio_processor = new AudioProcessor(SAMPLE_RATE, m_fft);
            }
            m_fingerprint_calculator = new FingerprintCalculator(config.Classifiers);
            m_config = config;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Computes the chromagram of an audio file.
        /// </summary>
        /// <param name="decoder">The <see cref="IDecoder"/> instance.</param>
        /// <returns>Chroma image.</returns>
        public static Image ComputeChromagram(IDecoder decoder)
        {
            var image = new Image(12);
            var image_builder = new ImageBuilder(image);

            var chroma_normalizer = new ChromaNormalizer(image_builder);
            var chroma_filter = new ChromaFilter(ChromaFilterCoefficients, chroma_normalizer);
            var chroma = new Chroma(MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, chroma_filter);

            var fft = new FFT(FRAME_SIZE, OVERLAP, chroma, new LomontFFTService());
            var processor = new AudioProcessor(SAMPLE_RATE, fft);

            processor.Reset(decoder.SampleRate, decoder.Channels);
            decoder.Decode(processor, 120);
            processor.Flush();

            return image;
        }
Exemplo n.º 4
0
 public void TestDiff()
 {
     double[] coefficients = { 1.0, -1.0 };
     Image image = new Image(12);
     ImageBuilder builder = new ImageBuilder(image);
     ChromaFilter filter = new ChromaFilter(coefficients, builder);
     double[] d1 = { 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
     double[] d2 = { 1.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
     double[] d3 = { 2.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
     filter.Consume(d1);
     filter.Consume(d2);
     filter.Consume(d3);
     Assert.AreEqual(2, image.Rows);
     Assert.AreEqual(-1.0, image.Get(0, 0));
     Assert.AreEqual(-1.0, image.Get(1, 0));
     Assert.AreEqual(-1.0, image.Get(0, 1));
     Assert.AreEqual(-1.0, image.Get(1, 1));
 }
Exemplo n.º 5
0
        public static Image Compute(string file, IDecoder decoder)
        {
            Image image = new Image(12);
            ImageBuilder image_builder = new ImageBuilder(image);
            ChromaNormalizer chroma_normalizer = new ChromaNormalizer(image_builder);
            ChromaFilter chroma_filter = new ChromaFilter(ChromaFilterCoefficients, chroma_normalizer);
            //Chroma chroma = new Chroma(MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, &chroma_normalizer);
            Chroma chroma = new Chroma(MIN_FREQ, MAX_FREQ, FRAME_SIZE, SAMPLE_RATE, chroma_filter);
            FFT fft = new FFT(FRAME_SIZE, OVERLAP, chroma);
            AudioProcessor processor = new AudioProcessor(SAMPLE_RATE, fft);

            processor.Reset(decoder.SampleRate, decoder.Channels);
            decoder.Decode(processor, 120);
            processor.Flush();

            //ExportImage(image, name);

            return image;
        }
Exemplo n.º 6
0
 public void TestBlur3()
 {
     double[] coefficients = { 0.5, 0.7, 0.5 };
     Image image = new Image(12, 0);
     ImageBuilder builder = new ImageBuilder(image);
     ChromaFilter filter = new ChromaFilter(coefficients, builder);
     double[] d1 = { 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
     double[] d2 = { 1.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
     double[] d3 = { 2.0, 7.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
     double[] d4 = { 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
     filter.Consume(d1);
     filter.Consume(d2);
     filter.Consume(d3);
     filter.Consume(d4);
     Assert.AreEqual(2, image.Rows);
     Assert.AreEqual(1.7, image.Get(0, 0), TestsHelper.EPS);
     Assert.AreEqual(3.399999999999999, image.Get(1, 0), TestsHelper.EPS);
     Assert.AreEqual(10.199999999999999, image.Get(0, 1), TestsHelper.EPS);
     Assert.AreEqual(11.899999999999999, image.Get(1, 1), TestsHelper.EPS);
 }