diff --git a/client/src/pages/EQPage.tsx b/client/src/pages/EQPage.tsx index 0b17a56..fda6465 100644 --- a/client/src/pages/EQPage.tsx +++ b/client/src/pages/EQPage.tsx @@ -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>({ - A: cloneBands(DEFAULT_BANDS), - B: cloneBands(DEFAULT_BANDS), + A: cloneBands(FLAT_BANDS), + B: cloneBands(FLAT_BANDS), }); const [selectedBandByMode, setSelectedBandByMode] = useState>({ 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; diff --git a/client/src/pages/eq/eqConstants.ts b/client/src/pages/eq/eqConstants.ts index c9236c7..d2bdcd2 100644 --- a/client/src/pages/eq/eqConstants.ts +++ b/client/src/pages/eq/eqConstants.ts @@ -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 },