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/aosfxplayer.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/aosfxplayer.cpp')
| -rw-r--r-- | src/aosfxplayer.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index fcdeb949..8d88667c 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -60,15 +60,23 @@ void AOSfxPlayer::stop(int channel) BASS_ChannelStop(m_stream_list[channel]); } +void AOSfxPlayer::set_muted(bool toggle) +{ + m_muted = toggle; + // Update the audio volume + set_volume_internal(m_volume); +} + void AOSfxPlayer::set_volume(qreal p_value) { - m_volume = p_value / 100; + m_volume = p_value * 0.01; set_volume_internal(m_volume); } void AOSfxPlayer::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 < m_channelmax; ++n_stream) { BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); } |
