forked from M-Labs/artiq
1
0
Fork 0

wavesynth: handle short segments

This commit is contained in:
Robert Jördens 2016-02-22 15:27:47 +01:00
parent 269e9c600c
commit 94584bb8b1
1 changed files with 5 additions and 5 deletions

View File

@ -179,7 +179,7 @@ class SplineSource(CoefficientSource):
x = self.x[ia:ib] x = self.x[ia:ib]
return np.r_[start, x, stop] return np.r_[start, x, stop]
def scale_x(self, x, scale, min_duration=10, min_length=20): def scale_x(self, x, scale, min_duration=1, min_length=20):
"""Enforce, round, and scale x to device-dependent values. """Enforce, round, and scale x to device-dependent values.
Due to minimum duration and/or minimum segment length constraints Due to minimum duration and/or minimum segment length constraints
@ -202,11 +202,11 @@ class SplineSource(CoefficientSource):
dt = np.diff(t.astype(np.int)) dt = np.diff(t.astype(np.int))
valid = np.absolute(dt) >= min_duration valid = np.absolute(dt) >= min_duration
dt = dt[valid] if not np.any(valid):
t = t[np.r_[True, valid]] valid[0] = True
if dt.shape[0] == 1:
dt[0] = max(dt[0], min_length) dt[0] = max(dt[0], min_length)
x_sample = t[:-1]*scale dt = dt[valid]
x_sample = t[:-1][valid]*scale
return x_sample, dt return x_sample, dt
def __call__(self, x): def __call__(self, x):