示例#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
示例#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
示例#3
0
def filter_from_node(xmlnode, samplerate):
    # ignore text nodes
    if xmlnode.nodeType != minidom.Node.ELEMENT_NODE:
        return None
    filtertype=xmlnode.tagName
    filterelement=None
    
    if filtertype=="input":
        filterelement=Input()
    elif filtertype=="biquad":
        filterelement=BiQuad()
    elif filtertype=="output":
        filterelement=Output()
    elif filtertype=="mixer":
        filterelement=Mixer()
    elif filtertype=="volume":
        filterelement=Volume()
    else:
        raise Exception("Unknown filter type "+filtertype)
        
    # set name, every node MUST have a name
    nameAttr=xmlnode.getAttributeNode('name')
    if nameAttr is None:
        raise Exception("Filter with type {} doesn't not have a name".format(filtertype))
    else:
        filterelement.name=nameAttr.nodeValue
        
    filterelement.set_samplerate(samplerate)
        
    # set other attributes
    for aName, aValue in xmlnode.attributes.items():
        # frequency
        if aName=="f" or aName=="frequency":
            filterelement.set_frequency(float(aValue))
        elif aName=="q":
            filterelement.set_q(float(aValue))
        elif aName=="type":
            filterelement.set_type(aValue)
        elif aName=="dbgain":
            gains = [float(x) for x in aValue.split(",")]
            if (len(gains)==1):
                filterelement.set_dbgain(gains[0])
            else:
                filterelement.set_dbgains(gains)
        elif aName=="firstorder":
            if (aValue.lower() in ["yes","true","1"]):
                filterelement.set_first_order(True)
        elif aName=="input":
            for inp in aValue.split(","):
                # store the input names in a separate array to connect them later
                try:
                    filterelement.imported_inputnames.append(inp)
                except AttributeError:
                    filterelement.imported_inputnames=[inp] 
            
    # we need to calculate the coefficients for biquads
    if isinstance(filterelement, BiQuad):
        filterelement.recalc_coefficients()
            
    
    return filterelement;
示例#4
0
def filter_from_node(xmlnode, samplerate):
    # ignore text nodes
    if xmlnode.nodeType != minidom.Node.ELEMENT_NODE:
        return None
    filtertype = xmlnode.tagName
    filterelement = None

    if filtertype == "input":
        filterelement = Input()
    elif filtertype == "biquad":
        filterelement = BiQuad()
    elif filtertype == "output":
        filterelement = Output()
    elif filtertype == "mixer":
        filterelement = Mixer()
    elif filtertype == "volume":
        filterelement = Volume()
    else:
        raise Exception("Unknown filter type " + filtertype)

    # set name, every node MUST have a name
    nameAttr = xmlnode.getAttributeNode('name')
    if nameAttr is None:
        raise Exception(
            "Filter with type {} doesn't not have a name".format(filtertype))
    else:
        filterelement.name = nameAttr.nodeValue

    filterelement.set_samplerate(samplerate)

    # set other attributes
    for aName, aValue in xmlnode.attributes.items():
        # frequency
        if aName == "f" or aName == "frequency":
            filterelement.set_frequency(float(aValue))
        elif aName == "q":
            filterelement.set_q(float(aValue))
        elif aName == "type":
            filterelement.set_type(aValue)
        elif aName == "dbgain":
            gains = [float(x) for x in aValue.split(",")]
            if (len(gains) == 1):
                filterelement.set_dbgain(gains[0])
            else:
                filterelement.set_dbgains(gains)
        elif aName == "firstorder":
            if (aValue.lower() in ["yes", "true", "1"]):
                filterelement.set_first_order(True)
        elif aName == "input":
            for inp in aValue.split(","):
                # store the input names in a separate array to connect them later
                try:
                    filterelement.imported_inputnames.append(inp)
                except AttributeError:
                    filterelement.imported_inputnames = [inp]

    # we need to calculate the coefficients for biquads
    if isinstance(filterelement, BiQuad):
        filterelement.recalc_coefficients()

    return filterelement