-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wavesynth: get coefficients.py into useable state
SplineSource() supports spline interpolating multi-channel tabular data, cropping it and generating wavesynth compatible segment data from it. ComposingSplineSource() needs some verification still.
Showing
3 changed files
with
292 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
from artiq.wavesynth import coefficients, compute_samples | ||
|
||
|
||
class TestSplineCoef(unittest.TestCase): | ||
def setUp(self): | ||
self.x = np.arange(5.) | ||
self.y = np.sin(2*np.pi*self.x/5) + np.arange(2)[:, None] | ||
self.s = coefficients.SplineSource(self.x, self.y, order=4) | ||
|
||
def test_get_segment(self): | ||
return list(self.s.get_segment_data(1.5, 3.2, 1/100.)) | ||
|
||
def test_synth(self): | ||
d = self.test_get_segment() | ||
d[0]["trigger"] = True | ||
return compute_samples.Synthesizer(self.y.shape[0], [d, d + d]) | ||
|
||
def drive(self, s): | ||
y = [] | ||
for f in 0, 1, None, 0: | ||
if f is not None: | ||
s.select(f) | ||
y += s.trigger()[0] | ||
return y | ||
|
||
def test_run(self): | ||
return self.drive(self.test_synth()) | ||
|
||
@unittest.skip("manual/visual test") | ||
def test_plot(self): | ||
import cairoplot | ||
y = self.test_run() | ||
x = list(range(len(y))) | ||
cairoplot.scatter_plot("plot.png", [x, y]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters