def __init__( self ): # Set up the UI super( LoudnessGui, self ).__init__( None ) self.audioRunning = False self.setGeometry( 0, 0, 800, 600 ) self.layout = QtGui.QGridLayout( self ) self.startButton = QtGui.QPushButton( "Start Audio" ) # , self.centralWidget ) #self.startButton.setMinimumSize( 200, 60 ) self.stopButton = QtGui.QPushButton( "Stop Audio" ) # , self.centralWidget ) #self.stopButton.setMinimumSize( 200, 60 ) self.layout.addWidget( self.startButton, 0, 0 ) # , QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter ) self.layout.addWidget( self.stopButton, 0, 1 ) # , QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter ) self.loudnessLabel = QtGui.QLabel( '--- dB' ) # , self.centralWidget ) #self.loudnessLabel.setMinimumSize( 200, 60 ) self.layout.addWidget( self.loudnessLabel, 0, 2 ) # , QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter ) self.startButton.clicked.connect( self.startAudio ) self.stopButton.clicked.connect( self.stopAudio ) self.plotWidget = pg.PlotWidget() self.plotWidget.setRange( xRange = (0,numPlotPoints-1), yRange = (-130.0,6.0)) self.layout.addWidget( self.plotWidget, 1, 0, 1, 4 ) self.loudnessPlot = pg.PlotCurveItem() self.plotWidget.addItem( self.loudnessPlot ) self.loudnessHist = -120.0 * np.ones( numPlotPoints, dtype=np.float32 ) self.loudnessPlot.setData( self.loudnessHist ) # %% Setup the DSP part self.context = visr.SignalFlowContext( period = blockSize, samplingFrequency = samplingFrequency ) self.meter = LoudnessMeter( self.context, 'meter', None, numChannels, measurePeriod = 0.4, audioOut = True ) audioOptions = ai.AudioInterface.Configuration( numChannels, numChannels, samplingFrequency, blockSize ) self.audioInterface = ai.AudioInterfaceFactory.create( audioInterfaceName, audioOptions, audioBackendOptions ) self.flow = rrl.AudioSignalFlow( self.meter ) self.loudnessPort = self.flow.parameterSendPort( 'loudnessOut' ) self.readTimer = QtCore.QTimer( self ) self.readTimer.timeout.connect( self.getMeterValues ) self.readTimer.setSingleShot( False ) self.readTimer.setInterval( 100 ) # ms
if not os.path.exists(sofaDir): os.makedirs(sofaDir) urlretrieve('http://sofacoustics.org/data/database/thk/HRIR_L2354.sofa', sofaFile) # If the ITDs are to be applied separately, we create a version of the SOFA file # that conains the delays separately in the Data.Delay dataset. # Note: This mechanism fails if the original SOFA file already cantains the delay data # (it would be discarded). if useDynamicITD: sofaFileTD = os.path.splitext(sofaFile)[0] + '_modelled_onsets.sofa' if not os.path.exists(sofaFileTD): sofaExtractDelay(sofaFile, sofaFileTD) sofaFile = sofaFileTD context = visr.SignalFlowContext(period=blockSize, samplingFrequency=fs) renderer = DynamicHrirRenderer( context, "DynamicHrirRenderer", None, numberOfObjects=numBinauralObjects, sofaFile=sofaFile, headTracking=useTracking, dynamicITD=useDynamicITD, dynamicILD=useDynamicILD, hrirInterpolation=useHRIRinterpolation, filterCrossfading=useCrossfading, interpolatingConvolver=useInterpolatingConvolver) result, messages = rrl.checkConnectionIntegrity(renderer)
# -*- coding: utf-8 -*- """ Created on Sat Feb 24 07:25:02 2018 @author: andi """ import visr import rcl import numpy as np ctxt = visr.SignalFlowContext( 64, 48000 ) numInputs = 3 numOutputs = 7 gains = np.array( np.random.rand( numOutputs, numInputs ), dtype=np.float32 ) mtx = rcl.GainMatrix( ctxt, "Matrix", None, numberOfInputs=numInputs, numberOfOutputs=numOutputs, interpolationSteps=0, initialGains=gains ) dv = rcl.DelayVector( ctxt, "DL", None, numberOfChannels=2, maxDelay=1.0, initialDelay = [0.0, 0.1], initialGain=[1.0,0.5]) iDelay = np.asarray([0.0, 0.1], dtype=np.float64) iGain=np.asarray([1.0,0.5]) dv = rcl.DelayVector( ctxt, "DL", None, numberOfChannels=2, maxDelay=1.0, initialDelay = iDelay, initialGain=iGain )
z = r * np.sin(el) return x, y, z hfLfPanning = False blockSize = 128 samplingFrequency = 48000 azGrid = np.arange(-45, 45, 1) * np.pi / 180.0 gridSize = len(azGrid) numSamples = 1024 numObjectChannels = 1 ctxt = visr.SignalFlowContext(blockSize, samplingFrequency) # lc = panning.LoudspeakerArray( '/home/andi/dev/visr/config/isvr/audiolab_39speakers_1subwoofer.xml' ) # lc = panning.LoudspeakerArray( '/home/andi/dev/visr/config/generic/bs2051-9+10+3_linear.xml' ) # lc = panning.LoudspeakerArray( 'c:/local/visr/config/isvr/audiolab_39speakers_1subwoofer.xml' ) # 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,
from realtime_multi_renderer_trajectory import RealTimeMultiRendererTrajectory import visr #import panning import rrl import audiointerfaces as ai import os.path import sys import time import numpy as np fs = 48000 blockSize = 1024 context = visr.SignalFlowContext(blockSize, fs) # configBasePath = '/usr/share/visr/config/' configBasePath = '/home/andi/dev/visr/config/' renderConfigNames = [ 'bbc-listening-room-full.xml', 'bs2051-0+2+0.xml', 'bs2051-0+5+0.xml', 'bs2051-2+5+0.xml', 'bs2051-4+5+0.xml', 'bs2051-4+9+0.xml', 'bs2051-9+10+3.xml' ] numberOfOutputs = 34 # Maximum channel number # Create filtes with full paths configPaths = [ os.path.join(configBasePath, 'bbc', cfg) for cfg in renderConfigNames
Example script to run a realtime VBAP renderer from Python. """ import visr import panning import rrl import audiointerfaces as ai from vbap_renderer import RealtimeVbapRenderer bs = 512 # Define the period / buffer size fs = 48000 # Define the sampling rate in Hz # Define a SignalFlowContext object that is used to pass the sampling frequency # and period parameter to a component's constructor. context = visr.SignalFlowContext(bs, fs) # Define a loudspeaker configuration file incl. VBAP triangulation # Stereo runs on most (including internal) soundcards. configFile = '../data/stereo.xml' # Multichannel Loudspeaker configurations as defined by ITU-R BS.2051. # Note that the speaker channels are consectutive, i.e., they differ from # the ITU standard as they omit the channels for the subwoofers (channel 4 and 10 # for 9+10+3) # Note: The sudio interface used must support the number of output channels. #configFile = '../data/bs2051-0+5+0.xml' #configFile = '../data/bs2051-4+5+0.xml' #configFile = '../data/bs2051-9+10+3.xml' # Number of objects rendered.
from vbap_l2_renderer import VbapL2Renderer from vbap_renderer import VbapRenderer from helper.baseTrigFunctions import sph2cart bs = 128 samplingFrequency = 48000 numBlocks = 128 numObjects = 1 signalLength = bs * numBlocks t = 1.0 / samplingFrequency * np.arange(0, signalLength) ctxt = visr.SignalFlowContext(bs, samplingFrequency) lc = panning.LoudspeakerArray('../data/bs2051-4+5+0.xml') numOutputChannels = lc.numberOfRegularLoudspeakers rendererVbap = VbapRenderer(ctxt, 'renderer', None, numObjects, lspConfig=lc) rendererL2 = VbapL2Renderer(ctxt, 'renderer', None, numObjects, lspArray=lc) flowVbap = rrl.AudioSignalFlow(rendererVbap) flow = rrl.AudioSignalFlow(rendererL2) paramInput = flow.parameterReceivePort('objects') paramInputVbap = flowVbap.parameterReceivePort('objects')