diff --git a/src/common/constants.ts b/src/common/constants.ts index 8d9bed2da..b66814eb6 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -20,13 +20,13 @@ along with this program. If not, see . import { uid } from 'uid'; -export const MAX_GAIN = 30; -export const MIN_GAIN = -30; +export const MAX_GAIN = 20; +export const MIN_GAIN = -20; export const MAX_FREQUENCY = 20000; export const MIN_FREQUENCY = 1; -export const MAX_QUALITY = 100; -export const MIN_QUALITY = 0.01; +export const MAX_QFACTOR = 100; +export const MIN_QFACTOR = 0.01; export const MAX_NUM_FILTERS = 20; // TODO: Investigate an appropriate value for this export const MIN_NUM_FILTERS = 1; @@ -78,7 +78,7 @@ export interface IFilter { frequency: number; gain: number; type: FilterTypeEnum; - quality: number; + qfactor: number; } export interface IState { @@ -109,7 +109,7 @@ const FIXED_FREQUENCIES = [ const DEFAULT_FILTER_TEMPLATE = { frequency: 1000, gain: 0, - quality: 1, + qfactor: 1, type: FilterTypeEnum.PK, }; diff --git a/src/main/main.ts b/src/main/main.ts index 12939b676..edf7781b8 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -57,11 +57,11 @@ import { MAX_FREQUENCY, MAX_GAIN, MAX_NUM_FILTERS, - MAX_QUALITY, + MAX_QFACTOR, MIN_FREQUENCY, MIN_GAIN, MIN_NUM_FILTERS, - MIN_QUALITY, + MIN_QFACTOR, WINDOW_HEIGHT, WINDOW_HEIGHT_EXPANDED, WINDOW_WIDTH, @@ -532,7 +532,7 @@ ipcMain.on(ChannelEnum.GET_FILTER_QUALITY, async (event, arg) => { } const reply: TSuccess = { - result: state.filters[filterId].quality || 10, + result: state.filters[filterId].qfactor || 10, }; event.reply(channel + filterId, reply); }); @@ -540,19 +540,19 @@ ipcMain.on(ChannelEnum.GET_FILTER_QUALITY, async (event, arg) => { ipcMain.on(ChannelEnum.SET_FILTER_QUALITY, async (event, arg) => { const channel = ChannelEnum.SET_FILTER_QUALITY; const filterId = arg[0]; - const quality = parseFloat(arg[1]) || 0; + const qfactor = parseFloat(arg[1]) || 0; // Filter id must exist if (!doesFilterIdExist(event, channel, filterId)) { return; } - if (quality < MIN_QUALITY || quality > MAX_QUALITY) { + if (qfactor < MIN_QFACTOR || qfactor > MAX_QFACTOR) { handleError(event, channel + filterId, ErrorCode.INVALID_PARAMETER); return; } - state.filters[filterId].quality = quality; + state.filters[filterId].qfactor = qfactor; await handleUpdate(event, channel + filterId); }); diff --git a/src/renderer/MainContent.tsx b/src/renderer/MainContent.tsx index e0701801a..2a6d5a2b5 100644 --- a/src/renderer/MainContent.tsx +++ b/src/renderer/MainContent.tsx @@ -62,14 +62,14 @@ const MainContent = () => { Filter Type Frequency (Hz) - +30dB + +20dB 0dB - -30dB + -20dB Gain (dB) - Quality + Q Factor
diff --git a/src/renderer/SideBar.tsx b/src/renderer/SideBar.tsx index 8c87287fc..92b6f6f40 100644 --- a/src/renderer/SideBar.tsx +++ b/src/renderer/SideBar.tsx @@ -28,8 +28,8 @@ import GraphViewSwitch from './components/GraphViewSwitch'; import Spinner from './icons/Spinner'; const SideBar = () => { - const MIN = -30; - const MAX = 30; + const MIN = -20; + const MAX = 20; const { isGraphViewOn, @@ -74,7 +74,7 @@ const SideBar = () => {

Pre-Amp Gain

-
+30 dB
+
+20 dB
{ value={preAmp} sliderHeight={sliderHeight} setValue={setGain} - label="-30 dB" + label="-20 dB" />
diff --git a/src/renderer/components/FrequencyBand.tsx b/src/renderer/components/FrequencyBand.tsx index b641ee1cd..3be91929b 100644 --- a/src/renderer/components/FrequencyBand.tsx +++ b/src/renderer/components/FrequencyBand.tsx @@ -22,10 +22,10 @@ import { IFilter, MAX_FREQUENCY, MAX_GAIN, - MAX_QUALITY, + MAX_QFACTOR, MIN_FREQUENCY, MIN_GAIN, - MIN_QUALITY, + MIN_QFACTOR, } from 'common/constants'; import IconButton, { IconName } from 'renderer/widgets/IconButton'; import { @@ -73,14 +73,14 @@ const FrequencyBand = forwardRef( [isLoading, isMinSliderCount] ); // Local copy of quality/freq value used so that the number input increases smoothly while throttling EQ APO writes - const [qualityValue, setQualityValue] = useState(filter.quality); + const [qualityValue, setQualityValue] = useState(filter.qfactor); const [frequencyValue, setFrequencyValue] = useState( filter.frequency ); useEffect(() => { - setQualityValue(filter.quality); - }, [filter.quality]); + setQualityValue(filter.qfactor); + }, [filter.qfactor]); useEffect(() => { setFrequencyValue(filter.frequency); @@ -119,7 +119,7 @@ const FrequencyBand = forwardRef( const normalSetQuality = useCallback( async (newValue: number) => { dispatchFilter({ - type: FilterActionEnum.QUALITY, + type: FilterActionEnum.QFACTOR, id: filter.id, newValue, }); @@ -262,8 +262,8 @@ const FrequencyBand = forwardRef(
=> { /** * Get the current main preamplification gain value * @deprecated - Removing with the context refactor - * @returns { Promise } gain - current system gain value in the range [-30, 30] + * @returns { Promise } gain - current system gain value in the range [-20, 20] */ export const getMainPreAmp = (): Promise => { const channel = ChannelEnum.GET_PREAMP; @@ -307,7 +307,7 @@ export const getMainPreAmp = (): Promise => { /** * Adjusts the main preamplification gain value - * @param {number} gain - new gain value in [-30, 30] + * @param {number} gain - new gain value in [-20, 20] */ export const setMainPreAmp = (gain: number) => { const channel = ChannelEnum.SET_PREAMP; @@ -324,7 +324,7 @@ export const setMainPreAmp = (gain: number) => { * Get the a slider's gain value * @deprecated - Removing with the context refactor * @param {string} filterId - id of the slider being adjusted - * @returns { Promise } gain - current system gain value in the range [-30, 30] + * @returns { Promise } gain - current system gain value in the range [-20, 20] */ export const getGain = (filterId: string): Promise => { const channel = ChannelEnum.GET_FILTER_GAIN; @@ -335,7 +335,7 @@ export const getGain = (filterId: string): Promise => { /** * Adjusts a slider's gain value * @param {string} filterId - id of the slider being adjusted - * @param {number} gain - new gain value in [-30, 30] + * @param {number} gain - new gain value in [-20, 20] */ export const setGain = (filterId: string, gain: number) => { const channel = ChannelEnum.SET_FILTER_GAIN; diff --git a/src/renderer/utils/utils.ts b/src/renderer/utils/utils.ts index 6358544da..5b7f23154 100644 --- a/src/renderer/utils/utils.ts +++ b/src/renderer/utils/utils.ts @@ -31,7 +31,7 @@ export const clamp = (num: number, min: number, max: number) => { export const sortHelper = (a: IFilter, b: IFilter) => a.frequency - b.frequency || a.gain - b.gain || - a.quality - b.quality || + a.qfactor - b.qfactor || a.type.localeCompare(b.type); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#sequence_generator_range