コード例 #1
0
 def test_logenergy_zero(self):
     _configure_frame()
     amps = [0] * 10
     frames = frame.apply(Signal(amps, 5))
     lenergies = shorttime.log_energy(frames)
     all150 = all(lenergies == -156.53559774527022)
     self.assertTrue(all150)
コード例 #2
0
 def zcr_nocrossing(self, amp):
     _configure_frame()
     signal = Signal([amp]*10, 5)
     frames = frame.apply(signal)
     zerocross = shorttime.zcr(frames, 5)
     allzero = all(zerocross == 0)
     return allzero
コード例 #3
0
 def test_zero_amps(self):
     amps = [0] * 10
     _configure_frame()
     frames = frame.apply(Signal(amps, 5))
     corrs, __ = shorttime.autocorr(frames)
     is_allzero = all(corrs == 0)
     self.assertTrue(is_allzero)
コード例 #4
0
 def test_ncross(self):
     _configure_frame()
     amps = np.array([3, 3, 3, -3, -4, -5, 10, 15, 12, -1])
     fs = 5
     frames = frame.apply(Signal(amps, fs))
     reals = [0, 0.33, 0.33, 0.33, 0.33, 0.33, 0.33, 0.33]
     zerocross = shorttime.zcr(frames, fs)
     abs_err = np.abs(np.array(reals) - zerocross)
     almost_equal = all(abs_err <= 0.01)
     self.assertTrue(almost_equal)
コード例 #5
0
def _make_frames(size, stride, signal=None):
    conf.framing['size'] = size
    conf.framing['stride'] = stride
    signal = Signal(np.arange(-20, 20), 20) if signal is None else signal
    return fr.apply(signal)
コード例 #6
0
def get_frames(signal=None):
    signal = signal01 if signal is None else signal
    return frame.apply(signal)
コード例 #7
0
def _make_simple_frames():
    _configure_frame()
    signal = _make_simple_signal()
    return frame.apply(signal)
コード例 #8
0
 def test_zero_amps_norm(self):
     amps = [0] * 10
     _configure_frame()
     frames = frame.apply(Signal(amps, 5))
     corrs = shorttime.autocorr_norm(frames)
     self.assertTrue(all(cor == 0 for cor in corrs))