Skip to content

Commit

Permalink
Add test for all semitones/octaves to HPCP
Browse files Browse the repository at this point in the history
  • Loading branch information
dbogdanov committed Dec 23, 2016
1 parent 2e4e1f4 commit a1a8ecc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/src/unittest/spectral/test_hpcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1a8ecc

Please sign in to comment.