From a1a8eccdbd7d30fffebf76bdc409c150cf240178 Mon Sep 17 00:00:00 2001 From: Dmitry Bogdanov Date: Fri, 23 Dec 2016 17:23:17 +0100 Subject: [PATCH] Add test for all semitones/octaves to HPCP --- test/src/unittest/spectral/test_hpcp.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/src/unittest/spectral/test_hpcp.py b/test/src/unittest/spectral/test_hpcp.py index 978fa3f9a..78384c7b9 100644 --- a/test/src/unittest/spectral/test_hpcp.py +++ b/test/src/unittest/spectral/test_hpcp.py @@ -47,14 +47,15 @@ def testSin440(self): hpcp = HPCP()(freqs, mags) self.assertEqualVector(hpcp, [1.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]) - def testAllSemitones(self): + def testAllSemitonesAllOctaves(self): # Tests whether a spectral peak output of 12 consecutive semitones - # yields a HPCP of all 1's - tonic = 440 - freqs = [(tonic * 2**(x/12.)) for x in range(12)] - mags = [1] * 12 - hpcp = HPCP()(freqs, mags) - self.assertEqualVector(hpcp, [1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.]) + # yields a HPCP of all 1's for octaves 1 to 8 + for octave in [1, 2, 3, 4, 5, 6, 7, 8]: + tonic = 55 * pow(2, octave-1) + freqs = [(tonic * 2**(x/12.)) for x in range(12)] + mags = [1] * 12 + hpcp = HPCP(maxFrequency=14000)(freqs, mags) + self.assertEqualVector(hpcp, [1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.]) def testSubmediantPosition(self): # Make sure that the submediant of a key based on 440 is in the