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)
def filter_objects_by_inclusion(objects: list, inclusion: bool):
    objects_filtered = []
    for obj in objects:
        # 音频资源没有inclusion选项
        if obj['type'] == 'AudioFileSource':
            continue
        if WaapiTools.get_object_property(obj, '@Inclusion') == inclusion:
            objects_filtered.append(obj)
    return objects_filtered
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 replace_event(self, event_obj):
     new_event_name = event_obj['name'].replace(self.__oldName,
                                                self.__newName).replace(
                                                    '_01', '')
     WaapiTools.rename_object(event_obj, new_event_name)
     for action in WaapiTools.get_children_objects(event_obj, False):
         target = WaapiTools.get_object_property(action, '@Target')
         target_full = WaapiTools.get_full_info_from_obj_id(target['id'])
         new_target_path = target_full['path'].replace(
             self.__oldName, self.__newName)
         new_target = WaapiTools.get_object_from_path(new_target_path)
         if new_target is not None:
             WaapiTools.set_object_reference(action, 'Target', new_target)