Skip to content

Commit b169f94

Browse files
authored
feat: add automatic gain control to voice processing options (stoatchat#953)
1 parent 039e9ca commit b169f94

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

packages/client/components/app/interface/settings/user/voice/VoiceProcessingOptions.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ export function VoiceProcessingOptions() {
2626
>
2727
<Trans>Browser Echo Cancellation</Trans>
2828
</CategoryButton>
29+
<CategoryButton
30+
icon="blank"
31+
action={<Checkbox checked={state.voice.autoGainControl} />}
32+
onClick={() =>
33+
(state.voice.autoGainControl = !state.voice.autoGainControl)
34+
}
35+
>
36+
<Trans>Automatic Gain Control</Trans>
37+
</CategoryButton>
2938
</CategoryButton.Group>
3039
</Column>
3140
);

packages/client/components/rtc/state.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class Voice {
9292
deviceId: this.#settings.preferredAudioInputDevice,
9393
echoCancellation: this.#settings.echoCancellation,
9494
noiseSuppression: this.#settings.noiseSupression === "browser",
95+
autoGainControl: this.#settings.autoGainControl,
9596
},
9697
audioOutput: {
9798
deviceId: this.#settings.preferredAudioOutputDevice,

packages/client/components/state/stores/Voice.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface TypeVoice {
1919

2020
echoCancellation: boolean;
2121
noiseSupression: NoiseSuppresionState;
22+
autoGainControl: boolean;
2223

2324
inputVolume: number;
2425
outputVolume: number;
@@ -53,6 +54,7 @@ export class Voice extends AbstractStore<"voice", TypeVoice> {
5354
return {
5455
echoCancellation: true,
5556
noiseSupression: "browser",
57+
autoGainControl: true,
5658
inputVolume: 1.0,
5759
outputVolume: 1.0,
5860
userVolumes: {},
@@ -90,6 +92,10 @@ export class Voice extends AbstractStore<"voice", TypeVoice> {
9092
data.noiseSupression = input.noiseSupression;
9193
}
9294

95+
if (typeof input.autoGainControl === "boolean") {
96+
data.autoGainControl = input.autoGainControl;
97+
}
98+
9399
if (typeof input.inputVolume === "number") {
94100
data.inputVolume = input.inputVolume;
95101
}
@@ -182,6 +188,13 @@ export class Voice extends AbstractStore<"voice", TypeVoice> {
182188
this.set("noiseSupression", value);
183189
}
184190

191+
/**
192+
* Set auto gain control
193+
*/
194+
set autoGainControl(value: boolean) {
195+
this.set("autoGainControl", value);
196+
}
197+
185198
/**
186199
* Set input volume
187200
*/
@@ -224,6 +237,13 @@ export class Voice extends AbstractStore<"voice", TypeVoice> {
224237
return this.get().noiseSupression;
225238
}
226239

240+
/**
241+
* Get auto gain control
242+
*/
243+
get autoGainControl(): boolean | undefined {
244+
return this.get().autoGainControl;
245+
}
246+
227247
/**
228248
* Get input volume
229249
*/

0 commit comments

Comments
 (0)