def split_by_net_role(obj): # Actor Mixer和Virtual Folder无法被放在SwitchContainer下面 if obj['type'] == 'ActorMixer' or obj['type'] == 'Folder': return original_name = obj['name'] # 拆分结构并重组到SwitchContainer下面 old_parent = WaapiTools.get_parent_objects(obj, False) new_parent = WaapiTools.create_object(original_name + '_Temp', 'SwitchContainer', old_parent, 'rename') WaapiTools.move_object(obj, new_parent) obj_2p = WaapiTools.copy_object(obj, new_parent) obj_3p = WaapiTools.copy_object(obj, new_parent) WaapiTools.rename_object(obj, original_name + '_1P') WaapiTools.rename_object(obj_2p, original_name + '_2P') WaapiTools.rename_object(obj_3p, original_name + '_3P') WaapiTools.rename_object(new_parent, original_name) # 分配bus original_bus = WaapiTools.get_object_property(obj, '@OutputBus') original_bus_name = original_bus['name'] bus_1p = WaapiTools.find_object_by_name(original_bus_name + '_1P', 'Bus') if bus_1p is None: bus_1p = WaapiTools.create_object(original_bus_name + '_1P', 'Bus', original_bus, 'replace') bus_2p = WaapiTools.find_object_by_name(original_bus_name + '_2P', 'Bus') if bus_2p is None: bus_2p = WaapiTools.create_object(original_bus_name + '_2P', 'Bus', original_bus, 'replace') bus_3p = WaapiTools.find_object_by_name(original_bus_name + '_3P', 'Bus') if bus_3p is None: bus_3p = WaapiTools.create_object(original_bus_name + '_3P', 'Bus', original_bus, 'replace') WaapiTools.set_object_property(obj, 'OverrideOutput', True) WaapiTools.set_object_reference(obj, 'OutputBus', bus_1p) WaapiTools.set_object_property(obj_2p, 'OverrideOutput', True) WaapiTools.set_object_reference(obj_2p, 'OutputBus', bus_2p) WaapiTools.set_object_property(obj_3p, 'OverrideOutput', True) WaapiTools.set_object_reference(obj_3p, 'OutputBus', bus_3p) net_role_switch_group = WaapiTools.find_object_by_name( 'Net_Role', 'SwitchGroup') if net_role_switch_group is None: return WaapiTools.set_object_reference(new_parent, 'SwitchGroupOrStateGroup', net_role_switch_group) for switch_obj in WaapiTools.get_children_objects(net_role_switch_group, False): if '1P' in switch_obj['name']: assign_switch_mapping(obj, switch_obj) WaapiTools.set_object_reference(new_parent, 'DefaultSwitchOrState', switch_obj) if '2P' in switch_obj['name']: assign_switch_mapping(obj_2p, switch_obj) if '3P' in switch_obj['name']: assign_switch_mapping(obj_3p, switch_obj)
def set_inclusion(self, included: bool): self.batchProcessor = BatchProcessor( self.activeObjects, lambda obj: WaapiTools.set_object_property( obj, 'Inclusion', True if included else False)) self.batchProcessor.start()
def reset_source_editor(sound_object): if sound_object['type'] != 'AudioFileSource': return WaapiTools.set_object_property(sound_object, 'FadeInDuration', 0) WaapiTools.set_object_property(sound_object, 'FadeOutDuration', 0) WaapiTools.set_object_property(sound_object, 'TrimBegin', -1) WaapiTools.set_object_property(sound_object, 'TrimEnd', -1) WaapiTools.set_object_property(sound_object, 'LoopBegin', -1) WaapiTools.set_object_property(sound_object, 'LoopEnd', -1)
def apply_fader_edits_downstream(obj): volume_bias = WaapiTools.get_object_property(obj, '@Volume') pitch_bias = WaapiTools.get_object_property(obj, '@Pitch') low_pass_bias = WaapiTools.get_object_property(obj, '@Lowpass') high_pass_bias = WaapiTools.get_object_property(obj, '@Highpass') WaapiTools.set_object_property(obj, 'Volume', 0) WaapiTools.set_object_property(obj, 'Pitch', 0) WaapiTools.set_object_property(obj, 'Lowpass', 0) WaapiTools.set_object_property(obj, 'Highpass', 0) children = WaapiTools.get_children_objects(obj, False) for child in children: volume_base = WaapiTools.get_object_property(child, '@Volume') pitch_base = WaapiTools.get_object_property(child, '@Pitch') low_pass_base = WaapiTools.get_object_property(child, '@Lowpass') high_pass_base = WaapiTools.get_object_property(child, '@Highpass') WaapiTools.set_object_property(child, 'Volume', volume_base + volume_bias) WaapiTools.set_object_property(child, 'Pitch', pitch_base + pitch_bias) WaapiTools.set_object_property(child, 'Lowpass', low_pass_base + low_pass_bias) WaapiTools.set_object_property(child, 'Highpass', high_pass_base + high_pass_bias) # 递归应用编辑 if child['type'] != 'Sound': apply_fader_edits_downstream(child)