def setUp(self): self.s1 = CompoundSineSource([dict(freq=4, amp=0.5, phase = 3 * pi / 2), dict(freq=1, amp=2, phase = 3 * pi / 2)]) self.s2 = CompoundSineSource([dict(freq=4, amp=0.5, phase = 3 * pi / 2), dict(freq=1, amp=2, phase = 3 * pi / 2)], normalize=False, length=self.s1.rate)
class CompoundSineSourceTest(unittest.TestCase): def setUp(self): self.s1 = CompoundSineSource([dict(freq=4, amp=0.5, phase = 3 * pi / 2), dict(freq=1, amp=2, phase = 3 * pi / 2)]) self.s2 = CompoundSineSource([dict(freq=4, amp=0.5, phase = 3 * pi / 2), dict(freq=1, amp=2, phase = 3 * pi / 2)], normalize=False, length=self.s1.rate) def test_read(self): second = list(islice(self.s1.read(), 0, self.s1.rate)) self.assertAlmostEqual(second[0][0], -1.0) another_second = list(self.s2.read()) self.assertAlmostEqual(another_second[0][0], -2.5) self.assertEqual(len(second), len(another_second))