feat(eq): 使用平直曲线作为默认预设显示

- 新增 FLAT_BANDS 平直曲线预设,包含10个增益为0的PEAK滤波器
- 默认初始化bandsByMode状态使用FLAT_BANDS替代旧的DEFAULT_BANDS
- 在无远程peq数据或切换耳机时,默认设置为FLAT_BANDS
- 无滤波器时恢复平直曲线并清空原始参考线状态
- 保持FLAT_BANDS预设一致性优化未加载状态的体验
This commit is contained in:
eafonyang
2026-08-28 18:47:24 +08:00
parent bf8a06eff7
commit f6f8bee11a
2 changed files with 27 additions and 5 deletions
+13 -5
View File
@@ -61,6 +61,7 @@ import {
BAND_Q_MIN,
DEFAULT_BANDS,
FILTER_TYPES,
FLAT_BANDS,
FLAT_PRESET_FILTERS,
PEQ_PRESET_MAX,
} from "./eq/eqConstants";
@@ -122,8 +123,8 @@ export default function EQPage() {
const eqPageTitle = usePageTitleWithConnection("HP-EQ");
const [bandsByMode, setBandsByMode] = useState<Record<"A" | "B", typeof DEFAULT_BANDS>>({
A: cloneBands(DEFAULT_BANDS),
B: cloneBands(DEFAULT_BANDS),
A: cloneBands(FLAT_BANDS),
B: cloneBands(FLAT_BANDS),
});
const [selectedBandByMode, setSelectedBandByMode] = useState<Record<"A" | "B", number>>({
A: 0,
@@ -609,7 +610,7 @@ export default function EQPage() {
const items = remote.peq ?? [];
if (items.length === 0) {
setBandsForBothModes(DEFAULT_BANDS);
setBandsForBothModes(FLAT_BANDS);
setSelectedBandByMode({ A: 0, B: 0 });
return;
}
@@ -1013,7 +1014,7 @@ export default function EQPage() {
setHeadphoneModels([]);
setPeqItems([]);
selectHeadphone(0, "");
setBandsForBothModes(DEFAULT_BANDS);
setBandsForBothModes(FLAT_BANDS);
setSelectedBandByMode({ A: 0, B: 0 });
setCurrentRawCurve(null);
}
@@ -1061,7 +1062,14 @@ export default function EQPage() {
// 切换耳机型号后,从 peqItems 加载该型号的 filters(暂停一次上报避免错写)
useEffect(() => {
const peq = peqItems[headphoneIdx];
if (!peq) return;
if (!peq) {
// 列表为空(如设备端删光全部预设):恢复平直曲线并清空 Raw 参考线
setBandsForBothModes(FLAT_BANDS);
setSelectedBandByMode({ A: 0, B: 0 });
setCurrentRawCurve(null);
setRawCurveLoading(false);
return;
}
const nextBands = normalizeFiltersFromPeq(peq);
if (!nextBands.length) return;
syncingHeadphoneRef.current = true;
+14
View File
@@ -36,6 +36,20 @@ export const DEFAULT_BANDS: EqBand[] = [
{ freq: 10000, gain: 0, q: 1.41, type: "HSHELF", enabled: true },
];
/** Flat bands:无预设/未加载时展示的平直曲线(10 个 gain=0 的 PEAK */
export const FLAT_BANDS: EqBand[] = [
{ freq: 80, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 150, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 350, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 750, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 1500, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 3000, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 6000, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 10000, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 14000, gain: 0, q: 1.41, type: "PEAK", enabled: true },
{ freq: 18000, gain: 0, q: 1.41, type: "PEAK", enabled: true },
];
export const FLAT_PRESET_FILTERS: PeqFilter[] = [
{ type: 4, fc: 80, gain: 0, q: 0.1 },
{ type: 4, fc: 150, gain: 0, q: 0.1 },