def testStreamingRegression(self):
        from essentia.streaming import MonoLoader as sMonoLoader, DynamicComplexity as sDynamicComplexity

        filename = join(testdata.audio_dir, "recorded", "techno_loop.wav")
        loader = sMonoLoader(filename=filename, downmix="left", sampleRate=44100)
        dyn = sDynamicComplexity()
        pool = Pool()

        loader.audio >> dyn.signal
        dyn.dynamicComplexity >> (pool, "complexity")
        dyn.loudness >> (pool, "loudness")
        run(loader)

        self.assertAlmostEqual(pool["complexity"], 5.865970134735107, 1e-1)
        self.assertAlmostEqual(pool["loudness"], -21.189722061157227, 1e-1)
Exemple #2
0
    def testRegression(self):
        loader = sMonoLoader(filename=join(testdata.audio_dir, 'recorded',
                                           'techno_loop.wav'),
                             sampleRate=44100)
        rhythm = RhythmExtractor()
        p = Pool()

        loader.audio >> rhythm.signal
        loader.audio >> (p, 'audio.raw')
        rhythm.bpm >> None
        rhythm.bpmIntervals >> None
        rhythm.estimates >> None
        #rhythm.rubatoStart >> None
        #rhythm.rubatoStop >> None
        rhythm.ticks >> (p, 'beats.locationEstimates')

        run(loader)

        gen = VectorInput(p['audio.raw'])

        beatsLoudness = BeatsLoudness(beats=p['beats.locationEstimates'],
                                      frequencyBands=[20, 150])

        gen.data >> beatsLoudness.signal
        beatsLoudness.loudness >> (p, 'beats.loudness')
        beatsLoudness.loudnessBandRatio >> (p, 'beats.loudnessBandRatio')
        run(gen)

        expectedLoudness = []
        expectedLoudnessBandRatio = []
        for beat in p['beats.locationEstimates']:
            loudness, loudnessBandRatio = self.computeSingleBeatLoudness(
                beat, p['audio.raw'], 44100)
            expectedLoudness.append(loudness)
            expectedLoudnessBandRatio.append(loudnessBandRatio)

    # The values below where extracted from running essentia-1.0  cpp tests
    # on some platform. This results cause the test to fail, and there is no
    # way to be sure they are correct. Therefore a new test has been done
    # where we compare the results of the algorithm with a manually passing
    # the beats to singlebeatloudness std:

    # expectedLoudness = [0.428758, 0.291341, 0.633762, 0.26555, 0.425245, 0.277024, 0.495149, 0.242385, 0.357601, 0.334, 0.323821, 0.232946, 0.528381, 0.200571, 0.437708, 0.167769, 0.584228, 0.392591, 0.530719, 0.296724, 0.550218, 0.332743, 0.501887, 0.310001, 0.403775, 0.29342, 0.578137, 0.306543, 0.470718, 0.690108, 0.0089495, 0.372516, 0.180331, 0.253785, 0.298147, 0.290077, 0.447453, 0.536407, 0.257739, 0.587473, 0.526467, 0.415834, 0.259945, 0.48784, 0.440733, 0.462674, 0.279204]
    # expectedLoudnessBass = [0.928696, 0.127746, 0.681139, 0.0506813, 0.947531, 0.0654974, 0.822909, 0.0516866, 0.781132, 0.134502, 0.74214, 0.0559918, 0.870337, 0.0795841, 0.825638, 0.0935618, 0.875636, 0.11054, 0.515007, 0.0459782, 0.681463, 0.0269587, 0.755229, 0.0620431, 0.711997, 0.127048, 0.713851, 0.0255558, 0.700511, 0.754544, 0.452143, 0.745394, 0.0926197, 0.113369, 0.0516325, 0.0871752, 0.00407939, 0.779901, 0.0498086, 0.677019, 0.0714908, 0.368265, 0.0453059, 0.51892, 0.0210914, 0.63086, 0.069424]

        self.assertAlmostEqualVector(p['beats.loudness'], expectedLoudness)
        self.assertAlmostEqualVector(p['beats.loudnessBandRatio'],
                                     expectedLoudnessBandRatio)
    def testStreamingRegression(self):
        from essentia.streaming import MonoLoader as sMonoLoader, \
                                       DynamicComplexity as sDynamicComplexity

        filename = join(testdata.audio_dir, 'recorded', 'techno_loop.wav')
        loader = sMonoLoader(filename=filename, downmix='left', sampleRate=44100)
        dyn = sDynamicComplexity()
        pool = Pool()

        loader.audio >> dyn.signal
        dyn.dynamicComplexity >> (pool, 'complexity')
        dyn.loudness >> (pool, 'loudness')
        run(loader)

        self.assertAlmostEqual(pool['complexity'], 5.865970134735107, 1e-1)
        self.assertAlmostEqual(pool['loudness'], -21.189722061157227, 1e-1)
    def testStreamingRegression(self):
        from essentia.streaming import MonoLoader as sMonoLoader, \
                                       DynamicComplexity as sDynamicComplexity

        filename = join(testdata.audio_dir, 'recorded', 'techno_loop.wav')
        loader = sMonoLoader(filename=filename, downmix='left', sampleRate=44100)
        dyn = sDynamicComplexity()
        pool = Pool()

        loader.audio >> dyn.signal
        dyn.dynamicComplexity >> (pool, 'complexity')
        dyn.loudness >> (pool, 'loudness')
        run(loader)

        self.assertAlmostEqual(pool['complexity'], 5.865970134735107, 1e-1)
        self.assertAlmostEqual(pool['loudness'], -21.189722061157227, 1e-1)
    def testRegression(self):
        loader = sMonoLoader(filename=join(testdata.audio_dir, 'recorded', 'techno_loop.wav'),
                             sampleRate=44100)
        rhythm = RhythmExtractor()
        p = Pool()

        loader.audio >> rhythm.signal
        loader.audio >> (p, 'audio.raw')
        rhythm.bpm >> None
        rhythm.bpmIntervals >> None
        rhythm.estimates >> None
        #rhythm.rubatoStart >> None
        #rhythm.rubatoStop >> None
        rhythm.ticks >> (p, 'beats.locationEstimates')

        run(loader)

        gen = VectorInput(p['audio.raw'])

        beatsLoudness = BeatsLoudness(beats=p['beats.locationEstimates'],
                                      frequencyBands = [20,150])

        gen.data >> beatsLoudness.signal
        beatsLoudness.loudness >> (p, 'beats.loudness')
        beatsLoudness.loudnessBandRatio >> (p, 'beats.loudnessBandRatio')
        run(gen);

        expectedLoudness = []
        expectedLoudnessBandRatio = []
        for beat in p['beats.locationEstimates']:
            loudness, loudnessBandRatio = self.computeSingleBeatLoudness(beat,p['audio.raw'], 44100)
            expectedLoudness.append(loudness)
            expectedLoudnessBandRatio.append(loudnessBandRatio)

       # The values below where extracted from running essentia-1.0  cpp tests
       # on some platform. This results cause the test to fail, and there is no
       # way to be sure they are correct. Therefore a new test has been done
       # where we compare the results of the algorithm with a manually passing
       # the beats to singlebeatloudness std:

       # expectedLoudness = [0.428758, 0.291341, 0.633762, 0.26555, 0.425245, 0.277024, 0.495149, 0.242385, 0.357601, 0.334, 0.323821, 0.232946, 0.528381, 0.200571, 0.437708, 0.167769, 0.584228, 0.392591, 0.530719, 0.296724, 0.550218, 0.332743, 0.501887, 0.310001, 0.403775, 0.29342, 0.578137, 0.306543, 0.470718, 0.690108, 0.0089495, 0.372516, 0.180331, 0.253785, 0.298147, 0.290077, 0.447453, 0.536407, 0.257739, 0.587473, 0.526467, 0.415834, 0.259945, 0.48784, 0.440733, 0.462674, 0.279204]
       # expectedLoudnessBass = [0.928696, 0.127746, 0.681139, 0.0506813, 0.947531, 0.0654974, 0.822909, 0.0516866, 0.781132, 0.134502, 0.74214, 0.0559918, 0.870337, 0.0795841, 0.825638, 0.0935618, 0.875636, 0.11054, 0.515007, 0.0459782, 0.681463, 0.0269587, 0.755229, 0.0620431, 0.711997, 0.127048, 0.713851, 0.0255558, 0.700511, 0.754544, 0.452143, 0.745394, 0.0926197, 0.113369, 0.0516325, 0.0871752, 0.00407939, 0.779901, 0.0498086, 0.677019, 0.0714908, 0.368265, 0.0453059, 0.51892, 0.0210914, 0.63086, 0.069424]


        self.assertAlmostEqualVector(p['beats.loudness'], expectedLoudness)
        self.assertAlmostEqualVector(p['beats.loudnessBandRatio'], expectedLoudnessBandRatio)