def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # Set defaults # If processor is on if 'on' in arguments.attrib: self.on = bool(int(arguments.attrib['on'])) else: self.on = True # Default is on # Verbose print out mode if "verbose" in arguments.attrib: self.verbose = bool(int(arguments.attrib["verbose"])) else: self.verbose = False # Update mode (overwrite or anything else) if "updateMode" in arguments.attrib: self.updateMode = arguments.attrib["updateMode"] else: self.updateMode = 'overwrite' # Filename (and path) to write to file with if "writeToFile" in arguments.attrib: self.writeToFile = arguments.attrib["writeToFile"] else: self.writeToFile = 'TempObjVector'
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # Processor properties # Get arguments: if 'on' in arguments.attrib: self.on = int(arguments.attrib['on']) else: self.on = 1 # Default is on if 'verbose' in arguments.attrib: self.verbose = int(arguments.attrib['verbose']) else: self.verbose = 0 # Default is not verbose # EQ properties self.lowgain = 0 self.highgain = 0 if 'lowfreq' in arguments.attrib: self.lowfreq = float(arguments.attrib['lowfreq']) else: self.lowfreq = 200.0 # Default is 200 Hz if 'highfreq' in arguments.attrib: self.highfreq = float(arguments.attrib['highfreq']) else: self.highfreq = 2000.0 # Default is 2000 Hz
def __init__(self, arguments): #MetadataProcessorInterface.__init__(self, arguments) SequenceProcessorInterface.__init__(self, arguments) # Get arguments: if 'on' in arguments.attrib: self.on = int(arguments.attrib['on']) else: self.on = 1 # DEFAULT FOR NOW IS ON if 'narrativeimportance' in arguments.attrib: self.ni = float(arguments.attrib['narrativeimportance']) else: self.ni = 1.0 if 'verbose' in arguments.attrib: self.verbose = int(arguments.attrib['verbose']) else: self.verbose = 1 # DEFAULT FOR NOW IS VERBOSE if 'lock' in arguments.attrib: self.dolock = int(arguments.attrib['lock']) else: self.dolock = 0 # Default has the position lock off SendValuesToMax(self) self.sendstrings = 0 self.sendlock = 2
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) if 'filename' in arguments.attrib: self.filename = str(arguments.attrib['filename']) else: self.filename = 'None' if 'verbose' in arguments.attrib: self.verbose = int(arguments.attrib['verbose']) else: self.verbose = 1 # Default is verbose if 'on' in arguments.attrib: self.on = int(arguments.attrib['on']) else: self.on = 1 # Default is on # Read the specified ADM file self.advanced_metadata = read_adm_file(self.filename, self.verbose) # Preallocate empty list of metadata to add self.metadata_to_add = [] # Create reset flag self.resetflag = 0
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # Set defaults self.source2az = 0 # degrees self.source2level = 0 # dB self.noiseon = 0 # flag
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) objStr = arguments.attrib['objectID'] self.objectId = [int(s) for s in objStr.split() if s.isdigit()] #print self.objectId self.active = strtobool(arguments.attrib['active']) self.maxAz = float(arguments.attrib['maxAz'])
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # Set defaults self.pianolevel = 0 # dB self.pianoazimuth = 0 # deg self.overall_level = 0 # dB
def __init__(self, arguments ): SequenceProcessorInterface.__init__(self, arguments) self.objectId = int( arguments.attrib['objectID'] ) self.active = strtobool( arguments.attrib['active'] ) self.x = float( arguments.attrib['x'] ) self.y = float( arguments.attrib['y'] ) self.z = float( arguments.attrib['height'] )
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) objs = [] for objNode in arguments.iter('object'): data = objNode.attrib['data'].replace('\'', '\"') obj = loads(data) objs.append(obj) sortedObjs = sorted(objs, key=lambda k: int(k['id'])) self.additionalObjects = sortedObjs
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) if 'on' in arguments.attrib: self.on = int(arguments.attrib['on']) else: self.on = 1 # Default is on # Set up a list of which MDO speakers are available (hard coded 100 max) self.idlist = [0] * 100
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # Get filename to load filename = arguments.attrib['filename'] # Get active flag (not actually used here) self.active = strtobool(arguments.attrib['active']) # Read advanced metadata chunk from file target_chunk = "bxml" (wav_string, fmt) = parse_WAV_chunk(filename, target_chunk) # Settings for advanced scene metadata to find self.scene = [] # Create empty list for results tag_target = 'scene' # Target tag attr = ['scene_attr_1', 'scene_attr_2'] # Attributes to try and find within tag attr_defaults = [0, 'option0' ] # Defaults for attributes for when not found # Parse wav_string assuming scene data in xml target tag self.scene = parse_xml_scene(self.scene, tag_target, wav_string, attr, attr_defaults) # Print to screen print() print() print("XML parse attributes for tag = '{}':\n".format(tag_target)) for x in self.scene: print("{:-12s}\t: {}".format(x, str(self.scene[x]))) print() # Settings for advanced object metadata to find self.objects = [] # Create empty list for results tag_target = 'object' # Target tag Nobj = fmt[ 'Nchan'] # Number of objects (assumed same as number of channels in file) attr = ['object_attr_1', 'object_attr_2'] # Attributes to try and find within tag attr_defaults = [0, 'option0' ] # Defaults for attributes for when not found # Parse wav_string assuming set of object data in xml target tag self.objects = parse_xml_objects(self.objects, tag_target, wav_string, Nobj, attr, attr_defaults) # Print to screen print("\nXML parse attributes for tag = '{}':\n".format(tag_target)) for x in self.objects: for y in x: print("{:-12s}\t: {}".format(y, str(x[y]))) print() print()
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) self.objectLookup = {} self.volumes = {} for groupNode in arguments.iter('group'): groupName = groupNode.attrib['name'] objsStr = groupNode.attrib['objectIds'] initialVolume = dB2lin(float(groupNode.attrib['initialVolume'])) objIds = [int(s) for s in objsStr.split() if s.isdigit()] for objId in objIds: self.objectLookup[objId] = groupName self.volumes[groupName] = initialVolume
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # Set default levels self.object1level = 0 # dB self.object2level = 0 # dB self.object3level = 0 # dB # Set default mutes self.object1mute = 0 self.object2mute = 0 self.object3mute = 0
def __init__(self, arguments): #MetadataProcessorInterface.__init__(self, arguments) SequenceProcessorInterface.__init__(self, arguments) self.objectLookup = {} self.spread = {} for groupNode in arguments.iter('group'): groupName = groupNode.attrib['name'] objsStr = groupNode.attrib['objectIds'] initialSpread = float(groupNode.attrib['initialSpread']) objIds = [int(s) for s in objsStr.split() if s.isdigit()] for objId in objIds: self.objectLookup[objId] = groupName self.spread[groupName] = initialSpread
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # Set default values if 'maxAz' in arguments.attrib: self.maxAz = float(arguments.attrib['maxAz']) else: self.maxAz = 30.0 #Default is 30 if 'minAz' in arguments.attrib: self.minAz = float(arguments.attrib['minAz']) else: self.minAz = -30.0 #Default is -30 if 'positionActive' in arguments.attrib: self.positionActive = bool(int(arguments.attrib['positionActive'])) else: self.positionActive = True # Default is on if 'levelActive' in arguments.attrib: self.levelActive = bool(int(arguments.attrib['levelActive'])) else: self.levelActive = True # Default is on if 'positionCats' in arguments.attrib: cat = arguments.attrib['positionCats'] self.positionCats = cat.split() else: self.positionCats = 'none' if 'levelAdj' in arguments.attrib: levelAdjData = arguments.attrib['levelAdj'] levelAdjData = levelAdjData.replace('\'', '\"') # Fix JSON string levelAdjData = json.loads(levelAdjData) # Force keys to be lower case dict((k.lower(), v) for k, v in levelAdjData.items()) self.levelAdj = levelAdjData else: self.levelAdj = 'none' if 'verbose' in arguments.attrib: self.verbose = bool(int(arguments.attrib['verbose'])) else: self.verbose = False # Default is False
def __init__(self, arguments ): SequenceProcessorInterface.__init__(self, arguments) if 'id' in arguments.attrib: self.id = int( arguments.attrib['id'] ) else: self.id = 0 if 'active' in arguments.attrib: self.active = strtobool( arguments.attrib['active'] ) else: self.active = 0 if 'diffuse' in arguments.attrib: self.diffuse = float( arguments.attrib['diffuse'] ) else: self.diffuse = 0
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) self.room_filename = 'None' self.loudspeaker_config = 'None' if 'on' in arguments.attrib: self.on = int(arguments.attrib['on']) else: self.on = 1 # Default is on if 'priority' in arguments.attrib: self.priority = arguments.attrib['priority'] else: self.priority = 'quality' # Default is 'quality' if 'loudspeakerconfig' in arguments.attrib: self.loudspeaker_config = arguments.attrib['loudspeakerconfig'] else: self.loudspeaker_config = 'None' if 'roomdescription' in arguments.attrib: self.room_filename = arguments.attrib['roomdescription'] else: self.room_filename = 'None' if 'verbose' in arguments.attrib: self.verbose = arguments.attrib['verbose'] else: self.verbose = 1 #self.room_filename = arguments.attrib['roomdescription'] #self.loudspeaker_config = arguments.attrib['loudspeakerconfig'] #print "MDO status: %i. Priority: %s" % (self.on, self.priority) # On initialisation, try parsing the files. But they'll both be none currently # TODO: These could be settable in the metadapter config file? self.loudspeakers = Parse_Loudspeaker_Config(self.loudspeaker_config) self.room_objects = Parse_Room_Description(self.room_filename) # Flag for using advanced metadata (rather than group and priority) self.use_amd = 1 # Count the number of periods elapsed (this is used to print output less frequently) self.periods = 0
def __init__(self, arguments): #MetadataProcessorInterface.__init__(self, arguments) SequenceProcessorInterface.__init__(self, arguments) # Get arguments: if 'on' in arguments.attrib: self.on = int(arguments.attrib['on']) else: self.on = 1 # DEFAULT FOR NOW IS ON if 'envelopment' in arguments.attrib: self.env = float(arguments.attrib['envelopment']) else: self.env = 1.0 if 'verbose' in arguments.attrib: self.verbose = int(arguments.attrib['verbose']) else: self.verbose = 1 # DEFAULT FOR NOW IS VERBOSE
def __init__(self, arguments): # Mandatory call to the base class initialisation method SequenceProcessorInterface.__init__(self, arguments) # Any definition and initialisation of data local to the object # goes here. This includes any consitency checking of the settings in # arguments. # load the reverb object library file fp = open(arguments.attrib['libFile']) self.reverbLibrary = json.load(fp)['roomlibrary'] self.nRooms = len(self.reverbLibrary) print("%d rooms found in reverb library" % (self.nRooms)) #pprint(self.reverbLibrary) # define and intialise dictionary for room library self.roomName = arguments.attrib['initRoomName'] # inititalise the list of obejcts to add reverb to initReverbString = arguments.attrib['initObjs'] if initReverbString == "all": maxReverbObjects = 64 self.reverbObjectList = [] for i in range(0, 64): self.reverbObjectList.append(i) elif initReverbString == "none": self.reverbObjectList = [] elif initReverbString == "list": self.reverbObjectList = eval(arguments.attrib['initObjectList']) if type(self.reverbObjectList) == int: self.reverbObjectList = [self.reverbObjectList] try: 0 in self.reverbObjectList except TypeError: self.reverbObjectList = [self.reverbObjectList] else: print( "REVERB ERROR: initObjs string must be 'all', 'none' or 'list (with a corresponding comma separated initObjectList)'" ) print("reverb will be added to objects:") print(self.reverbObjectList)
def __init__(self, arguments): # Mandatory call to the base class initialisation method SequenceProcessorInterface.__init__(self, arguments) # Any definition and initialisation of data local to the object # goes here. This includes any consitency checking of the settings in # arguments. # initialize radius self.r = float(arguments.attrib['r']) # inititalise the list of obejcts to add reverb to self.editObjectList = eval(arguments.attrib['objectIds']) try: 0 in self.editObjectList except TypeError: self.editObjectList = [self.editObjectList] else: print("Edit distance error") print("distance modifications will be made to objects:") print(self.editObjectList)
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) if 'on' in arguments.attrib: self.on = int(arguments.attrib['on']) else: self.on = 0 if 'soundbarchannel' in arguments.attrib: self.soundbarchannel = int(arguments.attrib['soundbarchannel']) else: self.soundbarchannel = 'None' print( "WARNING: No soundbar channel specified. VBAP array will be used" ) if 'initialobjects' in arguments.attrib: objsStr = arguments.attrib['initialobjects'] self.objects = [int(s) for s in objsStr.split() if s.isdigit()] else: self.objects = []
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # Get UDP ports for receiving object metadata on if "udpPort" in arguments.attrib: self.udpPort = int(arguments.attrib["udpPort"]) else: self.udpPort = 9001 if "verbose" in arguments.attrib: self.verbose = bool(arguments.attrib["verbose"]) else: self.verbose = False if "messagePacketSize" in arguments.attrib: inputPacketSize = int(arguments.attrib["messagePacketSize"]) else: inputPacketSize = None if "writeToFile" in arguments.attrib: self.writeToFile = arguments.attrib["writeToFile"] else: self.writeToFile = '' if "updateMode" in arguments.attrib: self.updateMode = arguments.attrib["updateMode"] else: self.updateMode = 'update' # Set up receiver for object/group metadata #self.objReceiver = TableReceiver( self, verbose = True ) #if inputPacketSize == None: # reactor.listenUDP( self.udpPort, self.objReceiver ) #else: # reactor.listenUDP( self.udpPort, self.objReceiver, maxPacketSize=inputPacketSize ) self.objectData = {} self.groupData = {} self.objHistory = []
def __init__(self, arguments): #MetadataProcessorInterface.__init__(self, arguments) SequenceProcessorInterface.__init__(self, arguments) #self.objectLookup = {} self.objectLookup = {} # Get the groups which are soloed soloStr = arguments.attrib['initialSolo'] self.solo = soloStr.split() # Get active self.active = strtobool(arguments.attrib['active']) # Get the groups (names and object IDs) for groupNode in arguments.iter('group'): groupName = groupNode.attrib['name'] objsStr = groupNode.attrib['objectIds'] #initialSolo = [int(groupNode.attrib['initialSolo'])] objIds = [int(s) for s in objsStr.split() if s.isdigit()] for objId in objIds: self.objectLookup[objId] = groupName
def __init__(self, arguments ): SequenceProcessorInterface.__init__(self, arguments) # Set defaults self.az0 = 0 self.az1 = 0 self.az2 = 0 self.az3 = 0 self.az4 = 0 self.az5 = 0 self.az6 = 0 self.az7 = 0 self.lev0 = 0 self.lev1 = 0 self.lev2 = 0 self.lev3 = 0 self.lev4 = 0 self.lev5 = 0 self.lev6 = 0 self.lev7 = 0 self.overall_level = 0
def __init__(self, arguments): # Mandatory call to the base class initialisation method SequenceProcessorInterface.__init__(self, arguments) # Any definition and initialisation of data local to the object # goes here. This includes any consitency checking of the settings in # arguments. # initialize edit reverb values self.earlyLevelAdjust = float(arguments.attrib['earlyLevelAdjust']) self.lateLevelAdjust = float(arguments.attrib['lateLevelAdjust']) # [float(i) for i in levelstr.split(",")] self.lateSubbandLevelAdjust = [ float(iBand) for iBand in arguments.attrib['lateSubbandLevelAdjust'].split(",") ] self.lateDecayAdjust = float(arguments.attrib['lateDecayAdjust']) self.preDelayAdjust = float(arguments.attrib['preDelayAdjust']) self.preDelayAdjustLate = float(arguments.attrib['preDelayAdjustLate']) self.lateDelayAdjust = float(arguments.attrib['lateDelayAdjust']) if not len(self.lateSubbandLevelAdjust) == 9: print( "[load] Subband level adjustment must be specified in 9 subbands" ) if self.preDelayAdjust < 0: print("PreDelay cannot be less than 0 s") # inititalise the list of obejcts to add reverb to self.editObjectList = eval(arguments.attrib['objectIds']) try: 0 in self.editObjectList except TypeError: self.editObjectList = [self.editObjectList] else: print("REVERB EDIT_ERROR")
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) leveldB = float(arguments.attrib['volumeAdjust']) self.volumeChange = numpy.power(10.0, leveldB / 20.0)
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) # leveldB = float(arguments.attrib['volumeAdjust']) # self.volumeChange = numpy.power( 10.0, leveldB/20.0 ) # Load Room Array Response (RAR) #! Need to launch metadapter.py from inside /metadapter fp = open('./processors/room/RoomArrayResponse.json') self.RAR = json.load(fp)['objects'] self.nRAR = len(self.RAR) #print(self.nRAR) #print(self.RAR[1]['type']) # Load Array Config (AC) fp = open('./processors/room/ArrayConfig.xml') self.AC = objectify.fromstring(fp.read()) az1 = self.AC.loudspeaker[1].polar.get("az") # hasattr(self.AC.loudspeaker[1], 'polar') #print(az1) r = self.AC.loudspeaker[1].polar.get("r") #print(r) self.lateBandFreqs = (62.5, 125, 250, 500, 1000, 2000, 4000, 8000, 16000) # Init state self.sampleRate = 48000 # Reproduction room parameters # Processs RAR here to generate room adaptation parameters: self.roomAdaptOn = 0 self.roomLateLevel = 0.0 self.roomLateDecayConst = 1.0 self.roomLateFreqMax = self.sampleRate self.roomLateDelay = 0.0 self.directLevelScale = 1.0 self.earlyLevelScale = 1.0 self.lateLevelScale = 1.0 self.lateBandLevelScale = [1.0] * 9 self.earlyDelayScale = 1.0 self.earlyDelayOffset = 0.0 self.lateDelayScale = 1.0 self.lateDelayOffset = 0.0 self.lateAttackTimeScale = 1.0 self.lateAttackTimeOffset = 0.0 self.lateDecayTimeScale = 10.0 self.lateDecayTimeOffset = 0.0 I = {'a0': 1, 'a1': 0, 'a2': 0, 'b0': 1, 'b1': 0, 'b2': 0} self.directLowpassBiquad = I self.directHighpassBiquad = I self.earlyLowpassBiquad = I self.earlyHighpassBiquad = I self.lateLowpassCutoff = self.sampleRate self.lateHighpassCutoff = 0
def __init__(self, arguments): SequenceProcessorInterface.__init__(self, arguments) self.objectId = int(arguments.attrib['objectID']) self.active = strtobool(arguments.attrib['active'])
def __init__(self, arguments): #MetadataProcessorInterface.__init__(self, arguments) SequenceProcessorInterface.__init__(self, arguments) #leveldB = float(arguments.attrib['volumeAdjust']) #self.volumeChange = numpy.power( 10.0, leveldB/20.0 ) self.programme = 'None'
def __init__(self, arguments): #MetadataProcessorInterface.__init__(self, arguments) SequenceProcessorInterface.__init__(self, arguments) # Set up options self.options = {} #self.options['numsteps'] = 10 # This is the number of steps that are allowed between the current value and the maximum value (i.e. if max spread is 10, the stepsize will be 1) self.options[ 'tolerance'] = 10 # The acceptable tolerance either side of the target level that the predicted level should be self.options[ 'period'] = 10 # This is how many metadapter periods to wait before doing anything # Get arguments if 'on' in arguments.attrib: self.on = int(arguments.attrib['on']) else: self.on = 1 # DEFAULT FOR NOW IS ON if 'verbose' in arguments.attrib: self.verbose = int(arguments.attrib['verbose']) else: self.verbose = 1 # DEFAULT FOR NOW IS VERBOSE if 'target' in arguments.attrib: self.target_env = float(arguments.attrib['target']) else: self.target_env = 100 if 'tolerance' in arguments.attrib: self.options['tolerance'] = float(arguments.attrib['tolerance']) if 'period' in arguments.attrib: self.options['period'] = float(arguments.attrib['period']) # Initialise predicted envelopment self.predicted_env = 100 # This flag is used so that the envelopment is only checked and altered when a prediction is recieved self.check = False # Set up parameter vectors self.params = [] # Index Name # -------------------------- self.params.append(list(numpy.linspace( start=3.0, stop=-1.0, num=201))) # 0 Clear speech level self.params.append(list(numpy.linspace( start=0.0, stop=30.0, num=201))) # 1 Clear speech elevation self.params.append( list(numpy.linspace(start=-0.05, stop=0.75, num=201))) # 2 Foreground action level self.params.append( list(numpy.linspace(start=0.0, stop=1.0, num=101)) + list(numpy.linspace(start=1.0, stop=5.0, num=101))) # 3 Foreground action spread del (self.params[3][101]) self.params.append(list(numpy.linspace( start=-1.5, stop=1.8, num=201))) # 4 Background action level self.params.append( list(numpy.linspace(start=0.0, stop=1.0, num=101)) + list(numpy.linspace(start=1.0, stop=5.0, num=101))) # 5 Background action spread del (self.params[5][101]) self.params.append(list(numpy.linspace( start=-4.3, stop=8.0, num=201))) # 6 Reverb + effects level self.params.append( list(numpy.linspace(start=0.0, stop=1.0, num=101)) + list(numpy.linspace(start=1.0, stop=5.0, num=101))) # 7 Reverb + effects spread del (self.params[7][101]) self.params.append(list(numpy.linspace( start=0.6, stop=0.4, num=201))) # 8 Overall level self.params.append(list(numpy.linspace( start=-2.75, stop=1.0, num=201))) # 9 Overall LF boost self.params.append(list(numpy.linspace( start=0.0, stop=1.5, num=201))) # 10 Overall HF boost self.params.append(list(numpy.linspace(start=-2, stop=2, num=201))) # 11 Music level self.params.append( list(numpy.linspace(start=0.0, stop=1.0, num=101)) + list(numpy.linspace(start=1.0, stop=5.0, num=101))) # 12 Music spread del (self.params[12][101]) # Initialise the head position of the vector self.head = 100 self.count = 0 # Start a counter for the number of modifications that have been made self.periods = 0 # Count the number of metadapter periods