diff --git a/fakebox/dsp.py b/fakebox/dsp.py index 7de6117..7c6ea64 100644 --- a/fakebox/dsp.py +++ b/fakebox/dsp.py @@ -5,9 +5,10 @@ from fakebox.conf import DEFAULT_SAMPLE_RATE, DEFAULT_BIT_N DSPFloat = np.float64 +DSPEpislon = DSPFloat(1e-8) DSPZero = DSPFloat(0.0) DSPOne = DSPFloat(1.0) -DSPOne_L = DSPFloat(1.0 - 1e-8) +DSPOne_L = DSPFloat(1.0) - DSPEpislon class DSPContext(object): diff --git a/fakebox/stdlib/env.py b/fakebox/stdlib/env.py index c8d1272..876abe6 100644 --- a/fakebox/stdlib/env.py +++ b/fakebox/stdlib/env.py @@ -1,4 +1,4 @@ -from fakebox.dsp import DSPObj, DSPZero +from fakebox.dsp import DSPObj, DSPZero, DSPEpislon class LineSegs(DSPObj): @@ -34,7 +34,7 @@ def _tick(self, ins): time_points.append(time_points[-1] + dur) - if running_time > time_points[-1]: + if running_time > time_points[-1] - DSPEpislon: self.running = False return DSPZero diff --git a/fakebox/stdlib/math.py b/fakebox/stdlib/math.py index 6c4d386..1aae860 100644 --- a/fakebox/stdlib/math.py +++ b/fakebox/stdlib/math.py @@ -1,7 +1,7 @@ import numpy as np from fakebox.dsp import DSPObj, DSPZero, DSPOne -def Sum(DSPObj): +class Sum(DSPObj): def __init__(self, c=None, in_n=None): @@ -22,7 +22,7 @@ def _tick(self, ins): return res -def Mul(DSPObj): +class Mul(DSPObj): def __init__(self, c=None, in_n=None): @@ -43,7 +43,7 @@ def _tick(self, ins): return res -def Neg(DSPObj): +class Neg(DSPObj): def __init__(self):