diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index 7d9d407ed1..934181e5c0 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -50,7 +50,7 @@ RageSoundParams::RageSoundParams(): m_StartSecond = 0; m_LengthSeconds = -1; m_FadeLength = 0; - m_Volume = -1.0f; // use SOUNDMAN->GetMixVolume() + m_Volume = 1.0f; m_Balance = 0; // center speed_input_samples = speed_output_samples = 1; m_bAccurateSync = false; @@ -574,10 +574,6 @@ int RageSound::GetPCM( char *pBuffer, int iSize, int64_t iFrameno ) * playing, Stop is called. */ void RageSound::StartPlaying() { - // If no volume is set, use the default. - if( m_Param.m_Volume == -1 ) - m_Param.m_Volume = SOUNDMAN->GetMixVolume(); - ASSERT( !m_bPlaying ); /* If m_StartTime is in the past, then we probably set a start time but took too @@ -885,6 +881,12 @@ float RageSound::GetVolume() const return m_Param.m_Volume; } +float RageSound::GetAbsoluteVolume() const +{ + float f = m_Param.m_Volume * SOUNDMAN->GetMixVolume(); + return f; +} + void RageSound::LockSound() { m_Mutex.Lock(); diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index 386947bac2..329e2bc103 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -22,6 +22,7 @@ public: virtual int GetSampleRate() const = 0; virtual RageTimer GetStartTime() const { return RageZeroTimer; } virtual float GetVolume() const = 0; + virtual float GetAbsoluteVolume() const = 0; virtual int GetID() const = 0; virtual CString GetLoadedFilePath() const = 0; virtual bool IsStreamingFromDisk() const = 0; @@ -42,7 +43,7 @@ struct RageSoundParams void SetNoFade() { m_FadeLength = 0; } - float m_Volume; + float m_Volume; // multiplies with SOUNDMAN->GetMixVolume() /* Pan: -1, left; 1, right */ float m_Balance; @@ -138,6 +139,7 @@ public: float GetPlaybackRate() const; RageTimer GetStartTime() const; float GetVolume() const; + float GetAbsoluteVolume() const; // factors in SOUNDMAN->GetMixVolume() int GetID() const { return m_iID; } void SetParams( const RageSoundParams &p ); const RageSoundParams &GetParams() const { return m_Param; } diff --git a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp index 907cd97570..b2dfdda29c 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp @@ -130,7 +130,7 @@ bool RageSound_ALSA9::stream::GetData( bool &bEOF ) bytes_read += got; bytes_left -= got; - RageSoundManager::AttenuateBuf( buf, got/sizeof(int16_t), snd->GetVolume() ); + RageSoundManager::AttenuateBuf( buf, got/sizeof(int16_t), snd->GetAbsoluteVolume() ); if( bytes_left > 0 ) { diff --git a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp index 6555cde27a..d55278408b 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp @@ -149,7 +149,7 @@ bool RageSound_DSound::stream::GetData( bool init, bool &bEOF ) * fill anything in FLUSHING; in that case, we just clear the audio buffer. */ if(state != FLUSHING) { - pcm->SetVolume( snd->GetVolume() ); + pcm->SetVolume( snd->GetAbsoluteVolume() ); int bytes_read = 0; int bytes_left = len; diff --git a/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp b/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp index e390bac719..36c91d1a32 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp @@ -181,7 +181,7 @@ void RageSound_Generic_Software::DecodeThread() { /* The volume can change while the sound is playing; update it. */ if( sounds[i].state == sound::PLAYING || sounds[i].state == sound::STOPPING ) - sounds[i].volume = sounds[i].snd->GetVolume(); + sounds[i].volume = sounds[i].snd->GetAbsoluteVolume(); } /* @@ -327,7 +327,7 @@ void RageSound_Generic_Software::StartMixing( RageSoundBase *snd ) s.snd = snd; s.start_time = snd->GetStartTime(); s.sound_id = snd->GetID(); - s.volume = snd->GetVolume(); + s.volume = snd->GetAbsoluteVolume(); s.buffer.clear(); /* Initialize the sound buffer. */