forked from M-Labs/artiq
1
0
Fork 0

wavesynth: silence is a channel property (closes #348)

This commit is contained in:
Robert Jördens 2016-04-07 21:51:29 +08:00
parent 6a783ead24
commit 13b4929dd8
3 changed files with 9 additions and 8 deletions

View File

@ -198,13 +198,14 @@ class Pdq2:
duration = line["duration"]
trigger = line.get("trigger", False)
for segment, data in zip(segments, line["channel_data"]):
silence = data.pop("silence", False)
if len(data) != 1:
raise ValueError("only one target per channel and line "
"supported")
for target, target_data in data.items():
getattr(segment, target)(
shift=shift, duration=duration, trigger=trigger,
**target_data)
silence=silence, **target_data)
def program(self, program, channels=None):
if channels is None:

View File

@ -103,10 +103,10 @@ _test_program = [
"duration": 40,
"channel_data": [
{"bias": {"amplitude": [.4, .04, -2e-3]}},
{"bias": {
"amplitude": [.5],
{
"bias": {"amplitude": [.5]},
"silence": True,
}},
},
{"dds": {
"amplitude": [.8, .08, -4e-3, 0],
"phase": [.25, .025, .02/40],

View File

@ -57,7 +57,7 @@ class DDS:
return self.amplitude.next()*cos(2*pi*self.phase.next())
class Wave:
class Channel:
def __init__(self):
self.bias = Spline()
self.dds = DDS()
@ -80,7 +80,7 @@ class TriggerError(Exception):
class Synthesizer:
def __init__(self, nchannels, program):
self.channels = [Wave() for _ in range(nchannels)]
self.channels = [Channel() for _ in range(nchannels)]
self.program = program
# line_iter is None: "wait for segment selection" state
# otherwise: iterator on the current position in the frame
@ -104,6 +104,7 @@ class Synthesizer:
while True:
for channel, channel_data in zip(self.channels,
line["channel_data"]):
channel.set_silence(channel_data.get("silence", False))
if "bias" in channel_data:
channel.bias.set_coefficients(
channel_data["bias"]["amplitude"])
@ -115,7 +116,6 @@ class Synthesizer:
channel_data["dds"]["phase"])
if channel_data["dds"].get("clear", False):
channel.dds.phase.clear()
channel.set_silence(channel_data.get("silence", False))
if line.get("dac_divider", 1) != 1:
raise NotImplementedError