LinearPhaseFilter, Delay: fix complex number issues

This commit is contained in:
Sebastien Bourdeauducq 2020-09-27 14:02:51 +08:00
parent 5de9ccf7ee
commit cbf9ff439f
1 changed files with 3 additions and 3 deletions

View File

@ -195,7 +195,7 @@ class LinearPhaseFilter:
def __init__(self, numtaps, *args, **kwargs): def __init__(self, numtaps, *args, **kwargs):
self.numtaps = numtaps self.numtaps = numtaps
self.coef = signal.firwin(numtaps, *args, **kwargs) self.coef = signal.firwin(numtaps, *args, **kwargs)
self.state = np.zeros(self.numtaps - 1) self.state = np.zeros(self.numtaps - 1, dtype="complex64")
def input(self, block): def input(self, block):
output, self.state = signal.lfilter(self.coef, [1.0], block, zi=self.state) output, self.state = signal.lfilter(self.coef, [1.0], block, zi=self.state)
@ -210,8 +210,8 @@ class Delay:
def __init__(self, block_size, delay_amount): def __init__(self, block_size, delay_amount):
self.block_size = block_size self.block_size = block_size
self.delay_amount = delay_amount self.delay_amount = delay_amount
self.output = np.zeros(block_size) self.output = np.zeros(block_size, dtype="complex64")
self.next = np.zeros(delay_amount) self.next = np.zeros(delay_amount, dtype="complex64")
def input(self, block): def input(self, block):
assert(len(block) == self.block_size) assert(len(block) == self.block_size)