Пример #1
0
 def __add(self, time, value):
     print 'add tempo change to', value, 'at', time
     time = action.mass_quantity(time)
     value = action.mass_quantity(value)
     print 'add tempo change to', value, 'at', time
     c = TempoChange(self.beatclock)
     self.beat_changes.add(c)
     c.setup(time, value)
Пример #2
0
 def __del(self, time, value):
     time = action.mass_quantity(time)
     value = action.mass_quantity(value)
     print 'del tempo change to', value, 'at', time
     for (i, c) in self.beat_changes.iteritems():
         if c.compare(time, value):
             del self.beat_changes[i]
             c.clear()
             return
Пример #3
0
    def __map_channel(self, subject, cfrom, cto):
        cfrom = int(action.mass_quantity(cfrom))
        cto = int(action.mass_quantity(cto))
        if cfrom < 1 or cfrom > 16:
            return errors.invalid_thing(str(cfrom), 'map')
        if cto < 1 or cto > 16:
            return errors.invalid_thing(str(cto), 'map')

        new_mapping = []
        new_mapping.append((cfrom, cto))
        for m in self.__current_channel_mapping():
            if m[0] != cfrom:
                new_mapping.append(m)

        self.__set_channel_mapping(new_mapping)
Пример #4
0
 def __set_course_int(self,subject,course,interval):
     (typ,id) = action.crack_ideal(action.arg_objects(course)[0])
     course = int(id)
     ints = action.mass_quantity(interval)
     print 'set course',course,'ints',ints
     self.controller.set_course_steps(int(course),ints)
     return action.nosync_return()
Пример #5
0
    def __record(self,subject,duration,mode):

        duration = action.mass_quantity(duration)
        mode = self.__crack_mode(mode)

        if not self.__schedready:
            print 'no scheduler'
            return async.success(errors.state_error1('scheduler','use'))

        result,started,done = self.recorder.record_start(duration)

        if result==record_err_no_clock:
            print 'metronome isnt started'
            return async.success(errors.state_error1('metronome','start'))

        if result==record_err_in_prog:
            print 'recording already in progress'
            return async.success(errors.message('recording already in progress'))

        id = self.library.nextid()
        if not self.__is_overdub_enabled():
            self.__unplay_auto()

        print 'recording',duration,'bars',id

        def trigger_ok(r,trigger):
            cookie = self.player.load(id,r,0)
            event,status = self.verb_defer(3,(True,trigger,2,mode),trigger,None,self.cookie_arg(id))
            self.player.unload(cookie,False)
            self[5].update()
            print 'trigger created',trigger,'cookie is', cookie

        def trigger_failed(msg):
            print 'cannot create trigger',msg

        def started_ok(r):
            start = r.get_tag(3).as_float()
            duration = r.get_tag(4).as_float()
            desc = "take %s at song beat %g every %g song beat" % (id,start,duration)
            self.library.write(recorder_native.recording(),id)
            trigger = self.__scheduler.create_trigger('schema("%s",[m(3,%f,%f)])' % (desc,duration,start%duration))
            trigger.setCallback(trigger_ok,r).setErrback(trigger_failed)
            print 'record started: start=',start,'duration=',duration

        def started_failed(msg):
            print 'record failed:',msg
            
        def done_ok(r):
            print 'record completed: signals=',r.signals(),'wires=',r.wires(),'start=',r.get_tag(2)
            self.library.write(r,id)

        def done_failed(msg):
            print 'record failed:',msg
            self.__unplay_auto()
            
        done.setCallback(done_ok).setErrback(done_failed)
        started.setCallback(started_ok).setErrback(started_failed)

        return action.nosync_return()
Пример #6
0
    def __uncreate_output(self,subj,mass):
        id = int(action.mass_quantity(mass))
        channel = self[2].get_channel(id)

        if channel is None:       
            thing='output %s' %str(id)
            return async.success(errors.invalid_thing(thing,'un create'))

        self[2].del_channel(id)
Пример #7
0
    def __create3(self,subj,voice):
        id=int(action.mass_quantity(voice))
        voice = self[5].get_voice(id)

        if voice is not None:
            thing='voice %s' %str(id)
            return async.success(errors.already_exists(thing,'create'))
        
        self[5].create_voice(id)
Пример #8
0
    def __uncreate_connector(self, subj, mass):
        id = int(action.mass_quantity(mass))
        connector = self[4].get_connector(id)

        if connector is None:
            thing = 'connector %s' % str(id)
            return async .success(errors.invalid_thing(thing, 'un create'))

        self[4].del_connector(id)
Пример #9
0
    def __kadd(self,subject,k,course=None):
        k = str(int(action.mass_quantity(k)))

        if course:
            course = int(action.mass_quantity(course))-1
        else:
            course = 0

        self.controller.ensure(course+1)
        coursekeys = self.__getkeys()

        while len(coursekeys) <= course:
            coursekeys.append([])

        for i in range(0,len(coursekeys)):
            if k in coursekeys[i]:
                coursekeys[i].remove(k)

        coursekeys[course].append(k)

        self.__setkeys(coursekeys)
Пример #10
0
    def __kclear(self,subject,course):
        if course is None:
            self.controller.setlist('courselen',[0])
            self.__set_mapping(())
            return

        course = int(action.mass_quantity(course))-1
        coursekeys = self.__getkeys()

        if len(coursekeys) > course:
            coursekeys[course] = []

        self.__setkeys(coursekeys)
Пример #11
0
    def __radd(self,subject,f,t,course):
        if course:
            course = int(action.mass_quantity(course))-1
        else:
            course = 0

        f = int(action.mass_quantity(f))
        t = int(action.mass_quantity(t))
        r = map(str,range(f,t+1))

        self.controller.ensure(course+1)
        coursekeys = self.__getkeys()

        while len(coursekeys) <= course:
            coursekeys.append([])

        coursekeys[course] = []

        for i in range(0,len(coursekeys)):
            coursekeys[i] = removelist(coursekeys[i],r)

        coursekeys[course].extend(r)
        self.__setkeys(coursekeys)
Пример #12
0
 def __set_midi_control(self, ctx, subj, ctl, val):
     c = action.mass_quantity(ctl)
     to = action.abstract_wordlist(val)[0]
     c_val = int(c)
     to_val = int(to)
     if c_val < 0 or c_val > 127:
         return errors.invalid_thing(c, 'set')
     if to_val < 0 or to_val > 127:
         return errors.invalid_thing(to, 'set')
     return piw.trigger(
         self.host.change_cc(),
         utils.makedict_nb(
             {
                 'ctl': piw.makelong_nb(c_val, 0),
                 'val': piw.makelong_nb(to_val, 0)
             }, 0)), None
Пример #13
0
    def verb2_20_connect(self, subject, src, dst, dst_chan, src_chan):
        """
        connect([],global_connect,role(None,[or([concrete],[composite([descriptor])])]),role(to,[concrete,singular]),option(into,[mass([channel])]),option(from,[abstract]))
        """

        if dst_chan is not None:
            dst_chan = int(action.mass_quantity(dst_chan))

        if src_chan is not None:
            src_chan = action.abstract_string(src_chan)
            src_match = re.match('^channel\s+([\d\.]+)$', src_chan,
                                 re.IGNORECASE)
            if src_match:
                src_chan = src_match.group(1)
            else:
                yield async .Coroutine.failure("%s is not valid" % src_chan)

        to_descriptor = (action.concrete_object(dst), None)
        to_descriptor = self.database.to_database_term(to_descriptor)

        for ff in action.arg_objects(src):
            if action.is_concrete(ff):
                from_descriptors = [(action.crack_concrete(ff), None)]
            else:
                from_descriptors = action.crack_composite(
                    ff, action.crack_descriptor)

            from_descriptors = self.database.to_database_term(from_descriptors)

            r = plumber.plumber(self.database,
                                to_descriptor,
                                from_descriptors,
                                dst_chan=dst_chan,
                                src_chan=src_chan)
            yield r
            if not r.status():
                yield async .Coroutine.failure(*r.args(), **r.kwds())

        yield async .Coroutine.success()
Пример #14
0
 def __show_blue(self, ctx, subj, b, v, s):
     return self.__show_colour(None, None, float(action.mass_quantity(v)),
                               action.mass_quantity(s))
Пример #15
0
 def __minimise(self, subj, pedal):
     pedal = int(action.mass_quantity(pedal))
     self.keyboard.learn_pedal_min(pedal)
     self.__setpedal(pedal)
Пример #16
0
 def __unset_breath_modulation(self, a, subj, course):
     number = int(action.mass_quantity(course))
     self.strumconfig.remove_breath_course(number)
     self.__update_strumconfig()
Пример #17
0
 def __show_blue(self,ctx,subj,b,v,s):
     return self.__show_colour(None,None,float(action.mass_quantity(v)),action.mass_quantity(s))
Пример #18
0
 def __playnvl(self,ctx,subj,note,velocity,s):
     note = action.mass_quantity(note)
     velocity = action.mass_quantity(velocity)
     length = max(1,int(1000000*action.mass_quantity(s)))
     print 'play note',note,'velocity',velocity,'sec',s,'us',length
     return self.nplayer.play(note,velocity,length),None
Пример #19
0
 def __set_open_course_key(self, a, subj, key, course):
     number = int(action.mass_quantity(course))
     key = int(action.mass_quantity(key))
     self.strumconfig.set_open_course_key(number, key)
     self.__update_strumconfig()
Пример #20
0
 def set_time_secs(self, subj, dummy, arg):
     time_secs = action.mass_quantity(arg)
     print "set time secs", arg, "->", time_secs, self.id()
     # time in seconds is -ve for now!
     self[1].get_policy().set_value(-time_secs)
     return action.nosync_return()
Пример #21
0
 def __create_output(self,subj,mass):
     id = int(action.mass_quantity(mass))
     e = self[2].create_channel(id)
     if not isinstance(e,AudioOutput):
         return e
Пример #22
0
 def __set_open_course_physical(self, a, subj, phys, course):
     number = int(action.mass_quantity(course))
     open_col, open_row = action.coord_value(phys)
     self.strumconfig.set_open_course_physical(number, open_col, open_row)
     self.__update_strumconfig()
Пример #23
0
 def __add_strum_key(self, a, subj, phys, course):
     number = int(action.mass_quantity(course))
     strum_col, strum_row = action.coord_value(phys)
     self.strumconfig.add_key_course(number, strum_col, strum_row)
     self.__update_strumconfig()
Пример #24
0
 def __playnv(self,ctx,subj,note,velocity):
     note = action.mass_quantity(note)
     velocity = action.mass_quantity(velocity)
     print 'play note',note,'velocity',velocity
     return self.nplayer.play(note,velocity,500000),None
Пример #25
0
 def __clear_strum_key(self, a, subj, course):
     number = int(action.mass_quantity(course))
     self.strumconfig.clear_key_course(number)
     self.__update_strumconfig()
Пример #26
0
 def set_time_beats(self, subj, dummy, arg):
     time_beats = action.mass_quantity(arg)
     print "set time beats", arg, "->", time_beats, self.id()
     self[1].get_policy().set_value(time_beats)
     return action.nosync_return()
Пример #27
0
 def __create_connector(self, subj, mass):
     id = int(action.mass_quantity(mass))
     e = self[4].create_connector(id)
     if not isinstance(e, Connector):
         return e