mirror of
https://github.com/Equicord/Equicord.git
synced 2025-03-30 20:21:59 -04:00
Fixes
This commit is contained in:
parent
53c4fd5bed
commit
b4587182c2
9 changed files with 3 additions and 687 deletions
|
@ -21,7 +21,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { types } from "../../philsPluginLibrary";
|
import { types } from "../../philsPluginLibrary";
|
||||||
|
|
||||||
export const PluginInfo = {
|
export const PluginInfo = {
|
||||||
PLUGIN_NAME: "BetterMicrophone",
|
PLUGIN_NAME: "PhilsBetterMicrophone",
|
||||||
DESCRIPTION: "This plugin allows you to further customize your microphone.",
|
DESCRIPTION: "This plugin allows you to further customize your microphone.",
|
||||||
AUTHOR: {
|
AUTHOR: {
|
||||||
...Devs.philhk,
|
...Devs.philhk,
|
||||||
|
|
|
@ -1,331 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2023 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Flex } from "@components/Flex";
|
|
||||||
import { Switch } from "@components/Switch";
|
|
||||||
import { ModalSize } from "@utils/modal";
|
|
||||||
import { Card, Forms, Select, Slider, TextInput, useEffect, useState } from "@webpack/common";
|
|
||||||
import { SelectOption } from "@webpack/types";
|
|
||||||
|
|
||||||
import { MicrophoneProfile, MicrophoneStore } from "../../betterMicrophone/stores";
|
|
||||||
import {
|
|
||||||
ProfilableStore,
|
|
||||||
SettingsModal,
|
|
||||||
SettingsModalCard,
|
|
||||||
SettingsModalCardItem,
|
|
||||||
SettingsModalCardRow,
|
|
||||||
SettingsModalProfilesCard,
|
|
||||||
validateNumberInput,
|
|
||||||
validateTextInputNumber
|
|
||||||
} from "../../philsPluginLibrary";
|
|
||||||
import { Styles } from "../../philsPluginLibrary/styles";
|
|
||||||
|
|
||||||
const simpleVoiceBitrates: readonly SelectOption[] = [
|
|
||||||
{
|
|
||||||
label: "Normal",
|
|
||||||
value: 96
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Medium-High",
|
|
||||||
value: 160
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "High",
|
|
||||||
value: 320
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Very-High",
|
|
||||||
value: 512
|
|
||||||
}
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export interface MicrophoneSettingsModalProps extends React.ComponentProps<typeof SettingsModal> {
|
|
||||||
microphoneStore: ProfilableStore<MicrophoneStore, MicrophoneProfile>;
|
|
||||||
showInfo?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MicrophoneSettingsModal = (props: MicrophoneSettingsModalProps) => {
|
|
||||||
const { microphoneStore, showInfo } = props;
|
|
||||||
|
|
||||||
const {
|
|
||||||
currentProfile,
|
|
||||||
simpleMode,
|
|
||||||
setSimpleMode,
|
|
||||||
deleteProfile,
|
|
||||||
duplicateProfile,
|
|
||||||
getCurrentProfile,
|
|
||||||
getDefaultProfiles,
|
|
||||||
getProfile,
|
|
||||||
getProfiles,
|
|
||||||
isCurrentProfileADefaultProfile,
|
|
||||||
profiles,
|
|
||||||
saveProfile,
|
|
||||||
setChannels,
|
|
||||||
setChannelsEnabled,
|
|
||||||
setCurrentProfile,
|
|
||||||
setFreq,
|
|
||||||
setFreqEnabled,
|
|
||||||
setPacsize,
|
|
||||||
setPacsizeEnabled,
|
|
||||||
setRate,
|
|
||||||
setRateEnabled,
|
|
||||||
setVoiceBitrate,
|
|
||||||
setVoiceBitrateEnabled
|
|
||||||
} = microphoneStore.use();
|
|
||||||
|
|
||||||
const {
|
|
||||||
name,
|
|
||||||
channels,
|
|
||||||
channelsEnabled,
|
|
||||||
freq,
|
|
||||||
freqEnabled,
|
|
||||||
pacsize,
|
|
||||||
pacsizeEnabled,
|
|
||||||
rate,
|
|
||||||
rateEnabled,
|
|
||||||
voiceBitrate,
|
|
||||||
voiceBitrateEnabled
|
|
||||||
} = currentProfile;
|
|
||||||
|
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
|
||||||
|
|
||||||
const [rateInput, setRateInput] = useState<string>(rate ? rate.toString() : "");
|
|
||||||
const [freqInput, setFreqInput] = useState<string>(freq ? freq.toString() : "");
|
|
||||||
const [pacsizeInput, setPacsizeInput] = useState<string>(pacsize ? pacsize.toString() : "");
|
|
||||||
const [channelsInput, setChannelsInput] = useState<string>(channels ? channels.toString() : "");
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setRateInput(rate ? rate.toString() : "");
|
|
||||||
setFreqInput(freq ? freq.toString() : "");
|
|
||||||
setPacsizeInput(pacsize ? pacsize.toString() : "");
|
|
||||||
setChannelsInput(channels ? channels.toString() : "");
|
|
||||||
}, [rate, freq, pacsize, channels]);
|
|
||||||
|
|
||||||
const simpleToggle =
|
|
||||||
<Flex style={{ justifyContent: "center", alignItems: "center", gap: "0.6em" }}>
|
|
||||||
<Forms.FormTitle style={{ margin: 0 }} tag="h5">Simple</Forms.FormTitle>
|
|
||||||
<Switch checked={simpleMode ?? false} disabled={isSaving} onChange={checked => setSimpleMode(checked)} />
|
|
||||||
</Flex>;
|
|
||||||
|
|
||||||
const settingsCardVoiceBitrateSimple =
|
|
||||||
<SettingsModalCard
|
|
||||||
title="Audio Bitrate"
|
|
||||||
switchEnabled
|
|
||||||
flex={0.8}
|
|
||||||
switchProps={{
|
|
||||||
checked: voiceBitrateEnabled ?? false,
|
|
||||||
disabled: isSaving,
|
|
||||||
onChange: status => setVoiceBitrateEnabled(status)
|
|
||||||
}}>
|
|
||||||
<SettingsModalCardItem>
|
|
||||||
<Select
|
|
||||||
isDisabled={!voiceBitrateEnabled || isSaving}
|
|
||||||
options={simpleVoiceBitrates}
|
|
||||||
select={(value: number) => setVoiceBitrate(value)}
|
|
||||||
isSelected={(value: number) => value === voiceBitrate}
|
|
||||||
serialize={() => ""} />
|
|
||||||
</SettingsModalCardItem>
|
|
||||||
</SettingsModalCard>;
|
|
||||||
|
|
||||||
const settingsCardChannelsSimple =
|
|
||||||
<SettingsModalCard
|
|
||||||
title="Stereo"
|
|
||||||
flex={0.2}
|
|
||||||
switchEnabled
|
|
||||||
switchProps={{
|
|
||||||
checked: (channelsEnabled && channels === 2) ?? false,
|
|
||||||
disabled: isSaving,
|
|
||||||
onChange: status => void setChannelsEnabled(status) ?? setChannels(2)
|
|
||||||
}}>
|
|
||||||
</SettingsModalCard>;
|
|
||||||
|
|
||||||
const settingsCardVoiceBitrate =
|
|
||||||
<SettingsModalCard
|
|
||||||
title="Audio Bitrate"
|
|
||||||
switchEnabled
|
|
||||||
flex={0.4}
|
|
||||||
switchProps={{
|
|
||||||
checked: voiceBitrateEnabled ?? false,
|
|
||||||
disabled: isSaving,
|
|
||||||
onChange: status => setVoiceBitrateEnabled(status)
|
|
||||||
}}>
|
|
||||||
<SettingsModalCardItem title="Kb/s">
|
|
||||||
<div style={{ paddingTop: "0.3em", paddingRight: "0.4em", paddingLeft: "0.4em", boxSizing: "border-box" }}>
|
|
||||||
<Slider
|
|
||||||
disabled={!voiceBitrateEnabled || isSaving}
|
|
||||||
onValueChange={value => setVoiceBitrate(value)}
|
|
||||||
initialValue={voiceBitrate || 8}
|
|
||||||
minValue={8}
|
|
||||||
maxValue={512}
|
|
||||||
markers={[8, 96, 320, 512]}
|
|
||||||
onValueRender={value => `${value.toFixed(0)}kb/s`} />
|
|
||||||
</div>
|
|
||||||
</SettingsModalCardItem>
|
|
||||||
</SettingsModalCard>;
|
|
||||||
|
|
||||||
const settingsCardRate =
|
|
||||||
<SettingsModalCard
|
|
||||||
title="Sample Rate"
|
|
||||||
switchEnabled
|
|
||||||
switchProps={{
|
|
||||||
checked: rateEnabled ?? false,
|
|
||||||
disabled: isSaving,
|
|
||||||
onChange: status => setRateEnabled(status)
|
|
||||||
}}>
|
|
||||||
<SettingsModalCardItem>
|
|
||||||
<TextInput
|
|
||||||
disabled={!rateEnabled || isSaving}
|
|
||||||
value={rateInput}
|
|
||||||
onChange={value => validateTextInputNumber(value) && setRateInput(value)}
|
|
||||||
onBlur={e => {
|
|
||||||
const result = validateNumberInput(e.target.value);
|
|
||||||
setRate(result);
|
|
||||||
setRateInput(result ? result.toString() : "");
|
|
||||||
}} />
|
|
||||||
</SettingsModalCardItem>
|
|
||||||
</SettingsModalCard>;
|
|
||||||
|
|
||||||
const settingsCardFreq =
|
|
||||||
<SettingsModalCard
|
|
||||||
title="Sample Frequency"
|
|
||||||
switchEnabled
|
|
||||||
switchProps={{
|
|
||||||
checked: freqEnabled ?? false,
|
|
||||||
disabled: isSaving,
|
|
||||||
onChange: status => setFreqEnabled(status)
|
|
||||||
}}>
|
|
||||||
<SettingsModalCardItem>
|
|
||||||
<TextInput
|
|
||||||
disabled={!freqEnabled || isSaving}
|
|
||||||
value={freqInput}
|
|
||||||
onChange={value => validateTextInputNumber(value) && setFreqInput(value)}
|
|
||||||
onBlur={e => {
|
|
||||||
const result = validateNumberInput(e.target.value);
|
|
||||||
setFreq(result);
|
|
||||||
setFreqInput(result ? result.toString() : "");
|
|
||||||
}} />
|
|
||||||
</SettingsModalCardItem>
|
|
||||||
</SettingsModalCard>;
|
|
||||||
|
|
||||||
const settingsCardPacsize =
|
|
||||||
<SettingsModalCard
|
|
||||||
title="Pac Size"
|
|
||||||
switchEnabled
|
|
||||||
switchProps={{
|
|
||||||
checked: pacsizeEnabled ?? false,
|
|
||||||
disabled: isSaving,
|
|
||||||
onChange: status => setPacsizeEnabled(status)
|
|
||||||
}}>
|
|
||||||
<SettingsModalCardItem>
|
|
||||||
<TextInput
|
|
||||||
disabled={!pacsizeEnabled || isSaving}
|
|
||||||
value={pacsizeInput}
|
|
||||||
onChange={value => validateTextInputNumber(value) && setPacsizeInput(value)}
|
|
||||||
onBlur={e => {
|
|
||||||
const result = validateNumberInput(e.target.value);
|
|
||||||
setPacsize(result);
|
|
||||||
setPacsizeInput(result ? result.toString() : "");
|
|
||||||
}} />
|
|
||||||
</SettingsModalCardItem>
|
|
||||||
</SettingsModalCard>;
|
|
||||||
|
|
||||||
const settingsCardChannels =
|
|
||||||
<SettingsModalCard
|
|
||||||
title="Channels"
|
|
||||||
switchEnabled
|
|
||||||
switchProps={{
|
|
||||||
checked: channelsEnabled ?? false,
|
|
||||||
disabled: isSaving,
|
|
||||||
onChange: status => setChannelsEnabled(status)
|
|
||||||
}}>
|
|
||||||
<SettingsModalCardItem>
|
|
||||||
<TextInput
|
|
||||||
disabled={!channelsEnabled || isSaving}
|
|
||||||
value={channelsInput}
|
|
||||||
onChange={value => validateTextInputNumber(value) && setChannelsInput(value)}
|
|
||||||
onBlur={e => {
|
|
||||||
const result = validateNumberInput(e.target.value);
|
|
||||||
setChannels(result);
|
|
||||||
setChannelsInput(result ? result.toString() : "");
|
|
||||||
}} />
|
|
||||||
</SettingsModalCardItem>
|
|
||||||
</SettingsModalCard>;
|
|
||||||
|
|
||||||
const settingsCardProfiles =
|
|
||||||
<SettingsModalProfilesCard
|
|
||||||
flex={0.6}
|
|
||||||
onSaveStateChanged={state => setIsSaving(state)}
|
|
||||||
profileableStore={microphoneStore} />;
|
|
||||||
|
|
||||||
const infoCard =
|
|
||||||
<Card style={{ ...Styles.infoCard }}>
|
|
||||||
<Forms.FormTitle tag="h5">Important</Forms.FormTitle>
|
|
||||||
<Forms.FormText>
|
|
||||||
To take full advantage of this plugin, please disable <span style={{ fontWeight: "bold" }}>Krisp</span> and <span style={{ fontWeight: "bold" }}>Echo Cancellation</span>, otherwise features like Stereo (Channels) will not work.
|
|
||||||
</Forms.FormText>
|
|
||||||
</Card>;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SettingsModal
|
|
||||||
size={simpleMode ? ModalSize.DYNAMIC : ModalSize.DYNAMIC}
|
|
||||||
title="Microphone Settings"
|
|
||||||
closeButtonName="Apply"
|
|
||||||
footerContent={
|
|
||||||
<Flex style={{ justifyContent: "center", alignItems: "center", marginLeft: "auto" }}>
|
|
||||||
{simpleToggle}
|
|
||||||
</Flex>
|
|
||||||
}
|
|
||||||
{...props}
|
|
||||||
onDone={() => {
|
|
||||||
props.onClose();
|
|
||||||
props.onDone && props.onDone();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{simpleMode
|
|
||||||
? <div style={{ width: "30em", display: "flex", flexDirection: "column", gap: "1em" }}>
|
|
||||||
<SettingsModalCardRow>
|
|
||||||
{settingsCardVoiceBitrateSimple}
|
|
||||||
{settingsCardChannelsSimple}
|
|
||||||
</SettingsModalCardRow>
|
|
||||||
{showInfo &&
|
|
||||||
<SettingsModalCardRow>
|
|
||||||
{infoCard}
|
|
||||||
</SettingsModalCardRow>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
: <div style={{ display: "flex", flexDirection: "column", width: "50em", gap: "1em", maxHeight: "30em" }}>
|
|
||||||
<SettingsModalCardRow>
|
|
||||||
{settingsCardFreq}
|
|
||||||
{settingsCardRate}
|
|
||||||
{settingsCardPacsize}
|
|
||||||
{settingsCardChannels}
|
|
||||||
</SettingsModalCardRow>
|
|
||||||
<SettingsModalCardRow>
|
|
||||||
{settingsCardVoiceBitrate}
|
|
||||||
{settingsCardProfiles}
|
|
||||||
</SettingsModalCardRow>
|
|
||||||
{showInfo &&
|
|
||||||
<SettingsModalCardRow>
|
|
||||||
{infoCard}
|
|
||||||
</SettingsModalCardRow>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</SettingsModal>
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -21,7 +21,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { types } from "../../philsPluginLibrary";
|
import { types } from "../../philsPluginLibrary";
|
||||||
|
|
||||||
export const PluginInfo = {
|
export const PluginInfo = {
|
||||||
PLUGIN_NAME: "BetterScreenshare",
|
PLUGIN_NAME: "PhilsBetterScreenshare",
|
||||||
DESCRIPTION: "This plugin allows you to further customize your screen sharing.",
|
DESCRIPTION: "This plugin allows you to further customize your screen sharing.",
|
||||||
AUTHOR: {
|
AUTHOR: {
|
||||||
...Devs.philhk,
|
...Devs.philhk,
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2023 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { createPluginStore, ProfilableInitializer, ProfilableStore, profileable, ProfileableProfile } from "../../philsPluginLibrary";
|
|
||||||
import { PluginInfo } from "../constants";
|
|
||||||
|
|
||||||
|
|
||||||
export interface MicrophoneProfile {
|
|
||||||
freq?: number,
|
|
||||||
pacsize?: number,
|
|
||||||
channels?: number,
|
|
||||||
rate?: number,
|
|
||||||
voiceBitrate?: number;
|
|
||||||
freqEnabled?: boolean,
|
|
||||||
pacsizeEnabled?: boolean;
|
|
||||||
channelsEnabled?: boolean;
|
|
||||||
rateEnabled?: boolean;
|
|
||||||
voiceBitrateEnabled?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MicrophoneStore {
|
|
||||||
simpleMode?: boolean;
|
|
||||||
setSimpleMode: (enabled?: boolean) => void;
|
|
||||||
setFreq: (freq?: number) => void;
|
|
||||||
setPacsize: (pacsize?: number) => void;
|
|
||||||
setChannels: (channels?: number) => void;
|
|
||||||
setRate: (rate?: number) => void;
|
|
||||||
setVoiceBitrate: (voiceBitrate?: number) => void;
|
|
||||||
setFreqEnabled: (enabled?: boolean) => void;
|
|
||||||
setPacsizeEnabled: (enabled?: boolean) => void;
|
|
||||||
setChannelsEnabled: (enabled?: boolean) => void;
|
|
||||||
setRateEnabled: (enabled?: boolean) => void;
|
|
||||||
setVoiceBitrateEnabled: (enabled?: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultMicrophoneProfiles = {
|
|
||||||
normal: {
|
|
||||||
name: "Normal",
|
|
||||||
channels: 2,
|
|
||||||
channelsEnabled: true,
|
|
||||||
voiceBitrate: 96,
|
|
||||||
voiceBitrateEnabled: true
|
|
||||||
},
|
|
||||||
high: {
|
|
||||||
name: "High",
|
|
||||||
channels: 2,
|
|
||||||
channelsEnabled: true,
|
|
||||||
voiceBitrate: 320,
|
|
||||||
voiceBitrateEnabled: true
|
|
||||||
},
|
|
||||||
} as const satisfies Record<string, MicrophoneProfile & ProfileableProfile>;
|
|
||||||
|
|
||||||
export const microphoneStoreDefault: ProfilableInitializer<MicrophoneStore, MicrophoneProfile> = (set, get) => ({
|
|
||||||
simpleMode: true,
|
|
||||||
setSimpleMode: enabled => get().simpleMode = enabled,
|
|
||||||
setChannels: channels => get().currentProfile.channels = channels,
|
|
||||||
setRate: rate => get().currentProfile.rate = rate,
|
|
||||||
setVoiceBitrate: voiceBitrate => get().currentProfile.voiceBitrate = voiceBitrate,
|
|
||||||
setPacsize: pacsize => get().currentProfile.pacsize = pacsize,
|
|
||||||
setFreq: freq => get().currentProfile.freq = freq,
|
|
||||||
setChannelsEnabled: enabled => get().currentProfile.channelsEnabled = enabled,
|
|
||||||
setFreqEnabled: enabled => get().currentProfile.freqEnabled = enabled,
|
|
||||||
setPacsizeEnabled: enabled => get().currentProfile.pacsizeEnabled = enabled,
|
|
||||||
setRateEnabled: enabled => get().currentProfile.rateEnabled = enabled,
|
|
||||||
setVoiceBitrateEnabled: enabled => get().currentProfile.voiceBitrateEnabled = enabled,
|
|
||||||
});
|
|
||||||
|
|
||||||
export let microphoneStore: ProfilableStore<MicrophoneStore, MicrophoneProfile>;
|
|
||||||
|
|
||||||
export const initMicrophoneStore = () =>
|
|
||||||
microphoneStore = createPluginStore(
|
|
||||||
PluginInfo.PLUGIN_NAME,
|
|
||||||
"MicrophoneStore",
|
|
||||||
profileable(
|
|
||||||
microphoneStoreDefault,
|
|
||||||
{ name: "" },
|
|
||||||
Object.values(defaultMicrophoneProfiles)
|
|
||||||
)
|
|
||||||
);
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { lodash } from "@webpack/common";
|
import { lodash } from "@webpack/common";
|
||||||
|
|
||||||
import { MicrophoneProfile, MicrophoneStore } from "../../betterMicrophone.desktop/stores";
|
import { MicrophoneProfile, MicrophoneStore } from "../../betterMicrophone/stores";
|
||||||
import { ProfilableStore, replaceObjectValuesIfExist, types } from "..";
|
import { ProfilableStore, replaceObjectValuesIfExist, types } from "..";
|
||||||
|
|
||||||
export function getDefaultAudioTransportationOptions(connection: types.Connection) {
|
export function getDefaultAudioTransportationOptions(connection: types.Connection) {
|
||||||
|
|
|
@ -17,6 +17,4 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from "./profileable";
|
export * from "./profileable";
|
||||||
export * from "./screenshareAudioStore";
|
|
||||||
export * from "./screenshareStore";
|
|
||||||
export * from "./store";
|
export * from "./store";
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2023 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { createPluginStore, ProfilableInitializer, ProfilableStore, profileable, ProfileableProfile } from "..";
|
|
||||||
import { PluginInfo } from "../constants";
|
|
||||||
|
|
||||||
|
|
||||||
export interface MicrophoneProfile {
|
|
||||||
freq?: number,
|
|
||||||
pacsize?: number,
|
|
||||||
channels?: number,
|
|
||||||
rate?: number,
|
|
||||||
voiceBitrate?: number;
|
|
||||||
freqEnabled?: boolean,
|
|
||||||
pacsizeEnabled?: boolean;
|
|
||||||
channelsEnabled?: boolean;
|
|
||||||
rateEnabled?: boolean;
|
|
||||||
voiceBitrateEnabled?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MicrophoneStore {
|
|
||||||
simpleMode?: boolean;
|
|
||||||
setSimpleMode: (enabled?: boolean) => void;
|
|
||||||
setFreq: (freq?: number) => void;
|
|
||||||
setPacsize: (pacsize?: number) => void;
|
|
||||||
setChannels: (channels?: number) => void;
|
|
||||||
setRate: (rate?: number) => void;
|
|
||||||
setVoiceBitrate: (voiceBitrate?: number) => void;
|
|
||||||
setFreqEnabled: (enabled?: boolean) => void;
|
|
||||||
setPacsizeEnabled: (enabled?: boolean) => void;
|
|
||||||
setChannelsEnabled: (enabled?: boolean) => void;
|
|
||||||
setRateEnabled: (enabled?: boolean) => void;
|
|
||||||
setVoiceBitrateEnabled: (enabled?: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultMicrophoneProfiles = {
|
|
||||||
normal: {
|
|
||||||
name: "Normal",
|
|
||||||
channels: 2,
|
|
||||||
channelsEnabled: true,
|
|
||||||
voiceBitrate: 96,
|
|
||||||
voiceBitrateEnabled: true
|
|
||||||
},
|
|
||||||
high: {
|
|
||||||
name: "High",
|
|
||||||
channels: 2,
|
|
||||||
channelsEnabled: true,
|
|
||||||
voiceBitrate: 320,
|
|
||||||
voiceBitrateEnabled: true
|
|
||||||
},
|
|
||||||
} as const satisfies Record<string, MicrophoneProfile & ProfileableProfile>;
|
|
||||||
|
|
||||||
export const microphoneStoreDefault: ProfilableInitializer<MicrophoneStore, MicrophoneProfile> = (set, get) => ({
|
|
||||||
simpleMode: true,
|
|
||||||
setSimpleMode: enabled => get().simpleMode = enabled,
|
|
||||||
setChannels: channels => get().currentProfile.channels = channels,
|
|
||||||
setRate: rate => get().currentProfile.rate = rate,
|
|
||||||
setVoiceBitrate: voiceBitrate => get().currentProfile.voiceBitrate = voiceBitrate,
|
|
||||||
setPacsize: pacsize => get().currentProfile.pacsize = pacsize,
|
|
||||||
setFreq: freq => get().currentProfile.freq = freq,
|
|
||||||
setChannelsEnabled: enabled => get().currentProfile.channelsEnabled = enabled,
|
|
||||||
setFreqEnabled: enabled => get().currentProfile.freqEnabled = enabled,
|
|
||||||
setPacsizeEnabled: enabled => get().currentProfile.pacsizeEnabled = enabled,
|
|
||||||
setRateEnabled: enabled => get().currentProfile.rateEnabled = enabled,
|
|
||||||
setVoiceBitrateEnabled: enabled => get().currentProfile.voiceBitrateEnabled = enabled,
|
|
||||||
});
|
|
||||||
|
|
||||||
export let microphoneStore: ProfilableStore<MicrophoneStore, MicrophoneProfile>;
|
|
||||||
|
|
||||||
export const initMicrophoneStore = () =>
|
|
||||||
microphoneStore = createPluginStore(
|
|
||||||
PluginInfo.PLUGIN_NAME,
|
|
||||||
"MicrophoneStore",
|
|
||||||
profileable(
|
|
||||||
microphoneStoreDefault,
|
|
||||||
{ name: "" },
|
|
||||||
Object.values(defaultMicrophoneProfiles)
|
|
||||||
)
|
|
||||||
);
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2023 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { createPluginStore, ProfilableStore, profileable } from "..";
|
|
||||||
import { PluginInfo } from "../constants";
|
|
||||||
import {
|
|
||||||
defaultMicrophoneProfiles as defaultScreenshareAudioProfiles,
|
|
||||||
MicrophoneProfile as ScreenshareAudioProfile,
|
|
||||||
MicrophoneStore as ScreenshareAudioStore,
|
|
||||||
microphoneStoreDefault as screenshareAudioStoreDefault
|
|
||||||
} from ".";
|
|
||||||
|
|
||||||
export let screenshareAudioStore: ProfilableStore<ScreenshareAudioStore, ScreenshareAudioProfile>;
|
|
||||||
|
|
||||||
export const initScreenshareAudioStore = () =>
|
|
||||||
screenshareAudioStore = createPluginStore(
|
|
||||||
PluginInfo.PLUGIN_NAME,
|
|
||||||
"ScreenshareAudioStore",
|
|
||||||
profileable(
|
|
||||||
screenshareAudioStoreDefault,
|
|
||||||
{ name: "" },
|
|
||||||
Object.values(defaultScreenshareAudioProfiles)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
export { defaultScreenshareAudioProfiles, ScreenshareAudioProfile, ScreenshareAudioStore, screenshareAudioStoreDefault };
|
|
|
@ -1,122 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2023 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { createPluginStore, ProfilableInitializer, ProfilableStore, profileable, ProfileableProfile } from "..";
|
|
||||||
import { PluginInfo } from "../constants";
|
|
||||||
|
|
||||||
|
|
||||||
export interface ScreenshareProfile {
|
|
||||||
width?: number,
|
|
||||||
height?: number,
|
|
||||||
framerate?: number,
|
|
||||||
videoCodec?: string,
|
|
||||||
keyframeInterval?: number,
|
|
||||||
videoBitrate?: number;
|
|
||||||
videoBitrateEnabled?: boolean;
|
|
||||||
resolutionEnabled?: boolean,
|
|
||||||
framerateEnabled?: boolean,
|
|
||||||
videoCodecEnabled?: boolean;
|
|
||||||
keyframeIntervalEnabled?: boolean;
|
|
||||||
hdrEnabled?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ScreenshareStore {
|
|
||||||
audioSource?: string;
|
|
||||||
audioSourceEnabled?: boolean;
|
|
||||||
simpleMode?: boolean;
|
|
||||||
setWidth: (width?: number) => void;
|
|
||||||
setHeight: (height?: number) => void;
|
|
||||||
setFramerate: (framerate?: number) => void;
|
|
||||||
setVideoCodec: (codec?: string) => void;
|
|
||||||
setKeyframeInterval: (keyframeInterval?: number) => void;
|
|
||||||
setVideoBitrate: (bitrate?: number) => void;
|
|
||||||
setKeyframeIntervalEnabled: (enabled?: boolean) => void;
|
|
||||||
setResolutionEnabled: (enabled?: boolean) => void;
|
|
||||||
setFramerateEnabled: (enabled?: boolean) => void;
|
|
||||||
setVideoCodecEnabled: (enabled?: boolean) => void;
|
|
||||||
setVideoBitrateEnabled: (enabled?: boolean) => void;
|
|
||||||
setHdrEnabled: (enabled?: boolean) => void;
|
|
||||||
setAudioSource: (audioSource?: string) => void;
|
|
||||||
setAudioSourceEnabled: (enabled?: boolean) => void;
|
|
||||||
setSimpleMode: (enabled?: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultScreenshareProfiles = {
|
|
||||||
low: {
|
|
||||||
name: "Low Quality",
|
|
||||||
width: 1280,
|
|
||||||
height: 720,
|
|
||||||
framerate: 60,
|
|
||||||
videoBitrate: 2500,
|
|
||||||
resolutionEnabled: true,
|
|
||||||
framerateEnabled: true,
|
|
||||||
videoBitrateEnabled: true,
|
|
||||||
},
|
|
||||||
medium: {
|
|
||||||
name: "Medium Quality",
|
|
||||||
width: 1920,
|
|
||||||
height: 1080,
|
|
||||||
framerate: 60,
|
|
||||||
videoBitrate: 5000,
|
|
||||||
resolutionEnabled: true,
|
|
||||||
framerateEnabled: true,
|
|
||||||
videoBitrateEnabled: true,
|
|
||||||
},
|
|
||||||
high: {
|
|
||||||
name: "High Quality",
|
|
||||||
width: 1920,
|
|
||||||
height: 1080,
|
|
||||||
framerate: 60,
|
|
||||||
videoBitrate: 10000,
|
|
||||||
resolutionEnabled: true,
|
|
||||||
framerateEnabled: true,
|
|
||||||
videoBitrateEnabled: true,
|
|
||||||
}
|
|
||||||
} as const satisfies Record<string, ScreenshareProfile & ProfileableProfile>;
|
|
||||||
|
|
||||||
export const screenshareStoreDefault: ProfilableInitializer<ScreenshareStore, ScreenshareProfile> = (set, get) => ({
|
|
||||||
setVideoBitrate: bitrate => get().currentProfile.videoBitrate = bitrate,
|
|
||||||
setVideoBitrateEnabled: enabled => get().currentProfile.videoBitrateEnabled = enabled,
|
|
||||||
setVideoCodec: codec => get().currentProfile.videoCodec = codec,
|
|
||||||
setVideoCodecEnabled: enabled => get().currentProfile.videoCodecEnabled = enabled,
|
|
||||||
setFramerate: framerate => get().currentProfile.framerate = framerate,
|
|
||||||
setFramerateEnabled: enabled => get().currentProfile.framerateEnabled = enabled,
|
|
||||||
setHeight: height => get().currentProfile.height = height,
|
|
||||||
setWidth: width => get().currentProfile.width = width,
|
|
||||||
setResolutionEnabled: enabled => get().currentProfile.resolutionEnabled = enabled,
|
|
||||||
setKeyframeInterval: keyframeInterval => get().currentProfile.keyframeInterval = keyframeInterval,
|
|
||||||
setKeyframeIntervalEnabled: enabled => get().currentProfile.keyframeIntervalEnabled = enabled,
|
|
||||||
setHdrEnabled: enabled => get().currentProfile.hdrEnabled = enabled,
|
|
||||||
setAudioSource: audioSource => get().audioSource = audioSource,
|
|
||||||
setAudioSourceEnabled: enabled => get().audioSourceEnabled = enabled,
|
|
||||||
setSimpleMode: enabled => get().simpleMode = enabled,
|
|
||||||
simpleMode: true
|
|
||||||
});
|
|
||||||
|
|
||||||
export let screenshareStore: ProfilableStore<ScreenshareStore, ScreenshareProfile>;
|
|
||||||
|
|
||||||
export const initScreenshareStore = () =>
|
|
||||||
screenshareStore = createPluginStore(
|
|
||||||
PluginInfo.PLUGIN_NAME,
|
|
||||||
"ScreenshareStore",
|
|
||||||
profileable(
|
|
||||||
screenshareStoreDefault,
|
|
||||||
{ name: "" },
|
|
||||||
Object.values(defaultScreenshareProfiles)
|
|
||||||
)
|
|
||||||
);
|
|
Loading…
Add table
Reference in a new issue