diff options
| author | Crystalwarrior <Varsash@Gmail.com> | 2022-07-23 18:18:45 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-23 18:18:45 +0300 |
| commit | ad578eb0bd15dfa828c8c43518991ee8ce81e261 (patch) | |
| tree | a610c3704109c40f26c044bb0100a0a0b7ca6dab /src/aoblipplayer.cpp | |
| parent | 1953b26233a46a5d644209c8faf35f435dd87145 (diff) | |
Suppress application volume when alt-tabbed (#730)
* Suppress application volume when alt-tabbed
Add a "suppress_audio" slider setting, 50% by default, which decides how much audio remains when the client is not in focus
Add a "muted" setting for blip, music, and sfx players
Add update_audio_volume func
* change "suppress" to "how much audio is suppressed" instead of "how much audio remains"
* Fix last commit just flipping the behavior and being ultra wacky
* Fix evidence present sound ignoring audio suppression settings
Co-authored-by: stonedDiscord <Tukz@gmx.de>
Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com>
Diffstat (limited to 'src/aoblipplayer.cpp')
| -rw-r--r-- | src/aoblipplayer.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 307a0bdd..5dc24678 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -37,6 +37,12 @@ void AOBlipPlayer::blip_tick() BASS_ChannelPlay(f_stream, false); } +void AOBlipPlayer::set_muted(bool toggle) +{ + m_muted = toggle; + set_volume_internal(m_volume); +} + void AOBlipPlayer::set_volume(int p_value) { m_volume = static_cast<qreal>(p_value) / 100; @@ -45,7 +51,8 @@ void AOBlipPlayer::set_volume(int p_value) void AOBlipPlayer::set_volume_internal(qreal p_value) { - float volume = static_cast<float>(p_value); + // If muted, volume will always be 0 + float volume = static_cast<float>(p_value) * !m_muted; for (int n_stream = 0; n_stream < 5; ++n_stream) { BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); |
