diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index 17c3f0b0be..b111094083 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -9,6 +9,7 @@ #include "RageSound.h" #include "RageLog.h" #include "RageTimer.h" +#include "PrefsManager.h" #include "arch/arch.h" #include "arch/Sound/RageSoundDriver.h" @@ -267,13 +268,11 @@ void RageSoundManager::PlayMusic(CString file, bool loop, float start_sec, float SoundMixBuffer::SoundMixBuffer() { - vol = .5; + vol = PREFSMAN->m_fSoundVolume; } void SoundMixBuffer::write(const Sint16 *buf, unsigned size) { - size /= 2; - if(mixbuf.size() < size) { basic_string empty(size-mixbuf.size(), 0); diff --git a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp index 5730d945dd..db419f28f5 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp @@ -12,6 +12,7 @@ #include "../../RageUtil.h" #include "../../RageSound.h" #include "../../RageLog.h" +#include "../../PrefsManager.h" #include "../../tls.h" #include "SDL.h" @@ -162,7 +163,7 @@ RageSound_DSound::RageSound_DSound() newbuf = new DSoundBuf(ds, DSoundBuf::HW_HARDWARE, channels, samplerate, 16, buffersize, - 0.50f); + PREFSMAN->m_fSoundVolume); } catch(const RageException &e) { /* If we didn't get at least 8, fail. */ if(i >= 8) break; /* OK */ diff --git a/stepmania/src/arch/Sound/RageSoundDriver_DSound_Software.cpp b/stepmania/src/arch/Sound/RageSoundDriver_DSound_Software.cpp index 3deff8da36..36cc5eb706 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_DSound_Software.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_DSound_Software.cpp @@ -81,7 +81,7 @@ bool RageSound_DSound_Software::GetData() /* Call the callback. */ unsigned got = sounds[i]->snd->GetPCM((char *) buf, len, play_pos); - mix.write((Sint16 *) buf, got); + mix.write((Sint16 *) buf, got/2); if(got < len) { diff --git a/stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp b/stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp index 1877c2c2b8..581932b19d 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp @@ -76,11 +76,10 @@ bool RageSound_WaveOut::GetData() static Sint16 *buf = NULL; int bufsize = chunksize_frames * channels; if(!buf) - { buf = new Sint16[bufsize]; - } memset(buf, 0, bufsize*sizeof(Uint16)); memset(buffers[b].lpData, 0, bufsize*sizeof(Uint16)); + SoundMixBuffer mix; for(unsigned i = 0; i < sounds.size(); ++i) { @@ -90,8 +89,7 @@ bool RageSound_WaveOut::GetData() /* Call the callback. */ unsigned got = sounds[i]->snd->GetPCM((char *) buf, chunksize, last_cursor_pos); - SOUNDMAN->MixAudio( - (Sint16 *) buffers[b].lpData, buf, got, .5); + mix.write((Sint16 *) buf, got/2); if(got < chunksize) { @@ -101,6 +99,7 @@ bool RageSound_WaveOut::GetData() } } + mix.read((Sint16 *) buffers[b].lpData); MMRESULT ret = waveOutWrite(wo, &buffers[b], sizeof(buffers[b])); if(ret != MMSYSERR_NOERROR) RageException::Throw(wo_ssprintf(ret, "waveOutWrite failed"));