brisonus_app_eq/config/gen_table_config.py
2025-02-19 17:49:20 +08:00

69 lines
2.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def generate_channel_config(channel_num):
"""为指定通道号生成配置"""
# 基础参数配置,保持原始名称
channel_config = [
{"delay_data1": f"delay_data{channel_num}"},
{"vol_data1": f"vol_data{channel_num}"},
{"mix_right_data1": f"mix_right_data{channel_num}"},
{"mix_left_data1": f"mix_left_data{channel_num}"},
]
# 添加20个滤波器的配置
for filter_num in range(1, 21):
filter_config = {
f"Filter_{filter_num}": f"fc{channel_num}_{filter_num}",
f"q{channel_num}_{filter_num}": f"q{channel_num}_{filter_num}",
f"gain{channel_num}_{filter_num}": f"gain{channel_num}_{filter_num}",
f"slope{channel_num}_{filter_num}": f"slope{channel_num}_{filter_num}",
f"filterType{channel_num}_{filter_num}": f"filterType{channel_num}_{filter_num}"
}
channel_config.append(filter_config)
return channel_config
def generate_table_config():
"""生成完整的table_config配置"""
table_config = {}
# 为6个通道生成配置
for channel_num in range(1, 7):
channel_key = f"channel_{channel_num}"
table_config[channel_key] = generate_channel_config(channel_num)
return table_config
def write_config_to_file(config, filename="table_config.py"):
"""将配置写入Python文件"""
with open(filename, 'w', encoding='utf-8') as f:
f.write("table_config = {\n")
# 写入每个通道的配置
for channel_idx, (channel_key, channel_config) in enumerate(config.items()):
f.write(f" \"{channel_key}\": [\n")
# 写入通道内的每个配置项
for item_idx, item in enumerate(channel_config):
item_str = str(item).replace("'", "\"")
if item_idx < len(channel_config) - 1:
f.write(f" {item_str},\n")
else:
f.write(f" {item_str}\n")
# 添加通道结束括号
if channel_idx < len(config) - 1:
f.write(" ],\n")
else:
f.write(" ]\n")
f.write("}\n")
def main():
# 生成配置
config = generate_table_config()
# 写入文件
write_config_to_file(config, "table_config.py")
print("配置文件已生成table_config.py")
if __name__ == "__main__":
main()