eq update to 12 band

This commit is contained in:
Steven Dan
2026-03-26 17:41:35 +08:00
parent fbcd59dfc6
commit 93a74910bf
5 changed files with 134 additions and 26 deletions

View File

@@ -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;

View File

@@ -7,15 +7,15 @@
#include <stdint.h>
#include <stdbool.h>
#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

View File

@@ -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)

View File

@@ -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 | 保留字节
```

View File

@@ -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},
},
}
},
};