コード例 #1
0
ファイル: language_plg.py プロジェクト: shamharoth/EigenD
 def rpc_create_action(self,arg):
     action_term = logic.parse_term(arg)
     result = deferred.create_action(self,action_term)
     yield result
     if not result.status():
         yield async.Coroutine.failure(*result.args(),**result.kwds())
     action = logic.render_termlist(result.args()[0])
     yield async.Coroutine.success(action)
コード例 #2
0
def check_verb_schema(schema):
    clause = logic.parse_term(schema, dict(server='0',self='1',parent='2',grandparent='3',a='0',s='1',p='1',pp='1'))
    roles = [ a.args[0] for a in clause.args[2:] ]
    roles = [ r for r in roles if r != 'none' ]
    mod = clause.args[0]
    subject = clause.args[1]
    vocab.check_word('verb',clause.pred)
    vocab.check_words('role',roles,True)
    vocab.check_words('modifier',mod)
コード例 #3
0
ファイル: upgrade_agentd.py プロジェクト: tylerwood/EigenD
def upgrade_plugins_v0(tools, address):
    n2 = tools.root(address).get_node(2)
    for n in n2.iter(extension=253):
        n3 = n.get_node(255, 6)
        old_term = logic.parse_term(n3.get_string())
        (address, plugin, version, cversion) = old_term.args
        map = tools.mapping.get(address)
        if map:
            (nplugin, nversion, ncversion) = map[1].split(':')
            new_term = logic.make_term(old_term.pred, address, plugin,
                                       nversion, ncversion)
            n3.set_string(str(new_term))

    return True
コード例 #4
0
def check_mode_schema(schema):
    clause = logic.parse_term(
        schema,
        dict(server='0',
             self='1',
             parent='2',
             grandparent='3',
             a='0',
             s='1',
             p='1',
             pp='1'))
    roles = [a.args[0] for a in clause.args[1:]]
    roles = [r for r in roles if r != 'none']
    vocab.check_words('role', roles)
コード例 #5
0
ファイル: upgrade_agentd.py プロジェクト: tylerwood/EigenD
    def upgrade_1_0_0_to_1_0_1(self, tools, address):
        plugins = []
        n2 = tools.get_root(address).get_node(2)
        for n in n2.iter(extension=253, exclude=[254, 255]):
            n3 = n.get_node(255)
            old_term = logic.parse_term(n3.get_data().as_string())
            (address, plugin, version, cversion) = old_term.args
            ncversion = tools.newcversion(address)
            nversion = tools.newrversion(address)
            nplugin = tools.canonical_name(address)
            new_term = logic.make_term('a', address, nplugin, nversion,
                                       ncversion)
            plugins.append(new_term)

        n2.erase_children()
        n2.set_data(
            piw.dictset(piw.dictnull(0), 'agents',
                        piw.makestring(logic.render_termlist(plugins), 0)))
コード例 #6
0
ファイル: domain.py プロジェクト: tylerwood/EigenD
def traits(domain):
    """
    Return traits object for a particular domain has the following attributes:

    data2value(data) -> normal value object, throws ValueError if wrong
    value2data(data) -> data object, throws ValueError if wrong
    canonical()      -> canonical form of domain name
    normalizer()     -> returns fast normalizer d2d functor
    denormalizer()   -> returns fast denormalizer d2d functor
    default()        -> a valid default normal value in the domain
    """
    try:
        term = logic.parse_term(domain)
        klass = __traits.get(term.pred)
        if not klass:
            raise ValueError("bad domain")
        return klass(*term.args)
    except:
        utils.log_exception()
        raise ValueError("bad domain " + domain)
コード例 #7
0
 def upgrade_1_0_4_to_1_0_5(self, tools, address):
     print 'upgrading host', address
     root = tools.get_root(address)
     state = root.get_node(255, 5)
     if state.get_data().is_string():
         mapping = state.get_data().as_string()
         if mapping != '[]':
             term = logic.parse_term(mapping)
             for t in term.args:
                 if "s" == t.pred:
                     decimation = 0
                     notes = True
                     pitchbend = True
                     hiresvel = True
                     pbup = 1.0
                     pbdown = 1.0
                     if t.arity >= 3:
                         decimation = float(t.args[0])
                         notes = bool(t.args[1])
                         pitchbend = bool(t.args[2])
                     if t.arity >= 4:
                         hiresvel = bool(t.args[3])
                     if t.arity >= 6:
                         pbup = float(t.args[4])
                         pbdown = float(t.args[5])
                     root.ensure_node(20, 254).set_data(
                         piw.makefloat_bounded(100, 0, 0, decimation, 0))
                     root.ensure_node(21,
                                      254).set_data(piw.makebool(notes, 0))
                     root.ensure_node(22, 254).set_data(
                         piw.makebool(pitchbend, 0))
                     root.ensure_node(23, 254).set_data(
                         piw.makebool(hiresvel, 0))
                     root.ensure_node(24, 254).set_data(
                         piw.makefloat_bounded(48, 0, 0, pbup, 0))
                     root.ensure_node(25, 254).set_data(
                         piw.makefloat_bounded(48, 0, 0, pbdown, 0))
                     break
コード例 #8
0
ファイル: host_plg.py プロジェクト: jschpmn/EigenD
    def phase2_1_0_1(self,tools,address):
        print 'upgrading plugin host',address
        root = tools.get_root(address)
        freq_input = root.ensure_node(6,2)
        scaler_conn = freq_input.get_master()
        if not scaler_conn: return
        scaler_addr = paths.id2server(scaler_conn[0])
        scaler_root = tools.get_root(scaler_addr)
        if not scaler_root: return
        scaler_type = scaler_root.get_meta_string('plugin')
        if scaler_type != 'scaler': return
        print 'scaler is',scaler_addr
        scaler_pressure_input = scaler_root.get_node(4,2)
        recorder_conn = scaler_pressure_input.get_master()
        if not recorder_conn: return
        recorder_addr = paths.id2server(recorder_conn[0])
        recorder_root = tools.get_root(recorder_addr)
        if not recorder_root: return
        recorder_type = recorder_root.get_meta_string('plugin')
        if recorder_type != 'recorder': return
        print 'recorder is',recorder_addr

        canonical_names = {}
        available_sources = {}
        blocked_sources = []

        available_sources['pressure'] = paths.makeid_list(scaler_addr,1,2)
        available_sources['roll'] = paths.makeid_list(scaler_addr,1,3)
        available_sources['yaw'] = paths.makeid_list(scaler_addr,1,4)

        for (k,v) in available_sources.items():
            canonical_names[v] = k

        for i in range(5,15):
            recorder_input = recorder_root.get_node(1,i)
            if recorder_input:
                input_name = recorder_input.get_name()
                input_conn = recorder_input.get_master()
                output_id = paths.makeid_list(recorder_addr,2,i)
                if not input_conn:
                    blocked_sources.append(output_id)
                    print 'unavailable input',output_id
                    continue
                upstream_addr,upstream_path = paths.breakid_list(input_conn[0])
                upstream_root = tools.get_root(upstream_addr)
                if not upstream_root: continue
                upstream = upstream_root.get_node(*upstream_path)
                if not upstream: continue
                upstream_name = upstream.get_name().split()
                if 'output' in upstream_name: upstream_name.remove('output')
                upstream_name = ' '.join(upstream_name)
                if upstream_name == 'controller': continue
                print 'recorder output',i,'at',output_id,'called',input_name,'connected to',upstream_name
                available_sources[upstream_name] = output_id
                canonical_names[output_id] = upstream_name

        for n,id in available_sources.items():
            print 'source',n,'at',id

        current_parms = {}
        unused_parms = range(1,16)
        existing_names = []

        for k in range(1,16):
            parm_node = root.get_node(4,k)
            parm_name = parm_node.get_name()
            if not parm_node: continue
            parm_conn = parm_node.get_master()
            if not parm_conn: continue
            parm_master = parm_conn[0]

            if parm_master in canonical_names:
                parm_name = canonical_names[parm_master]
            else:
                split_name = parm_name.split()
                kstr = str(k)
                if split_name and split_name[-1]==kstr:
                    parm_name = ' '.join(split_name[:-1])

            if parm_master not in current_parms:
                current_parms[parm_master] = (k,parm_name)
                existing_names.append(parm_name)
                print 'existing source',k,'called',parm_name,'connected to',parm_master
                unused_parms.remove(k)

        for pname,pmaster in available_sources.items():
            if pmaster not in current_parms and pname not in existing_names:
                if unused_parms:
                    k = unused_parms[0]
                    unused_parms = unused_parms[1:]
                    current_parms[pmaster] = (k,pname)
                    print 'adding available source',k,pname,'from',pmaster


        print 'parameter map:'
        for pmaster,(k,pname) in current_parms.items():
            print 'parameter',k,'called',pname,'connected to',pmaster

        for k in range(1,17):
            parm_node = root.ensure_node(4,k)
            parm_node.set_meta('master',piw.data())
            parm_node.set_name('parameter %d' % k)
            
        for pmaster,(k,pname) in current_parms.items():
            if pmaster in blocked_sources:
                continue
            conn = logic.make_term('conn',None,None,pmaster,None)
            conn_txt = logic.render_term(conn)
            parm_node = root.ensure_node(4,k)
            parm_node.set_meta_string('master',conn_txt)
            parm_node.set_name(pname)
            print 'connected',parm_node.id(),'to',conn_txt,'called',pname,'parameter',k

        conn = logic.make_term('conn',None,None,paths.makeid_list(scaler_addr,1,2),None)
        conn_txt = logic.render_term(conn)
        parm_node = root.ensure_node(4,16)
        parm_node.set_meta_string('master',conn_txt)
        parm_node.set_name('key position')

        local_map = {}

        self.check_midi_controller(root,(6,4),7,current_parms,local_map) # volume
        self.check_midi_controller(root,(6,5),1,current_parms,local_map) # modwheel
        self.check_midi_controller(root,(6,6),10,current_parms,local_map) # pan
        self.check_midi_controller(root,(6,7),4,current_parms,local_map) # foot pedal
        self.check_midi_controller(root,(6,8),11,current_parms,local_map) # expression
        self.check_midi_controller(root,(6,9),130,current_parms,local_map) # channel pressure
        self.check_midi_controller(root,(6,10),128,current_parms,local_map) # poly pressure
        self.check_midi_controller(root,(6,11),131,current_parms,local_map) # pitch bend
        self.check_midi_controller(root,(6,12),64,current_parms,local_map) # sustain pedal

        print 'local map',local_map

        map_node = root.ensure_node(255,5)
        map_data = map_node.get_data()
        map_list = []

        if map_data.is_string() and map_data.as_string() and map_data.as_string() != '[]':
            print 'map data',map_data.as_string()
            map_term = logic.parse_term(map_data.as_string())
            map_list = map_term.args

        bits_14 = set([0x07,0x01,0x0a,0x04,0x0b])

        for cc,p in local_map.items():
            ccl = (cc+32) if cc<32 else -1
            res = const.resolution_bits_7 if cc not in bits_14 else const.resolution_bits_14
            map_list=list(map_list)
            map_list.append(logic.make_term('c',p,cc,1.0,0,0,1.0,True,const.scope_pernote,res,ccl))

        map_term = logic.make_term('mapping',*map_list)
        map_node.set_data(piw.makestring(logic.render_term(map_term),0))
コード例 #9
0
    def phase2_1_0_2(self, tools, address):
        print 'upgrading converter', address
        root = tools.get_root(address)
        freq_input = root.ensure_node(2, 2)
        scaler_conn = freq_input.get_master()
        if not scaler_conn: return
        scaler_addr = paths.id2server(scaler_conn[0])
        scaler_root = tools.get_root(scaler_addr)
        if not scaler_root: return
        scaler_type = scaler_root.get_meta_string('plugin')
        if scaler_type != 'scaler': return
        print 'scaler is', scaler_addr
        scaler_pressure_input = scaler_root.get_node(4, 2)
        recorder_conn = scaler_pressure_input.get_master()
        if not recorder_conn: return
        recorder_addr = paths.id2server(recorder_conn[0])
        recorder_root = tools.get_root(recorder_addr)
        if not recorder_root: return
        recorder_type = recorder_root.get_meta_string('plugin')
        if recorder_type != 'recorder': return
        print 'recorder is', recorder_addr

        available_sources = {}
        available_sources['pressure'] = paths.makeid_list(scaler_addr, 1, 2)
        available_sources['roll'] = paths.makeid_list(scaler_addr, 1, 3)
        available_sources['yaw'] = paths.makeid_list(scaler_addr, 1, 4)
        available_sources['key position'] = paths.makeid_list(
            scaler_addr, 1, 2)

        for i in range(5, 15):
            recorder_input = recorder_root.get_node(1, i)
            if recorder_input:
                input_name = recorder_input.get_name()
                input_conn = recorder_input.get_master()
                if not input_conn: continue
                upstream_addr, upstream_path = paths.breakid_list(
                    input_conn[0])
                upstream_root = tools.get_root(upstream_addr)
                if not upstream_root: continue
                upstream = upstream_root.get_node(*upstream_path)
                if not upstream: continue
                upstream_name = upstream.get_name().split()
                if 'output' in upstream_name: upstream_name.remove('output')
                upstream_name = ' '.join(upstream_name)
                if upstream_name == 'controller': continue
                output_id = paths.makeid_list(recorder_addr, 2, i)
                print 'recorder output', i, 'at', output_id, 'called', input_name, 'connected to', upstream_name
                available_sources[upstream_name] = output_id

        for n, id in available_sources.items():
            print 'source', n, 'at', id

        desired_sources = {
            'pressure': 1,
            'roll': 2,
            'yaw': 3,
            'breath': 4,
            'strip position 1': 5,
            'absolute strip 1': 6,
            'strip position 2': 7,
            'absolute strip 2': 8,
            'pedal 1': 9,
            'pedal 2': 10,
            'pedal 3': 11,
            'pedal 4': 12,
            'key position': 16,
        }

        active_sources = {}

        for k in range(1, 17):
            parm_node = root.ensure_node(12, k)
            parm_node.set_meta('master', piw.data())
            parm_node.set_name('parameter %d' % k)

        for k, v in desired_sources.items():
            if k in available_sources:
                conn = logic.make_term('conn', None, None,
                                       available_sources[k], None)
                conn_txt = logic.render_term(conn)
                parm_node = root.ensure_node(12, v)
                parm_node.set_meta_string('master', conn_txt)
                parm_node.set_name(k)
                if v < 16:  # dont map anything to key position
                    active_sources[available_sources[k]] = v
                print 'connected', parm_node.id(), 'to', conn_txt, 'called', k

        print 'checking for midi output', active_sources

        my_controller = None

        all_agents = tools.get_agents()
        for agent in all_agents:
            agent_root = tools.get_root(agent)
            if not agent_root: continue
            agent_type = agent_root.get_meta_string('plugin')
            if agent_type != 'midi_output': continue
            agent_midi_input = agent_root.get_node(2)
            if not agent_midi_input: continue
            agent_conn = [
                paths.id2server(i) for i in agent_midi_input.get_master()
            ]
            print agent, 'is midi output', agent_conn, root.id()
            if root.id() not in agent_conn: continue
            print 'my midi output', agent
            for i in agent_conn:
                controller_root = tools.get_root(i)
                controller_type = controller_root.get_meta_string('plugin')
                if controller_type != 'midi_controller': continue
                my_controller = controller_root
                break
            if my_controller: break

        if not my_controller: return

        cc1 = self.get_midi_cc(my_controller, 1)
        cc2 = self.get_midi_cc(my_controller, 2)
        cc3 = self.get_midi_cc(my_controller, 3)
        cc4 = self.get_midi_cc(my_controller, 4)

        print 'midi controller', my_controller.id(), cc1, cc2, cc3, cc4

        global_map = {}

        self.check_midi_controller(my_controller, (2, 1), 7, active_sources,
                                   global_map)  # volume
        self.check_midi_controller(my_controller, (2, 2), 1, active_sources,
                                   global_map)  # modwheel
        self.check_midi_controller(my_controller, (2, 3), 10, active_sources,
                                   global_map)  # pan
        self.check_midi_controller(my_controller, (2, 4), 4, active_sources,
                                   global_map)  # foot pedal
        self.check_midi_controller(my_controller, (2, 5), 11, active_sources,
                                   global_map)  # EXPRESSION
        self.check_midi_controller(my_controller, (2, 6), 130, active_sources,
                                   global_map)  # channel pressure
        self.check_midi_controller(my_controller, (2, 7), 131, active_sources,
                                   global_map)  # pitch bend
        self.check_midi_controller(my_controller, (2, 8), 64, active_sources,
                                   global_map)  # sustain pedal
        self.check_midi_controller(my_controller, (2, 9), cc1, active_sources,
                                   global_map)
        self.check_midi_controller(my_controller, (2, 10), cc2, active_sources,
                                   global_map)
        self.check_midi_controller(my_controller, (2, 11), cc3, active_sources,
                                   global_map)
        self.check_midi_controller(my_controller, (2, 12), cc4, active_sources,
                                   global_map)

        local_map = {}

        self.check_midi_controller(root, (2, 4), 7, active_sources,
                                   local_map)  # volume
        self.check_midi_controller(root, (2, 5), 1, active_sources,
                                   local_map)  # modwheel
        self.check_midi_controller(root, (2, 6), 10, active_sources,
                                   local_map)  # pan
        self.check_midi_controller(root, (2, 7), 4, active_sources,
                                   local_map)  # foot pedal
        self.check_midi_controller(root, (2, 8), 11, active_sources,
                                   local_map)  # expression
        self.check_midi_controller(root, (2, 9), 130, active_sources,
                                   local_map)  # channel pressure
        self.check_midi_controller(root, (2, 10), 128, active_sources,
                                   local_map)  # poly pressure
        self.check_midi_controller(root, (2, 11), 131, active_sources,
                                   local_map)  # pitch bend
        self.check_midi_controller(root, (2, 12), 64, active_sources,
                                   local_map)  # sustain pedal

        print 'per key mappings', local_map
        print 'global mappings', global_map

        map_node = root.ensure_node(255, 1)
        map_data = map_node.get_data()
        map_list = []

        if map_data.is_string() and map_data.as_string(
        ) and map_data.as_string() != '[]':
            print 'map data', map_data.as_string()
            map_term = logic.parse_term(map_data.as_string())
            map_list = map_term.args

        bits_14 = set([0x07, 0x01, 0x0a, 0x04, 0x0b])

        for cc, p in local_map.items():
            ccl = (cc + 32) if cc < 32 else -1
            res = const.resolution_bits_7 if cc not in bits_14 else const.resolution_bits_14
            map_list = list(map_list)
            map_list.append(
                logic.make_term('c', p, cc, 1.0, 0, 0, 1.0, True,
                                const.scope_pernote, ccl, ccl))

        for cc, p in global_map.items():
            ccl = (cc + 32) if cc < 32 else -1
            res = const.resolution_bits_7 if cc not in bits_14 else const.resolution_bits_14
            map_list.append(
                logic.make_term('c', p, cc, 1.0, 0, 0, 1.0, True,
                                const.scope_global, ccl, ccl))

        map_term = logic.make_term('mapping', *map_list)
        map_node.set_data(piw.makestring(logic.render_term(map_term), 0))