def __init__(self,agent,voice): self.agent = agent self.voice = voice self.__file = None self.__fileid = None atom.Atom.__init__(self,names='voice',ordinal=voice) self.__private = node.Server(value=piw.makenull(0),change=self.__change) self.set_private(self.__private) self.looper = loop_native.player(agent.aggregator.get_output(voice),agent.domain) agent.clock_cloner.set_output(voice,self.looper.cookie()) self.loop_off = piw.change2(piw.fastchange(self.looper.player(0)),piw.slowchange(utils.changify(self.__off))) self.loop_on = piw.change2(piw.fastchange(self.looper.player(1)),piw.slowchange(utils.changify(self.__on))) self.loop_toggle = piw.change2(piw.fastchange(self.looper.player(3)),piw.slowchange(utils.changify(self.__toggle))) self.loop_once = self.looper.player(2) self.__playing = True self.agent.lights.set_status(self.voice,const.status_active) self[1] = atom.Atom(domain=domain.BoundedFloat(0.0,100.0,0.0,hints=(T('inc',1),T('biginc',10),T('control','updown')),verbinc=10.0),init=100.0,policy=atom.default_policy(self.set_volume),names='volume') self[2] = atom.Atom(domain=domain.BoundedFloat(0.0,100.0,0.0,hints=(T('inc',1),T('biginc',10),T('control','updown')),verbinc=10.0),init=10.0,policy=atom.default_policy(self.set_chop),names='chop') self.looper.set_chop(10.0) self.looper.set_volume(1.0) piw.changelist_connect(agent.loop_on,self.loop_on) piw.changelist_connect(agent.loop_off,self.loop_off) piw.changelist_connect(agent.loop_toggle,self.loop_toggle)
def upgrade_5_0_to_6_0(self, tools, address): root = tools.root(address) events = root.get_node(3) for e in events.iter(): schema = e.get_node(255, 6).get_data() e.ensure_node(255, 6).set_data(piw.makenull(0)) e.ensure_node(255, 6, 1).set_data(schema) e.ensure_node(255, 6, 2).set_data(piw.makebool(False, 0)) return True
def upgrade_2_0_to_3_0(self,tools,address): root = tools.root(address) loop_node = root.get_node(3,254) loop = loop_node.get_data().as_long() loop_node.set_data(piw.makenull(0)) root.ensure_node(5,255,6,1).set_data(piw.makestring(logic.render_term((loop,100.0)),0)) root.ensure_node(5,255,const.meta_domain) root.ensure_node(5,255,const.meta_protocols) root.ensure_node(5,255,const.meta_names).set_data(piw.makestring('voice',0)) return True
def __init__(self,cookie): t = piw.tsd_time() self.__controller_dict = {} self.__state = node.Server(change=self.__change_controller) self.__filter = piw.function1(False,1,1,piw.makenull(0),cookie) self.__setup()
def value2data(self, v, t=0L): if v is None: return piw.makenull(t) raise ValueError('null value %s inappropriate' % str(v))
def value2data(self, v, t=0L): if v is None: return piw.makenull(t) return BoundedInt.value2data(self, v, t)
def value2data(self, v, t=0L): if v is None: return piw.makenull(t) if v is False: return piw.makenull(t) return BoundedFloat.value2data(self, v, t)
def value2data(self, v, t=0L): if v is None: return piw.makenull(t) if v is False: return piw.makenull(t) return Enum.value2data(self, v, t)
def __update(self): if self.__file is None: self.__private.set_data(piw.makenull(0)) return self.__private.set_data(piw.makestring(logic.render_term((self.__file,self.__playing)),0))