From 93a74910bfaa753b7e521cd2b31b60cb7df3200a Mon Sep 17 00:00:00 2001 From: Steven Dan Date: Thu, 26 Mar 2026 17:41:35 +0800 Subject: [PATCH] eq update to 12 band --- .../src/extensions/eq.c | 10 +- .../src/extensions/eq.h | 12 +- .../src/extensions/eq_designer_new.py | 8 +- .../src/extensions/eq_hid_protocol.md | 24 ++-- .../src/extensions/eq_params_44100.h | 106 ++++++++++++++++++ 5 files changed, 134 insertions(+), 26 deletions(-) diff --git a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq.c b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq.c index da1b5b1..3468196 100644 --- a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq.c +++ b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq.c @@ -865,7 +865,8 @@ void init_mode_info(void) { // 初始化默认模式名称 const char* default_names[NUM_EQ_MODES] = { "JAZZ", "POP", "ROCK", "CLASIC", "R&B", - "3A Game", "FPS", "user 1", "user 2", "user3" + "3A Game", "FPS", "HI-FI", "VOCAL", "DANCE", + "user 1", "user 2" }; // 初始化默认增益(0dB) @@ -969,12 +970,11 @@ unsigned char process_read_params(uint8_t response[]) { if (read_request.pending_cmd == 0x91) { RSP_HDR(response, 0x91); - // 模式总数:预定义模式(0-5) + 用户模式(6-8) = 9,不包含禁用模式(10) - // 注意:NUM_EQ_MODES = 10,但实际可用模式是0-8共9个(不包含禁用模式10) - uint8_t mode_count = NUM_EQ_MODES; // 固定返回10 + // 模式总数:预定义模式(0-9) + 用户模式(10-11) = 12,不包含禁用模式(12) + uint8_t mode_count = NUM_EQ_MODES; // 固定返回12 response[2] = mode_count; - // 预定义模式数量:0-6共7个预设模式 + // 预定义模式数量:0-9共10个预设模式 uint8_t preset_mode_count = EQ_PRESET_MODE_MAX + 1; response[3] = preset_mode_count; diff --git a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq.h b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq.h index a5b387b..f83e019 100644 --- a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq.h +++ b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq.h @@ -7,15 +7,15 @@ #include #include -#define NUM_EQ_MODES 10 +#define NUM_EQ_MODES 12 #define NUM_EQ_CHANS 2 #define MAX_EQ_BANDS 8 -#define EQ_DISABLED_MODE 10 // 禁用EQ的模式编号 +#define EQ_DISABLED_MODE 12 // 禁用EQ的模式编号(超出有效范围) #define EQ_PRESET_MODE_MIN 0 // 预设模式最小编号 -#define EQ_PRESET_MODE_MAX 6 // 预设模式最大编号(preset1-preset6) -#define EQ_USER_MODE_MIN 7 // 用户模式最小编号 -#define EQ_USER_MODE_MAX 9 // 用户模式最大编号(user 1-4) -#define EQ_MODE_MAX (NUM_EQ_MODES) // 模式最大编号(user 1-4) +#define EQ_PRESET_MODE_MAX 9 // 预设模式最大编号(preset1-preset10) +#define EQ_USER_MODE_MIN 10 // 用户模式最小编号 +#define EQ_USER_MODE_MAX 11 // 用户模式最大编号(user 1-2) +#define EQ_MODE_MAX (NUM_EQ_MODES) // 模式最大编号 // Filter type definition diff --git a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_designer_new.py b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_designer_new.py index 0bf1eb2..e8330f1 100644 --- a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_designer_new.py +++ b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_designer_new.py @@ -53,8 +53,8 @@ from filter_utils import (BiquadFilterCalculator, make_biquad_bypass, make_biqua # 常量定义 MAX_EQ_BANDS = 8 # 最大EQ滤波器数量 (0-7) -NUM_EQ_MODES = 10 # EQ模式数量 -EQ_DISABLED_MODE = 10 # 禁用EQ的模式编号 +NUM_EQ_MODES = 12 # EQ模式数量(10预设 + 2用户) +EQ_DISABLED_MODE = 12 # 禁用EQ的模式编号 class BandFilter(QGroupBox): """单个滤波器带控件""" @@ -531,7 +531,9 @@ class EQDesigner(QMainWindow): mode_layout = QFormLayout(mode_group) self.mode_label = QLabel("EQ模式:") self.mode_combo = QComboBox() - self.mode_combo.addItems(["预设模式1", "预设模式2", "预设模式3", "预设模式4", "预设模式5", "预设模式6", "用户模式1", "用户模式2", "用户模式3", "bypass", "禁用EQ"]) + self.mode_combo.addItems(["预设模式1", "预设模式2", "预设模式3", "预设模式4", "预设模式5", + "预设模式6", "预设模式7", "预设模式8", "预设模式9", "预设模式10", + "用户模式1", "用户模式2", "禁用EQ"]) self.mode_combo.currentIndexChanged.connect(self.on_mode_changed) mode_layout.addRow(self.mode_label, self.mode_combo) diff --git a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_hid_protocol.md b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_hid_protocol.md index d411ce6..a6eb9c7 100644 --- a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_hid_protocol.md +++ b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_hid_protocol.md @@ -156,7 +156,7 @@ ---------|------|------|------ 0 | 1 | 0x77 | 同步头1 1 | 1 | 0x8A | 命令码 -2 | 1 | uint8 | 模式值 (0-5: 预设模式, 6-8: 用户模式, 9: bypass) +2 | 1 | uint8 | 模式值 (0-9: 预设模式, 10-11: 用户模式) 3-62 | 60 | 0x00 | 保留字节 ``` @@ -170,13 +170,13 @@ ---------|------|------|------ 0 | 1 | 0x77 | 同步头1 1 | 1 | 0x8B | 命令码 -2 | 1 | uint8 | 模式值 (0-9: 有效模式值, 0xFF: 获取当前模式信息) +2 | 1 | uint8 | 模式值 (0-11: 有效模式值, 0xFF: 获取当前模式信息) 3-62 | 60 | 0x00 | 保留字节 ``` **设备端处理**: - 如果mode值为0xFF,返回当前模式值、整体增益和模式名称 -- 如果mode值为有效模式值(0-9),返回指定模式值、整体增益和模式名称 +- 如果mode值为有效模式值(0-11),返回指定模式值、整体增益和模式名称 @@ -195,7 +195,7 @@ **使用说明**: - 发送mode=0xFF时,返回当前激活的EQ模式信息 -- 发送mode=0-9时,返回指定模式的增益和名称信息(不切换当前模式) +- 发送mode=0-11时,返回指定模式的增益和名称信息(不切换当前模式) ### 2.3 0x8C - SET_MODE_GAIN_AND_NAME (设置模式整体增益和名称) **功能**: 设置EQ模式整体增益和名称 @@ -206,7 +206,7 @@ ---------|------|------|------ 0 | 1 | 0x77 | 同步头1 1 | 1 | 0x8C | 命令码 -2 | 1 | uint8 | 模式值 (0-9) +2 | 1 | uint8 | 模式值 (0-11) 3-6 | 4 | int32 | 增益值 (范围0到-50dB,有符号整数) 7-22 | 16 | char | 模式名称 (UTF-8编码,16字节) 23-62 | 40 | 0x00 | 保留字节 @@ -226,7 +226,7 @@ ---------|------|------|------ 0 | 1 | 0x77 | 同步头1 1 | 1 | 0x8D | 命令码 -2 | 1 | uint8 | 模式值 (0-9) +2 | 1 | uint8 | 模式值 (0-11) 3 | 1 | uint8 | 滤波器Band索引 (0-7) 4 | 1 | uint8 | 滤波器类型 5-8 | 4 | float | 中心频率 (Hz) @@ -260,7 +260,7 @@ ---------|------|------|------ 0 | 1 | 0x77 | 同步头1 1 | 1 | 0x8E | 命令码 -2 | 1 | uint8 | 模式值 (0-9) +2 | 1 | uint8 | 模式值 (0-11) 3 | 1 | uint8 | EQ索引 (0-7) 4-62 | 59 | 0x00 | 保留字节 ``` @@ -272,7 +272,7 @@ 0 | 1 | 0x01 | Report ID 1 | 1 | 0x77 | 同步头1 2 | 1 | 0x8E | 同步头2 -3 | 1 | uint8 | 模式值 (0-9) +3 | 1 | uint8 | 模式值 (0-11) 4 | 1 | uint8 | 滤波器Band索引 (0-7) 5 | 1 | uint8 | 滤波器类型 6-9 | 4 | float | 中心频率 (Hz) @@ -318,7 +318,7 @@ ---------|------|------|------ 0 | 1 | 0x77 | 同步头1 1 | 1 | 0x90 | 命令码 -2 | 1 | uint8 | 模式号 (0-9, 0xFF表示恢复所有包括EQ参数,总体增益,模式名称 ) +2 | 1 | uint8 | 模式号 (0-11, 0xFF表示恢复所有包括EQ参数,总体增益,模式名称 ) 3-62 | 60 | 0x00 | 保留字节 ``` @@ -352,8 +352,8 @@ 0 | 1 | 0x01 | Report ID 1 | 1 | 0x77 | 同步头1 2 | 1 | 0x91 | 同步头2 -3 | 1 | uint8 | 模式总数 (当前为9,包含0-8共9个模式,不包含禁用模式) -4 | 1 | uint8 | 预定义模式数量 (当前为6,包含0-5共6个预设模式) +3 | 1 | uint8 | 模式总数 (当前为12,包含0-11共12个模式,不包含禁用模式) +4 | 1 | uint8 | 预定义模式数量 (当前为10,包含0-9共10个预设模式) 5-62 | 58 | 0x00 | 保留字节 ``` @@ -366,7 +366,7 @@ ---------|------|------|------ 0 | 1 | 0x77 | 同步头1 1 | 1 | 0x92 | 命令码 -2 | 1 | uint8 | 模式值 (0-9: 0-5预设模式, 6-8用户模式, 9: bypass) +2 | 1 | uint8 | 模式值 (0-11: 0-9预设模式, 10-11用户模式) 3-62 | 60 | 0x00 | 保留字节 ``` diff --git a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_params_44100.h b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_params_44100.h index bec730f..d8f4de4 100644 --- a/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_params_44100.h +++ b/sw_usb_audio/app_usb_aud_phaten_golden_6ch/src/extensions/eq_params_44100.h @@ -1645,4 +1645,110 @@ eq_mode_data_t sEQ_data_44100HZ[NUM_EQ_MODES][NUM_EQ_CHANS] = { }, } }, + // 用户模式 10 (user 1) - 平坦初始值,用户可自定义 + [10][0] = { + .sample_rate = 44100, + .total_bshift = 0, + .post_gain_db = 0, + .bands = { + { .index = 0, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 1, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 2, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 3, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 4, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 5, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 6, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 7, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + }, + .filter = { + .biquad_count = MAX_EQ_BANDS, + .state = {{0}}, + .coef = { + {0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + }, + } + }, + [10][1] = { + .sample_rate = 44100, + .total_bshift = 0, + .post_gain_db = 0, + .bands = { + { .index = 0, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 1, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 2, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 3, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 4, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 5, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 6, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 7, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + }, + .filter = { + .biquad_count = MAX_EQ_BANDS, + .state = {{0}}, + .coef = { + {0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + }, + } + }, + // 用户模式 11 (user 2) - 平坦初始值,用户可自定义 + [11][0] = { + .sample_rate = 44100, + .total_bshift = 0, + .post_gain_db = 0, + .bands = { + { .index = 0, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 1, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 2, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 3, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 4, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 5, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 6, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 7, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + }, + .filter = { + .biquad_count = MAX_EQ_BANDS, + .state = {{0}}, + .coef = { + {0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + }, + } + }, + [11][1] = { + .sample_rate = 44100, + .total_bshift = 0, + .post_gain_db = 0, + .bands = { + { .index = 0, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 1, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 2, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 3, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 4, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 5, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 6, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + { .index = 7, .type = FILTER_TYPE_BYPASS, .fc = 1000.00f, .q = 0.7100f, .bw = 1.00f, .gain = 0.00f }, + }, + .filter = { + .biquad_count = MAX_EQ_BANDS, + .state = {{0}}, + .coef = { + {0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000, 0x40000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + }, + } + }, };