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 __init__(self, atom, data_domain, init, transient, handler, stream_policy=None, clock=True): self.__stream_policy = stream_policy or ThrottleStreamPolicy(500) self.__handler = handler self.__slow_handler = utils.fastchange(self.__handler) self.__ctl_handler = piw.change2( self.__slow_handler, piw.slowchange(utils.changify(self.__control))) self.__clock_domain = piw.clockdomain_ctl() self.__clock_domain.set_source(piw.makestring('*', 0L)) self.__clock = piw.clocksink() self.__clock_domain.sink(self.__clock, 'FastPolicy') self.__upstream = None self.__backend = None self.__correlator = None self.__ctrl = None ConnectablePolicyImpl.__init__(self, atom, data_domain, init, clock, node.Server(transient=transient), False) self.data_node().set_change_handler(self.__slow_handler) self.data_node().set_data(self.get_domain().value2data(init))
def __ocreate(self, ctx, subj, dummy, arg): val = float(action.abstract_string(arg)) print 'ocreate', ctx, subj, arg, val if val < -72 or val > 72: return async .failure('offset inappropriate') b = piw.change2( self.bender.set_offset(), piw.slowchange_polled( utils.changify(self[9].get_policy().set_data), 5000)) return piw.trigger(b, piw.makefloat_nb(val, 0)), None