Skip to content

Commit

Permalink
Fix volume issue when reducing volume during voice
Browse files Browse the repository at this point in the history
Fixes #1143

Add functionality to return to the previously set volume after reducing volume when someone speaks.

* Add a new variable `previousVolume` to store the previously set volume.
* Update the `setVolume` method to update the `previousVolume` variable whenever the volume is set.
* Update the `suppressVoiceWhenPeopleAreSpeaking` method to set the volume to `previousVolume` instead of `defaultVolume`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/museofficial/muse/issues/1143?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
Codixer committed Nov 24, 2024
1 parent 6ec6bb8 commit 3a7b0f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/services/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default class {
private audioResource: AudioResource | null = null;
private volume?: number;
private defaultVolume: number = DEFAULT_VOLUME;
private previousVolume: number = DEFAULT_VOLUME;
private nowPlaying: QueuedSong | null = null;
private playPositionInterval: NodeJS.Timeout | undefined;
private lastSongURL = '';
Expand Down Expand Up @@ -364,7 +365,7 @@ export default class {
if (speakingUsers && speakingUsers.size > 0) {
this.setVolume(turnDownVolumeWhenPeopleSpeakTarget);
} else {
this.setVolume(this.defaultVolume);
this.setVolume(this.previousVolume);
}
}

Expand Down Expand Up @@ -481,6 +482,7 @@ export default class {

setVolume(level: number): void {
// Level should be a number between 0 and 100 = 0% => 100%
this.previousVolume = this.volume ?? this.defaultVolume;
this.volume = level;
this.setAudioPlayerVolume(level);
}
Expand Down

0 comments on commit 3a7b0f6

Please sign in to comment.