diff options
| author | 2019-01-26 14:53:58 +0100 | |
|---|---|---|
| committer | 2019-01-26 22:42:09 +0100 | |
| commit | 7185d90a5376fb1642abe9491aa412f9f6b49003 (patch) | |
| tree | fa8b8426d50594af177ce0c9d955b1415066b966 /src/audio_core/stream.cpp | |
| parent | Merge pull request #1927 from ReinUsesLisp/shader-ir (diff) | |
| download | yuzu-7185d90a5376fb1642abe9491aa412f9f6b49003.tar.gz yuzu-7185d90a5376fb1642abe9491aa412f9f6b49003.tar.xz yuzu-7185d90a5376fb1642abe9491aa412f9f6b49003.zip | |
dsp_interface: fix sound being played while volume is 0
According to documentation, if the argument of std::exp is zero, one is returned.
However we want the return value to be also zero in this case so no audio is played.
Diffstat (limited to 'src/audio_core/stream.cpp')
| -rw-r--r-- | src/audio_core/stream.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index 874673c4e..4ce2d374e 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp | |||
| @@ -68,7 +68,7 @@ static void VolumeAdjustSamples(std::vector<s16>& samples) { | |||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | // Implementation of a volume slider with a dynamic range of 60 dB | 70 | // Implementation of a volume slider with a dynamic range of 60 dB |
| 71 | const float volume_scale_factor{std::exp(6.90775f * volume) * 0.001f}; | 71 | const float volume_scale_factor = volume == 0 ? 0 : std::exp(6.90775f * volume) * 0.001f; |
| 72 | for (auto& sample : samples) { | 72 | for (auto& sample : samples) { |
| 73 | sample = static_cast<s16>(sample * volume_scale_factor); | 73 | sample = static_cast<s16>(sample * volume_scale_factor); |
| 74 | } | 74 | } |