class RMSTest(unittest.TestCase): def setUp(self): self.p = RMS() self.s = SineSource(freq=1000, amp=0.5) def test_on_sin(self): chunk_len = 100 * self.s.rate / self.s._freq chunk = list(islice(self.s.read(), 0, chunk_len)) self.p.process(chunk) # RMS for sine is Amplitude / sqrt(2) self.assertAlmostEqual(self.p.get_state()["rms"][0], self.s._amp / sqrt(2.0), 3)
def setUp(self): self.p = RMS() self.s = SineSource(freq=1000, amp=0.5)