- fixed delay
This commit is contained in:
@@ -4,15 +4,15 @@ import numpy as np
|
||||
class Delay:
|
||||
def __init__(self, dt, delay):
|
||||
nd = int(delay/dt + 0.5)
|
||||
self.delay_line = np.zeros(nd)
|
||||
self.delay_line = np.zeros(nd+1)
|
||||
self.ri = 0
|
||||
self.wi = 0
|
||||
|
||||
def put(self, data):
|
||||
if self.wi >= self.delay_line.size:
|
||||
self.wi = 0
|
||||
self.delay_line[self.wi] = data
|
||||
self.wi += 1
|
||||
if self.wi >= self.delay_line.size:
|
||||
self.wi = 0
|
||||
|
||||
def get(self):
|
||||
self.ri += 1
|
||||
@@ -20,12 +20,11 @@ class Delay:
|
||||
self.ri = 0
|
||||
|
||||
result = self.delay_line[self.ri]
|
||||
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
d = Delay(1, 10)
|
||||
d = Delay(1, 1)
|
||||
|
||||
for i in range(1, 20):
|
||||
d.put(i)
|
||||
|
||||
Reference in New Issue
Block a user