示例#1
0
def __getfullname(snap, cache, address):
    (id, path) = paths.breakid_list(address)

    if id in cache:
        return paths.makeid_list(cache[id], *path)

    agent = snap.get_agent_address(0, id, False)
    if not agent.isvalid():
        agent = snap.get_agent_address(1, id, False)
        if not agent.isvalid():
            cache[id] = id
            return paths.makeid_list(id, *path)

    root = agent.get_root()
    sig = root.get_data().as_string().split(':')
    parent_name = None

    if guid.isguid(address) and len(sig) > 3:
        parent = __findroot(snap, guid.split(address)[0])
        parent_name = __getfullname(snap, cache, parent)

    node = Node(root, id, ())
    name = node.getname()

    if parent_name:
        name = parent_name + ' ' + name

    cache[id] = name
    return paths.makeid_list(name, *path)
示例#2
0
 def upgrade_2_0_to_3_0(self, tools, address):
     root = tools.root(address)
     root.get_node(2).erase()
     root.ensure_node(1, 1, 255, 7).set_data(piw.makelong(1, 0))
     tools.substitute_connection(paths.makeid_list(address, 2),
                                 paths.makeid_list(address, 2, 1))
     return True
示例#3
0
    def upgrade_2_0_to_3_0(self, tools, address):
        root = tools.root(address)
        root.get_node(1).erase()
        tools.substitute_connection(paths.makeid_list(address, 1),
                                    paths.makeid_list(address, 1, 1))

        old_2 = root.get_node(2)
        root.get_node(2).erase()
        root.ensure_node(2, 1).copy(old_2)
        root.ensure_node(2, 1).rename(names='audio input')
        root.ensure_node(2, 1, 255, 7).set_data(piw.makelong(1, 0))
        return True
示例#4
0
def __getname(snap, cache, address):
    (id, path) = paths.breakid_list(address)

    if id in cache:
        return paths.makeid_list(cache[id], *path)

    agent = snap.get_agent_address(0, id, False)
    if not agent.isvalid():
        agent = snap.get_agent_address(1, id, False)
        if not agent.isvalid():
            cache[id] = id
            return paths.makeid_list(id, *path)

    root = agent.get_root()
    node = Node(root, id, ())
    name = node.getname()

    cache[id] = name
    return paths.makeid_list(name, *path)
示例#5
0
    def move_connections(self,old_id,new_id):
        connections = self.get_connections()

        old_server,old_path = paths.breakid_list(old_id)
        old_path = tuple(old_path)
        old_path_len = len(old_path)
        old_connections = connections.get(old_server,{})
        new_server,new_path = paths.breakid_list(new_id)
        new_path = tuple(new_path)

        for src_path,tgt_id_set in old_connections.items():
            if src_path[:old_path_len] == old_path:
                old_src_id = paths.makeid_list(old_server,*src_path)
                new_src_id = paths.makeid_list(new_server,*(new_path+src_path[old_path_len:]))
                for tgt_id in tgt_id_set:
                    tgt_server,tgt_path = paths.breakid_list(tgt_id)
                    tgt_node = self.get_root(tgt_server).get_node(*tgt_path)
                    if tgt_node:
                        tgt_node.move_connection(old_src_id,new_src_id)
示例#6
0
 def id(self):
     return paths.makeid_list(self.server, *self.path)
示例#7
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))