Example #1
0
    def __init__(self, context, name, parent, numberOfObjects, lspConfig):
        """
        Constructor, instantiates the component, all contained sub-components,
        and their connections.

        Parameters
        ----------

        self: VbapRenderer
            self argument, mandatory for Python methods.
        context: visr.SignalFlowContext
            A context object containing the sampling frequency and the block size.
            That is a mandatory parameter for VISR components.
        name: string
            Name of the component to be identified within a containing component.
        parent: visr.Compositcomponent
            A containing component, or None if this is the top-level component.
        numberOfObjects: int
            The maximum number of objects to be rendered.
        lspConfig: panning.LoudspeakerArray
            Object containing the loudspeaker positions.
        """
        numLsp = lspConfig.numberOfRegularLoudspeakers
        super().__init__(context, name, parent)
        self.audioIn = visr.AudioInputFloat("in", self, numberOfObjects)
        self.audioOut = visr.AudioOutputFloat("out", self, numLsp)
        self.objectIn = visr.ParameterInput(
            "objects", self, pml.ObjectVector.staticType,
            pml.DoubleBufferingProtocol.staticType, pml.EmptyParameterConfig())
        self.calculator = rcl.PanningCalculator(context, "VbapGainCalculator",
                                                self, numberOfObjects,
                                                lspConfig)
        self.matrix = rcl.GainMatrix(context,
                                     "GainMatrix",
                                     self,
                                     numberOfObjects,
                                     numLsp,
                                     interpolationSteps=context.period,
                                     initialGains=0.0)
        # Uncomment this and comment the lines above to use the simple, Python-based
        # GainMatrix class instead.
        #        self.matrix = GainMatrix( context, "GainMatrix", self, numberOfObjects,
        #                                  numLsp )
        self.audioConnection(self.audioIn, self.matrix.audioPort("in"))
        self.audioConnection(self.matrix.audioPort("out"), self.audioOut)
        self.parameterConnection(
            self.objectIn, self.calculator.parameterPort("objectVectorInput"))
        self.parameterConnection(self.calculator.parameterPort("vbapGains"),
                                 self.matrix.parameterPort("gainInput"))
    def __init__(self, context, name, parent, numberOfInputs, numberOfOutputs,
                 arrayConfig, interpolationSteps):
        super(StandardVbap, self).__init__(context, name, parent)
        self.input = visr.AudioInputFloat("in", self, numberOfInputs)
        self.output = visr.AudioOutputFloat("out", self, numberOfOutputs)

        self.objectInput = visr.ParameterInput(
            "objectVectorInput",
            self,
            parameterType=pml.ObjectVector.staticType,
            protocolType=pml.DoubleBufferingProtocol.staticType,
            parameterConfig=pml.EmptyParameterConfig())
        self.panningCalculator = rcl.PanningCalculator(
            context,
            "GainCalculator",
            self,
            arrayConfig=arrayConfig,
            numberOfObjects=numberOfInputs,
            separateLowpassPanning=False)

        self.panningMatrix = rcl.GainMatrix(
            context,
            "PanningMatrix",
            self,
            numberOfInputs=numberOfInputs,
            numberOfOutputs=numberOfOutputs,
            interpolationSteps=interpolationSteps,
            initialGains=0.0,
            controlInput=True)

        self.audioConnection(self.input, self.panningMatrix.audioPort("in"))
        self.audioConnection(self.panningMatrix.audioPort("out"), self.output)

        self.parameterConnection(
            self.objectInput,
            self.panningCalculator.parameterPort("objectVectorInput"))
        self.parameterConnection(
            self.panningCalculator.parameterPort("gainOutput"),
            self.panningMatrix.parameterPort("gainInput"))
# lc = panning.LoudspeakerArray( 'c:/local/visr/config/generic/bs2051-9+10+3.xml' )
lc = panning.LoudspeakerArray(
    'c:/local/s3a_git/aes2018_dualband_panning/code/data/bs2051-4+5+0.xml')

numSpeakers = lc.numberOfRegularLoudspeakers

if False:
    calc = PythonPanner(ctxt,
                        'calc',
                        None,
                        numberOfObjects=numObjectChannels,
                        arrayConfig=lc)
else:
    calc = rcl.PanningCalculator(ctxt,
                                 'calc',
                                 None,
                                 numberOfObjects=numObjectChannels,
                                 arrayConfig=lc,
                                 separateLowpassPanning=True)

flow = rrl.AudioSignalFlow(calc)

paramInput = flow.parameterReceivePort('objectVectorInput')

# Dummy input required for the process() function
inputBlock = np.zeros((0, blockSize), dtype=np.float32)

lfGainOutput = flow.parameterSendPort("vbapGains")
hfGainOutput = flow.parameterSendPort("vbipGains")

hfGains = np.zeros((gridSize, numSpeakers))
lfGains = np.zeros((gridSize, numSpeakers))
    def __init__(self,
                 context,
                 name,
                 parent,
                 numberOfInputs,
                 numberOfOutputs,
                 arrayConfig,
                 interpolationSteps,
                 lfFilter=rbbl.BiquadCoefficientFloat(0.001921697757295,
                                                      0.003843395514590,
                                                      0.001921697757295,
                                                      -1.824651307057289,
                                                      0.832338098086468),
                 hfFilter=rbbl.BiquadCoefficientFloat(0.914247351285939,
                                                      1.828494702571878,
                                                      -0.914247351285939,
                                                      -1.824651307057289,
                                                      0.832338098086468)):
        super(LfHfVbap, self).__init__(context, name, parent)
        self.input = visr.AudioInputFloat("in", self, numberOfInputs)
        self.output = visr.AudioOutputFloat("out", self, numberOfOutputs)

        self.objectInput = visr.ParameterInput(
            "objectVectorInput",
            self,
            parameterType=pml.ObjectVector.staticType,
            protocolType=pml.DoubleBufferingProtocol.staticType,
            parameterConfig=pml.EmptyParameterConfig())

        self.panningCalculator = rcl.PanningCalculator(
            context,
            "GainCalculator",
            self,
            arrayConfig=arrayConfig,
            numberOfObjects=numberOfInputs,
            separateLowpassPanning=True)

        filterMtx = rbbl.BiquadCoefficientMatrixFloat(2 * numberOfInputs, 1)
        for idx in range(0, numberOfInputs):
            filterMtx[idx, 0] = lfFilter
            filterMtx[idx + numberOfInputs, 0] = hfFilter

        self.filterBank = rcl.BiquadIirFilter(
            context,
            "filterBank",
            self,
            numberOfChannels=2 * numberOfInputs,
            numberOfBiquads=1,  # TODO: allow variable number of sections.
            initialBiquads=filterMtx,
            controlInput=False)
        self.audioConnection(
            self.input,
            [i % numberOfInputs for i in range(0, 2 * numberOfInputs)],
            self.filterBank.audioPort("in"), range(0, 2 * numberOfInputs))

        self.lfMatrix = rcl.GainMatrix(context,
                                       "LfPanningMatrix",
                                       self,
                                       numberOfInputs=numberOfInputs,
                                       numberOfOutputs=numberOfOutputs,
                                       interpolationSteps=interpolationSteps,
                                       initialGains=0.0,
                                       controlInput=True)
        self.audioConnection(self.filterBank.audioPort("out"),
                             range(0, numberOfInputs),
                             self.lfMatrix.audioPort("in"),
                             range(0, numberOfInputs))

        self.hfMatrix = rcl.GainMatrix(context,
                                       "HfPanningMatrix",
                                       self,
                                       numberOfInputs=numberOfInputs,
                                       numberOfOutputs=numberOfOutputs,
                                       interpolationSteps=interpolationSteps,
                                       initialGains=0.0,
                                       controlInput=True)
        self.audioConnection(self.filterBank.audioPort("out"),
                             range(numberOfInputs, 2 * numberOfInputs),
                             self.hfMatrix.audioPort("in"),
                             range(0, numberOfInputs))

        self.signalMix = rcl.Add(context,
                                 "SignalMix",
                                 self,
                                 numInputs=2,
                                 width=numberOfOutputs)
        self.audioConnection(self.signalMix.audioPort("out"), self.output)

        self.audioConnection(self.lfMatrix.audioPort("out"),
                             self.signalMix.audioPort("in0"))
        self.audioConnection(self.hfMatrix.audioPort("out"),
                             self.signalMix.audioPort("in1"))

        self.parameterConnection(
            self.objectInput,
            self.panningCalculator.parameterPort("objectVectorInput"))
        self.parameterConnection(
            self.panningCalculator.parameterPort("lowFrequencyGainOutput"),
            self.lfMatrix.parameterPort("gainInput"))
        self.parameterConnection(
            self.panningCalculator.parameterPort("gainOutput"),
            self.hfMatrix.parameterPort("gainInput"))
Example #5
0
samplingFrequency = 48000
ctxt = visr.SignalFlowContext(bs, samplingFrequency)

numBlocks = 360

numObjects = 1

# Load the loudspeaker configuation
lc = panning.LoudspeakerArray('../data/bs2051-4+5+0.xml')

numLsp = lc.numberOfRegularLoudspeakers

# Create components for the two apnning algorithms
pannerVbap = rcl.PanningCalculator(ctxt,
                                   'vbapbCalc',
                                   None,
                                   numObjects,
                                   arrayConfig=lc)
pannerL2 = VbapL2Panner(ctxt, 'constSpread', None, numObjects, lspArray=lc)

# %% Create signal flow objects for the two algorithms
flowVbap = rrl.AudioSignalFlow(pannerVbap)
flowL2 = rrl.AudioSignalFlow(pannerL2)

# %% Retrieve parameter inputs and outputs for the two audio objects.
paramInputVbap = flowVbap.parameterReceivePort('objectVectorInput')
paramOutputVbap = flowVbap.parameterSendPort('vbapGains')

paramInputL2 = flowL2.parameterReceivePort('objects')
paramOutputL2 = flowL2.parameterSendPort('gains')