def testNumChordsEqualsHpcpSize(self): # this test has been introduced since it was reported that # chordsdetection may reveal errors on the scheduling yielding more # chords than hpcps are computed from essentia.streaming import MonoLoader, DCRemoval, FrameCutter,\ EqualLoudness, Windowing, Spectrum, SpectralPeaks, SpectralWhitening,\ HPCP audiofile = 'musicbox.wav' filename = filename = join(testdata.audio_dir, 'recorded', audiofile) p = Pool() loader = MonoLoader(filename=filename) dc = DCRemoval() eqloud = EqualLoudness() fc = FrameCutter(frameSize=2048, hopSize=1024, silentFrames="noise") win = Windowing(size=2048) spec = Spectrum() specPeaks = SpectralPeaks() specWhite = SpectralWhitening() hpcp = HPCP() chords = ChordsDetection(hopSize=1024) loader.audio >> dc.signal dc.signal >> eqloud.signal eqloud.signal >> fc.signal fc.frame >> win.frame win.frame >> spec.frame spec.spectrum >> specPeaks.spectrum spec.spectrum >> specWhite.spectrum specPeaks.frequencies >> specWhite.frequencies specPeaks.magnitudes >> specWhite.magnitudes specWhite.magnitudes >> hpcp.magnitudes specPeaks.frequencies >> hpcp.frequencies hpcp.hpcp >> chords.pcp chords.chords >> (p, 'chords') chords.strength >> None hpcp.hpcp >> (p, 'hpcp') run(loader) self.assertEqual(len(p['chords']), len(p['hpcp']))
def testInvalidParam(self): self.assertConfigureFails(ChordsDetection(), {'sampleRate': 0}) self.assertConfigureFails(ChordsDetection(), {'hopSize': 0}) self.assertConfigureFails(ChordsDetection(), {'windowSize': 0})