Files
controller-v2/client/src/pages/eq/constants.ts
T

175 lines
5.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { CSSProperties } from "react";
import type { PeqFilter, PeqState } from "@/lib/luxsinApi";
import localeZh from "@/locales/data-zh.json";
/* ── Filter types ── */
export const FILTER_TYPES = [
"LPF",
"HPF",
"BPF",
"NOTCH",
"PEAK",
"LSHELF",
"HSHELF",
"APF",
];
/* ── Band parameter ranges ── */
export const BAND_FREQ_MIN = 20;
export const BAND_FREQ_MAX = 20000;
export const BAND_GAIN_MIN = -15;
export const BAND_GAIN_MAX = 15;
export const BAND_Q_MIN = 0.1;
export const BAND_Q_MAX = 10;
/** Maximum headphone PEQ presets stored on device. */
export const PEQ_PRESET_MAX = 50;
/** Maximum characters for a custom PEQ preset name (letter, CJK, symbol, or space = 1). */
export const PEQ_PRESET_NAME_MAX_LENGTH = 80;
export type BandParamKind = "freq" | "gain" | "q";
/* ── Band param value box style ── */
export const BAND_PARAM_VALUE_BOX_STYLE: CSSProperties = {
background: "rgba(44,44,46,0.9)",
border: "1px solid rgba(255,255,255,0.08)",
};
/* ── EQ UI locale type ── */
export type PeqEqUi = NonNullable<
NonNullable<(typeof localeZh)["peq"]>["eqUi"]
>;
/* ── Default bands matching reference image ── */
export const DEFAULT_BANDS = [
{ freq: 9500, gain: 0, q: 1.41, type: "LSHELF", enabled: true, bypassed: false },
{ freq: 9200, gain: -2, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 220, gain: 1, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 500, gain: -3, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 1200, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 13800, gain: -1, q: 1.41, type: "NOTCH", enabled: true, bypassed: false },
{ freq: 11000, gain: -2, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 7400, gain: 1, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 8200, gain: -1, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 10000, gain: 0, q: 1.41, type: "HSHELF", enabled: true, bypassed: false },
];
/* ── Flat bands:无预设/未加载时展示的平直曲线(10 个 gain=0 的 PEAK) ── */
export const FLAT_BANDS: typeof DEFAULT_BANDS = [
{ freq: 80, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 150, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 350, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 750, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 1500, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 3000, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 6000, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 10000, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 14000, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
{ freq: 18000, gain: 0, q: 1.41, type: "PEAK", enabled: true, bypassed: false },
];
/* ── PEQ catalog item type ── */
export type PeqCatalogItem = NonNullable<PeqState["peq"]>[number];
/** 本地编辑缓存(按预设名称);syncPeq 拉取时优先于设备 catalog */
export type PeqPresetLocalCache = {
filters?: PeqFilter[];
preamp?: number;
autoPre?: number;
};
/* ── Flat preset filters ── */
export const FLAT_PRESET_FILTERS: PeqFilter[] = [
{ type: 4, fc: 80, gain: 0, q: 0.1 },
{ type: 4, fc: 150, gain: 0, q: 0.1 },
{ type: 4, fc: 350, gain: 0, q: 0.1 },
{ type: 4, fc: 750, gain: 0, q: 0.1 },
{ type: 4, fc: 1500, gain: 0, q: 0.1 },
{ type: 4, fc: 3000, gain: 0, q: 0.1 },
{ type: 4, fc: 6000, gain: 0, q: 0.1 },
{ type: 4, fc: 10000, gain: 0, q: 0.1 },
{ type: 4, fc: 14000, gain: 0, q: 0.1 },
{ type: 4, fc: 18000, gain: 0, q: 0.1 },
];
/* ── Catalog target type & data ── */
export type CatalogTarget = {
name: string;
bassBoost: { fc: number; q: number; gain: number };
ear: "in" | "over" | "all";
};
export const CATALOG_TARGETS: CatalogTarget[] = [
{
name: "Harman over-ear 2018",
bassBoost: { fc: 105, q: 0.7, gain: 6 },
ear: "over",
},
{
name: "HMS II.3 Harman over-ear 2018",
bassBoost: { fc: 105, q: 0.7, gain: 6 },
ear: "over",
},
{
name: "crinacle EARS + 711 Harman over-ear 2018",
bassBoost: { fc: 105, q: 0.7, gain: 6 },
ear: "over",
},
{
name: "Harman in-ear 2019",
bassBoost: { fc: 105, q: 0.7, gain: 9.5 },
ear: "in",
},
{
name: "AutoEq in-ear",
bassBoost: { fc: 105, q: 0.7, gain: 8 },
ear: "in",
},
{
name: "HMS II.3 AutoEq in-ear",
bassBoost: { fc: 105, q: 0.7, gain: 8 },
ear: "in",
},
{
name: "HMS II.3 Harman in-ear 2019",
bassBoost: { fc: 105, q: 0.7, gain: 9.5 },
ear: "in",
},
{
name: "Diffuse Field 5128 (-1 dB/oct)",
bassBoost: { fc: 105, q: 0.7, gain: 0 },
ear: "over",
},
{
name: "LMG 5128 0.6 without bass",
bassBoost: { fc: 105, q: 0.7, gain: 6 },
ear: "over",
},
{
name: "JM-1 with Harman filters",
bassBoost: { fc: 105, q: 0.7, gain: 6.5 },
ear: "all",
},
{
name: "oratory1990 in-ear",
bassBoost: { fc: 105, q: 0.7, gain: 9.5 },
ear: "in",
},
{
name: "oratory1990 over-ear",
bassBoost: { fc: 105, q: 0.7, gain: 6 },
ear: "over",
},
{
name: "Harman over-ear 2013",
bassBoost: { fc: 105, q: 0.7, gain: 6 },
ear: "over",
},
{
name: "Flat",
bassBoost: { fc: 105, q: 0.7, gain: 0 },
ear: "all",
},
];