feat(eq): 使用平直曲线作为默认预设显示
- 新增 FLAT_BANDS 平直曲线预设,包含10个增益为0的PEAK滤波器 - 默认初始化bandsByMode状态使用FLAT_BANDS替代旧的DEFAULT_BANDS - 在无远程peq数据或切换耳机时,默认设置为FLAT_BANDS - 无滤波器时恢复平直曲线并清空原始参考线状态 - 保持FLAT_BANDS预设一致性优化未加载状态的体验
This commit is contained in:
@@ -53,6 +53,7 @@ import {
|
|||||||
BAND_Q_MAX,
|
BAND_Q_MAX,
|
||||||
BAND_PARAM_VALUE_BOX_STYLE,
|
BAND_PARAM_VALUE_BOX_STYLE,
|
||||||
DEFAULT_BANDS,
|
DEFAULT_BANDS,
|
||||||
|
FLAT_BANDS,
|
||||||
FLAT_PRESET_FILTERS,
|
FLAT_PRESET_FILTERS,
|
||||||
PEQ_PRESET_MAX,
|
PEQ_PRESET_MAX,
|
||||||
type BandParamKind,
|
type BandParamKind,
|
||||||
@@ -136,8 +137,8 @@ export default function EQPage() {
|
|||||||
const [bandsByMode, setBandsByMode] = useState<
|
const [bandsByMode, setBandsByMode] = useState<
|
||||||
Record<"A" | "B", typeof DEFAULT_BANDS>
|
Record<"A" | "B", typeof DEFAULT_BANDS>
|
||||||
>({
|
>({
|
||||||
A: cloneBands(DEFAULT_BANDS),
|
A: cloneBands(FLAT_BANDS),
|
||||||
B: cloneBands(DEFAULT_BANDS),
|
B: cloneBands(FLAT_BANDS),
|
||||||
});
|
});
|
||||||
const [selectedBandByMode, setSelectedBandByMode] = useState<
|
const [selectedBandByMode, setSelectedBandByMode] = useState<
|
||||||
Record<"A" | "B", number>
|
Record<"A" | "B", number>
|
||||||
@@ -605,7 +606,7 @@ export default function EQPage() {
|
|||||||
|
|
||||||
const items = remote.peq ?? [];
|
const items = remote.peq ?? [];
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
setBandsForBothModes(DEFAULT_BANDS);
|
setBandsForBothModes(FLAT_BANDS);
|
||||||
setSelectedBandByMode({ A: 0, B: 0 });
|
setSelectedBandByMode({ A: 0, B: 0 });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1043,7 +1044,7 @@ export default function EQPage() {
|
|||||||
setHeadphoneModels([]);
|
setHeadphoneModels([]);
|
||||||
setPeqItems([]);
|
setPeqItems([]);
|
||||||
selectHeadphone(0, "");
|
selectHeadphone(0, "");
|
||||||
setBandsForBothModes(DEFAULT_BANDS);
|
setBandsForBothModes(FLAT_BANDS);
|
||||||
setSelectedBandByMode({ A: 0, B: 0 });
|
setSelectedBandByMode({ A: 0, B: 0 });
|
||||||
setCurrentRawCurve(null);
|
setCurrentRawCurve(null);
|
||||||
}
|
}
|
||||||
@@ -1102,7 +1103,14 @@ export default function EQPage() {
|
|||||||
// 切换耳机型号后,从 peqItems 加载该型号的 filters(暂停一次上报避免错写)
|
// 切换耳机型号后,从 peqItems 加载该型号的 filters(暂停一次上报避免错写)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const peq = peqItems[headphoneIdx];
|
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);
|
const nextBands = normalizeFiltersFromPeq(peq);
|
||||||
if (!nextBands.length) return;
|
if (!nextBands.length) return;
|
||||||
syncingHeadphoneRef.current = true;
|
syncingHeadphoneRef.current = true;
|
||||||
|
|||||||
@@ -55,6 +55,20 @@ export const DEFAULT_BANDS = [
|
|||||||
{ freq: 10000, gain: 0, q: 1.41, type: "HSHELF", enabled: true },
|
{ freq: 10000, gain: 0, q: 1.41, type: "HSHELF", enabled: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/* ── Flat bands:无预设/未加载时展示的平直曲线(10 个 gain=0 的 PEAK) ── */
|
||||||
|
export const FLAT_BANDS: typeof DEFAULT_BANDS = [
|
||||||
|
{ 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 },
|
||||||
|
];
|
||||||
|
|
||||||
/* ── PEQ catalog item type ── */
|
/* ── PEQ catalog item type ── */
|
||||||
export type PeqCatalogItem = NonNullable<PeqState["peq"]>[number];
|
export type PeqCatalogItem = NonNullable<PeqState["peq"]>[number];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user