Refactor Vite configuration for improved chunking strategy and caching. Enhance DeviceContext with new upgradePeqChange method for PEQ updates. Update audio page to support localized labels and dynamic volume control. Introduce new filter types and improve EQPage functionality with enhanced frequency response visualization.
This commit is contained in:
@@ -13,8 +13,11 @@ export const TYPE_BANDPASS = 2;
|
||||
export const TYPE_NOTCH = 3;
|
||||
export const TYPE_ALLPASS = 7;
|
||||
|
||||
// Filter type mapping
|
||||
export function getFilterType(typeName: string): number {
|
||||
// Filter type mapping (device uses numeric type; pass-through when already a number)
|
||||
export function getFilterType(typeName: string | number): number {
|
||||
if (typeof typeName === "number" && Number.isFinite(typeName)) {
|
||||
return typeName;
|
||||
}
|
||||
switch (typeName) {
|
||||
case 'LPF':
|
||||
case 'LOW_PASS':
|
||||
@@ -309,10 +312,53 @@ export function visualizeResponse(coeffList: Coeff[], fs: number): [number[], nu
|
||||
}
|
||||
});
|
||||
|
||||
if (validCoeffList.length === 0) {
|
||||
const flat = f.map(() => 0);
|
||||
return [semilogf, flat];
|
||||
}
|
||||
|
||||
const overall = getFreqznList(validCoeffList, fs, f);
|
||||
return [semilogf, overall];
|
||||
}
|
||||
|
||||
/** Same log-spaced grid as visualizeResponse (20 Hz … 20 kHz, 349 points). */
|
||||
export function getPeqLogSpacedFreqs(): number[] {
|
||||
const n = 349;
|
||||
const startF = 20;
|
||||
const logStep = (Math.log10(20000) - Math.log10(20)) / n;
|
||||
const step = Math.pow(10, logStep);
|
||||
const f: number[] = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
f.push(startF * Math.pow(step, i));
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
export type PeqBandForResponse = {
|
||||
enabled: boolean;
|
||||
gain: number;
|
||||
freq: number;
|
||||
q: number;
|
||||
type: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Combined magnitude response (dB) per band — same pipeline as legacy:
|
||||
* getSectionsMatrix(...) per filter, then cascade via getFreqznList.
|
||||
*/
|
||||
export function computePeqMagnitudeDb(bands: PeqBandForResponse[], fs: number): number[] {
|
||||
const f = getPeqLogSpacedFreqs();
|
||||
const list: Coeff[] = [];
|
||||
bands.forEach((b) => {
|
||||
if (!b.enabled) return;
|
||||
list.push(getSectionsMatrix(b.gain, b.freq, b.q, getFilterType(b.type), false, fs));
|
||||
});
|
||||
if (list.length === 0) {
|
||||
return f.map(() => 0);
|
||||
}
|
||||
return getFreqznList(list, fs, f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ECharts options for frequency response chart
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user