diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index d90f9751bc..50290ce461 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -77,6 +77,7 @@ RageSound::RageSound(): databuf.reserve(internal_buffer_size); m_StartSample = 0; m_LengthSamples = -1; + m_Volume = -1.0f; // use SOUNDMAN->GetMixVolume() AccurateSync = false; fade_length = 0; /* Register ourselves, so we receive Update()s. */ @@ -109,6 +110,7 @@ RageSound::RageSound(const RageSound &cpy): original = cpy.original; m_StartSample = cpy.m_StartSample; m_LengthSamples = cpy.m_LengthSamples; + m_Volume = cpy.m_Volume; StopMode = cpy.StopMode; position = cpy.position; playing = false; @@ -513,6 +515,11 @@ int RageSound::GetPCM( char *buffer, int size, int64_t frameno ) void RageSound::StartPlaying() { LockMut(SOUNDMAN->lock); + + // If no volume is set, use the default. + if( GetVolume() == -1 ) + SetVolume( SOUNDMAN->GetMixVolume() ); + stopped_position = -1; ASSERT(!playing); diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index e77d3a0f51..c25c4c82db 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -16,6 +16,7 @@ public: virtual int GetPCM( char *buffer, int size, int64_t sampleno ) = 0; virtual int GetSampleRate() const = 0; virtual RageTimer GetStartTime() const { return RageZeroTimer; } + virtual float GetVolume() const = 0; virtual CString GetLoadedFilePath() const = 0; }; @@ -75,6 +76,8 @@ public: void SetPlaybackRate( float fScale ); void SetFadeLength( float fSeconds ); void SetNoFade() { SetFadeLength(0); } + void SetVolume( float fVolume ) { m_Volume = fVolume; } + float GetVolume() const { return m_Volume; } float GetPlaybackRate() const { return float(speed_input_samples) / speed_output_samples; } bool IsPlaying() const { return playing; } CString GetLoadedFilePath() const { return m_sFilePath; } @@ -120,6 +123,8 @@ private: /* Amount of time to fade out at the end. */ float fade_length; + float m_Volume; + /* Hack: When we stop a playing sound, we can't ask the driver the position * (we're not playing); and we can't seek back to the current playing position * when we stop (too slow), but we want to be able to report the position we