Exemplo n.º 1
0
def lines_to_network(lines):
    network=Network()
    for l in lines:
        parts=l.split()
        node=None
        print parts
        if len(parts)>=4:
            print "h"
            typename=parts[1]
            if typename.startswith("EQ1940SingleS"):
                print "g"
                # biquad filter
                node=BiQuad()
                node.name=typename
            elif typename.startswith("EQ1940Single"):
                node=BiQuad()
                node.name=typename
            elif typename.startswith("ICSigma100Out"):
                node=Output()
                node.name=typename
            elif typename.startswith("ICSigma100In"):
                # split input into separate input nodes
                inputs=parts[2:]
                i=0
                while len(inputs)>=2:
                    inp=Input()
                    inp.name=typename+"_"+str(i)
                    network.add_node(inp)
        if node is not None:
            network.add_node(node)
        return network
Exemplo n.º 2
0
def lines_to_network(lines):
    network = Network()
    for l in lines:
        parts = l.split()
        node = None
        print parts
        if len(parts) >= 4:
            print "h"
            typename = parts[1]
            if typename.startswith("EQ1940SingleS"):
                print "g"
                # biquad filter
                node = BiQuad()
                node.name = typename
            elif typename.startswith("EQ1940Single"):
                node = BiQuad()
                node.name = typename
            elif typename.startswith("ICSigma100Out"):
                node = Output()
                node.name = typename
            elif typename.startswith("ICSigma100In"):
                # split input into separate input nodes
                inputs = parts[2:]
                i = 0
                while len(inputs) >= 2:
                    inp = Input()
                    inp.name = typename + "_" + str(i)
                    network.add_node(inp)
        if node is not None:
            network.add_node(node)
        return network
Exemplo n.º 3
0
def network_from_minidom(networknode):
    if networknode.tagName != "network":
        raise Exception("Cannot create network from node {}".format(
            networknode.tagName))

    # get sample rate
    sr = float(networknode.getAttributeNode('samplerate').value)

    network = Network()
    network.samplerate = sr

    # create nodes
    for filterNode in networknode.childNodes:
        f = filter_from_node(filterNode, sr)
        if f != None:
            network.add_node(f)

    # create connections
    # objects have been created with an additional attribute "imported_inputnames" that will be used now
    for f in network.get_nodes():
        try:
            inputnames = f.imported_inputnames
        except AttributeError:
            continue

        if len(inputnames) == 1:
            inputobject = network.get_node_by_name(inputnames[0])
            if inputobject is not None:
                f.set_input(inputobject)
            else:
                raise Exception("Cannot connect {} with {}".format(
                    f.name, inputnames[0]))

        else:
            for i in inputnames:
                inputobject = network.get_node_by_name(i)
                if inputobject is not None:
                    f.add_input(inputobject)
                else:
                    raise Exception("Cannot connect {} with {}".format(
                        f.name, inputnames[0]))

    return network
Exemplo n.º 4
0
def network_from_minidom(networknode):
    if networknode.tagName != "network":
        raise Exception("Cannot create network from node {}".format(networknode.tagName))
    
    # get sample rate
    sr=float(networknode.getAttributeNode('samplerate').value)
    
    network=Network()
    network.samplerate=sr
    
    # create nodes
    for filterNode in networknode.childNodes:
        f = filter_from_node(filterNode,sr)
        if f != None:
            network.add_node(f)
            
    # create connections
    # objects have been created with an additional attribute "imported_inputnames" that will be used now
    for f in network.get_nodes():
        try:
            inputnames=f.imported_inputnames
        except AttributeError:
            continue
        
        if len(inputnames)==1:
            inputobject=network.get_node_by_name(inputnames[0])
            if inputobject is not None:
                f.set_input(inputobject)
            else:
                raise Exception("Cannot connect {} with {}".format(f.name,inputnames[0]))
            
        else:
            for i in inputnames:
                inputobject=network.get_node_by_name(i)
                if inputobject is not None:
                    f.add_input(inputobject)
                else:
                    raise Exception("Cannot connect {} with {}".format(f.name,inputnames[0]))
    
    return network