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, agent, data=None): self.__agent = agent node.Server.__init__(self, creator=self.__create) self.__setter = piw.fastchange(self.__agent.model.set_event()) self.__agent.model.event_set( piw.make_change_nb(utils.slowchange(self.model_changed))) self.__agent.model.events_cleared( piw.make_change_nb(utils.slowchange(self.model_cleared)))
def __set_playing(self,p): self.__playing = p if p: self.agent.lights.set_status(self.voice,const.status_active) else: self.agent.lights.set_status(self.voice,const.status_inactive) c = self.looper.player(1 if p else 0) fc = piw.fastchange(c) fc(piw.makefloat_bounded(1,0,0,1,0))
def __do_play_now(self,arg,mode): cookie = self.__load(arg,1) if not cookie: thing= 'take %s' %str(arg) return async.success(errors.invalid_thing(thing,'play')) f = self.player.player(cookie,mode) ff = piw.fastchange(f) ff(piw.makefloat_bounded_nb(1,0,0,1,0)) self.player.unload(cookie,False) return action.nosync_return()
def __fastinvoke(self, server, args): f = server.create_action(None, *args) if f is None: return async .failure() ff = piw.fastchange(utils.changify_nb(f[0])) t = piw.tsd_time() ff(piw.makefloat_bounded(1, 0, 0, 1, t)) ff(piw.makefloat_bounded(1, 0, 0, 0, t + 1)) ret = (action.nosync_return(), ) return async .success(action.marshal(ret))
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 = piw.fastchange(self.__handler) self.__clock_domain = piw.clockdomain_ctl() self.__clock_domain.set_source(piw.makestring('*', 0L)) self.__clock = piw.clocksink() self.__clock_domain.sink(self.__clock, 'TriggerPolicy') self.__upstream = None self.__backend = 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(0))
def __ochange(self, v): fc = piw.fastchange(self.bender.set_offset()) fc(piw.makefloat_nb(v, 0)) return True
def fastchange(c): return piw.fastchange(changify_nb(c))
def detach(self): self.__selector.detach() self.__controller.clone.clear_output(self.__index + 1) fc = piw.fastchange(self.__gate) fc(piw.makefloat_bounded(1, 0, 0, 1, 0))
def __play_change(self,d): if d.is_bool(): fc = piw.fastchange(self.model.set_playstop()) fc(d)
def __doubletap_change(self,v): fc = piw.fastchange(self.__agent.view.set_doubletap()) fc(piw.makefloat(v,0)) return True
def __fraction_change(self,v): fc = piw.fastchange(self.__agent.model.set_stepdenominator()) fc(piw.makefloat(v,0)) return True
def __step_change(self,v): fc = piw.fastchange(self.__agent.model.set_stepnumerator()) fc(piw.makefloat(v,0)) return True
def __end_change(self,v): fc = piw.fastchange(self.__agent.model.set_loopend()) fc(piw.makelong(v-1,0)) return True
def __rchange(self, v): fc = piw.fastchange(self.bender.set_range()) fc(piw.makefloat(v, 0)) return True
def __start_change(self,v): fc = piw.fastchange(self.__agent.model.set_loopstart()) fc(piw.makelong_nb(v-1,0)) return True