Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAT-119 JAT-120 - change quality label to Q Factor and change gain range to [-20 , 20] #59

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

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;
Expand Down Expand Up @@ -78,7 +78,7 @@ export interface IFilter {
frequency: number;
gain: number;
type: FilterTypeEnum;
quality: number;
qfactor: number;
}

export interface IState {
Expand Down Expand Up @@ -109,7 +109,7 @@ const FIXED_FREQUENCIES = [
const DEFAULT_FILTER_TEMPLATE = {
frequency: 1000,
gain: 0,
quality: 1,
qfactor: 1,
type: FilterTypeEnum.PK,
};

Expand Down
12 changes: 6 additions & 6 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -532,27 +532,27 @@ ipcMain.on(ChannelEnum.GET_FILTER_QUALITY, async (event, arg) => {
}

const reply: TSuccess<number> = {
result: state.filters[filterId].quality || 10,
result: state.filters[filterId].qfactor || 10,
};
event.reply(channel + filterId, reply);
});

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);
});

Expand Down
6 changes: 3 additions & 3 deletions src/renderer/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ const MainContent = () => {
<span className="row-label">Filter Type</span>
<span className="row-label">Frequency (Hz)</span>
<span />
<span>+30dB</span>
<span>+20dB</span>
<span />
<span>0dB</span>
<span />
<span>-30dB</span>
<span>-20dB</span>
<span />
<span className="row-label">Gain (dB)</span>
<span className="row-label">Quality</span>
<span className="row-label">Q Factor</span>
<span />
</div>
<div className="bands row center">
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -74,15 +74,15 @@ const SideBar = () => {
</div>
<div>
<h4>Pre-Amp Gain</h4>
<div>+30 dB</div>
<div>+20 dB</div>
<Slider
name="Pre-Amplification Gain (dB)"
min={MIN}
max={MAX}
value={preAmp}
sliderHeight={sliderHeight}
setValue={setGain}
label="-30 dB"
label="-20 dB"
/>
</div>
<div className="col center">
Expand Down
16 changes: 8 additions & 8 deletions src/renderer/components/FrequencyBand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<number>(filter.quality);
const [qualityValue, setQualityValue] = useState<number>(filter.qfactor);
const [frequencyValue, setFrequencyValue] = useState<number>(
filter.frequency
);

useEffect(() => {
setQualityValue(filter.quality);
}, [filter.quality]);
setQualityValue(filter.qfactor);
}, [filter.qfactor]);

useEffect(() => {
setFrequencyValue(filter.frequency);
Expand Down Expand Up @@ -119,7 +119,7 @@ const FrequencyBand = forwardRef(
const normalSetQuality = useCallback(
async (newValue: number) => {
dispatchFilter({
type: FilterActionEnum.QUALITY,
type: FilterActionEnum.QFACTOR,
id: filter.id,
newValue,
});
Expand Down Expand Up @@ -262,8 +262,8 @@ const FrequencyBand = forwardRef(
</div>
<NumberInput
value={qualityValue}
min={MIN_QUALITY}
max={MAX_QUALITY}
min={MIN_QFACTOR}
max={MAX_QFACTOR}
name={`${frequencyValue}-quality`}
isDisabled={!!globalError}
floatPrecision={2}
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/utils/AquaContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export enum FilterActionEnum {
INIT,
FREQUENCY,
GAIN,
QUALITY,
QFACTOR,
TYPE,
ADD,
REMOVE,
Expand All @@ -49,7 +49,7 @@ export enum FilterActionEnum {
type NumericalFilterAction =
| FilterActionEnum.FREQUENCY
| FilterActionEnum.GAIN
| FilterActionEnum.QUALITY;
| FilterActionEnum.QFACTOR;

export type FilterAction =
| { type: FilterActionEnum.INIT; filters: IFiltersMap }
Expand Down Expand Up @@ -96,9 +96,9 @@ const filterReducer: IFilterReducer = (
filtersCloned[action.id].gain = action.newValue;
return filtersCloned;
}
case FilterActionEnum.QUALITY: {
case FilterActionEnum.QFACTOR: {
const filtersCloned = cloneFilters(filters);
filtersCloned[action.id].quality = action.newValue;
filtersCloned[action.id].qfactor = action.newValue;
return filtersCloned;
}
case FilterActionEnum.TYPE: {
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/utils/equalizerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export const disableGraphView = (): Promise<void> => {
/**
* Get the current main preamplification gain value
* @deprecated - Removing with the context refactor
* @returns { Promise<number> } gain - current system gain value in the range [-30, 30]
* @returns { Promise<number> } gain - current system gain value in the range [-20, 20]
*/
export const getMainPreAmp = (): Promise<number> => {
const channel = ChannelEnum.GET_PREAMP;
Expand All @@ -307,7 +307,7 @@ export const getMainPreAmp = (): Promise<number> => {

/**
* 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;
Expand All @@ -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<number> } gain - current system gain value in the range [-30, 30]
* @returns { Promise<number> } gain - current system gain value in the range [-20, 20]
*/
export const getGain = (filterId: string): Promise<number> => {
const channel = ChannelEnum.GET_FILTER_GAIN;
Expand All @@ -335,7 +335,7 @@ export const getGain = (filterId: string): Promise<number> => {
/**
* 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;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading