summaryrefslogtreecommitdiffstats
path: root/src/audio_core
diff options
context:
space:
mode:
authorDavid Marcec <dmarcecguzman@gmail.com>2019-06-16 11:06:33 +0200
committerDavid Marcec <dmarcecguzman@gmail.com>2019-06-16 11:06:33 +0200
commit335127af6921ce298a6dd63682895768c6b06e86 (patch)
tree0a505fec2c232dec0945fc02159eecc9c3af087e /src/audio_core
parentMerge pull request #2538 from ReinUsesLisp/ssy-pbk (diff)
downloadyuzu-335127af6921ce298a6dd63682895768c6b06e86.tar
yuzu-335127af6921ce298a6dd63682895768c6b06e86.tar.gz
yuzu-335127af6921ce298a6dd63682895768c6b06e86.tar.bz2
yuzu-335127af6921ce298a6dd63682895768c6b06e86.tar.lz
yuzu-335127af6921ce298a6dd63682895768c6b06e86.tar.xz
yuzu-335127af6921ce298a6dd63682895768c6b06e86.tar.zst
yuzu-335127af6921ce298a6dd63682895768c6b06e86.zip
Diffstat (limited to 'src/audio_core')
-rw-r--r--src/audio_core/stream.cpp10
-rw-r--r--src/audio_core/stream.h7
2 files changed, 14 insertions, 3 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp
index 11481a776..982c7af2f 100644
--- a/src/audio_core/stream.cpp
+++ b/src/audio_core/stream.cpp
@@ -51,6 +51,10 @@ void Stream::Stop() {
UNIMPLEMENTED();
}
+void Stream::SetVolume(float volume) {
+ game_volume = volume;
+}
+
Stream::State Stream::GetState() const {
return state;
}
@@ -62,8 +66,8 @@ s64 Stream::GetBufferReleaseCycles(const Buffer& buffer) const {
return Core::Timing::usToCycles(us);
}
-static void VolumeAdjustSamples(std::vector<s16>& samples) {
- const float volume{std::clamp(Settings::values.volume, 0.0f, 1.0f)};
+static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) {
+ const float volume{std::clamp(Settings::values.volume - (1.0f - game_volume), 0.0f, 1.0f)};
if (volume == 1.0f) {
return;
@@ -97,7 +101,7 @@ void Stream::PlayNextBuffer() {
active_buffer = queued_buffers.front();
queued_buffers.pop();
- VolumeAdjustSamples(active_buffer->GetSamples());
+ VolumeAdjustSamples(active_buffer->GetSamples(), game_volume);
sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples());
diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h
index 05071243b..97458c80a 100644
--- a/src/audio_core/stream.h
+++ b/src/audio_core/stream.h
@@ -61,6 +61,12 @@ public:
/// Returns a vector of recently released buffers specified by tag
std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(std::size_t max_count);
+ void SetVolume(float volume);
+
+ float GetVolume() const {
+ return game_volume;
+ }
+
/// Returns true if the stream is currently playing
bool IsPlaying() const {
return state == State::Playing;
@@ -103,6 +109,7 @@ private:
SinkStream& sink_stream; ///< Output sink for the stream
Core::Timing::CoreTiming& core_timing; ///< Core timing instance.
std::string name; ///< Name of the stream, must be unique
+ float game_volume = 1.0f; ///< The volume the game currently has set
};
using StreamPtr = std::shared_ptr<Stream>;