コード例 #1
0
    def testDisplay(self):
        n = 257
        centerFrequencies = np.array([125, 500, 1000, 2000, 4000],
                                     dtype=np.float)
        samplingRate = 16000
        filterbank = FilterBank(n, centerFrequencies, samplingRate)
        fig = filterbank.display(merged=False)
        plt.show(block=False)
        time.sleep(1.0)
        plt.close(fig)
        fig = filterbank.display(merged=True)
        plt.show(block=False)
        time.sleep(1.0)
        plt.close(fig)

        n = 257
        scales = np.array([1.0, 0.5, 0.25, 0.5, 0.05])
        centerFrequencies = np.array([125, 500, 1000, 2000, 4000],
                                     dtype=np.float)
        samplingRate = 16000
        filterbank = FilterBank(n, centerFrequencies, samplingRate)
        fig = filterbank.display(scales, merged=False)
        plt.show(block=False)
        time.sleep(1.0)
        plt.close(fig)
        fig = filterbank.display(scales, merged=True)
        plt.show(block=False)
        time.sleep(1.0)
        plt.close(fig)

        impulse = filterbank.getScaledImpulseResponse(scales)
        fig = plt.figure()
        plt.plot(impulse)
        plt.show(block=False)
        time.sleep(1.0)
        plt.close(fig)
コード例 #2
0
    def testInit(self):
        n = 256
        centerFrequencies = np.array([125, 500, 1000, 2000, 4000],
                                     dtype=np.float)
        samplingRate = 16000
        filterbank = FilterBank(n, centerFrequencies, samplingRate)
        impulse = filterbank.getScaledImpulseResponse()
        self.assertTrue(impulse.ndim == 1)
        self.assertTrue(impulse.shape[0] == n + 1)

        n = 511
        centerFrequencies = np.array([125, 500, 1000, 2000, 4000],
                                     dtype=np.float)
        samplingRate = 16000
        filterbank = FilterBank(n, centerFrequencies, samplingRate)
        impulse = filterbank.getScaledImpulseResponse()
        self.assertTrue(impulse.ndim == 1)
        self.assertTrue(impulse.shape[0] == n)