def test_Get_Hi(self): print('test_Get_Low') e = EqualTemperament() expecteds = [261,277,293,311,329,349,369,391,415,440,466,493] for p in range(PitchClass.Max+1): print(e.GetFrequency(p, 5+1)) self.assertIn(math.floor(e.GetFrequency(p, 5+1)), [math.floor(expecteds[p]*2), math.floor(expecteds[p]*2)+1])
def test_Get_MinOctave(self): print('test_Get_MinOctave') e = EqualTemperament() expecteds = [261,277,293,311,329,349,369,391,415,440,466,493] for p in range(PitchClass.Max+1): print(e.GetFrequency(p, 0)) self.assertEqual(math.floor(expecteds[p]/math.pow(2,5)), math.floor(e.GetFrequency(p, 0)))
def test_Get_MaxOctave(self): print('test_Get_MaxOctave') e = EqualTemperament() expecteds = [8372,8869,9397,9956,10548,11175,11839,12543] for p in range(PitchClass.Max+1): if p + (10 * (PitchClass.Max+1)) < 128: print(e.GetFrequency(p, 10)) self.assertEqual(expecteds[p], math.floor(e.GetFrequency(p, 10)))
def test_Get_OutOfRange_Pitch_Max(self): e = EqualTemperament() with self.assertRaises(ValueError) as ex: e.GetFrequency(12, 5) self.assertIn( f'引数pitchClassは{PitchClass.Min}〜{PitchClass.Max}までの整数値にしてください。', str(ex.exception))
def test_Get_Invalid_Type_OctaveClass(self): e = EqualTemperament() with self.assertRaises(TypeError) as ex: e.GetFrequency(9, 'octave') self.assertIn('引数octaveはint型にしてください。', str(ex.exception))
def test_Get_Invalid_Type_PitchClass(self): e = EqualTemperament() with self.assertRaises(TypeError) as ex: e.GetFrequency('pitch', 5) self.assertIn('引数pitchClassはint型にしてください。', str(ex.exception))
def test_Get_OutOfRange_Octave_Max(self): e = EqualTemperament() with self.assertRaises(ValueError) as ex: e.GetFrequency(9, 11) self.assertIn('引数octaveは0〜10の値にしてください。', str(ex.exception))
def test_Get_OutOfRange_Octave_Max(self): e = EqualTemperament() with self.assertRaises(ValueError) as ex: e.GetFrequency(9, 11) self.assertIn('ノート番号が0〜127の範囲外になりました。', str(ex.exception))