def test_pitchclass(self): p0 = edo.EDO2_12Pitch(0, 1) self.assertEqual(p0.pitchclass, 0) # use too high number for pitchclass self.assertRaises(ValueError, lambda: edo.EDO2_12Pitch(13)) # use false number for multiply self.assertRaises(ValueError, lambda: edo.EDO2_12Pitch(0, 3))
def test_cents(self): p0 = edo.EDO2_12Pitch(0, 1) p1 = edo.EDO2_12Pitch(1, 1) p2 = edo.EDO2_12Pitch(2, 1) p3 = edo.EDO2_12Pitch(2.5, 1) p4 = edo.EDO2_12Pitch(2.5, 2) self.assertEqual(p0.cents, 0) self.assertEqual(round(p1.cents, 3), 100) self.assertEqual(round(p2.cents, 3), 200) self.assertEqual(round(p3.cents, 3), 250) self.assertEqual(round(p4.cents, 3), 1450)
def __init__(self, n_divisions=48, octaves=3): float_and_oct = tuple(( n // n_divisions, (n % n_divisions) / n_divisions * 12, 2**(n // n_divisions), ) for n in range(n_divisions * octaves)) float_and_oct += tuple(( n // n_divisions, (n % n_divisions) / n_divisions * 12, 2**(n // n_divisions), ) for n in range(-18, 0)) self.available_pitches = tuple( sorted( tuple((edo.EDO2_12Pitch(fl, oc), abjad.NumberedPitch(fl - 15 + (12 * n))) for n, fl, oc in float_and_oct), key=operator.itemgetter(0), )) self.cents_of_available_pitches = tuple( p[0].cents for p in self.available_pitches)
def test_repr(self): p0 = edo.EDO2_12Pitch(0, 1) self.assertEqual(repr(p0), str((p0.pitchclass, p0.multiply)))
def test_factor(self): p0 = edo.EDO2_12Pitch(0, 1) expected_factor = pow(2, 1 / 12) self.assertEqual(p0.factor, expected_factor)