From be307e9a60f272ed2e24acdf10831d54bfa34c24 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 8 Nov 2007 09:06:43 +0000 Subject: [PATCH] probably fix crash with mono songs --- stepmania/src/RageSoundReader_Extend.cpp | 2 +- stepmania/src/RageSoundUtil.cpp | 4 ++-- stepmania/src/RageSoundUtil.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stepmania/src/RageSoundReader_Extend.cpp b/stepmania/src/RageSoundReader_Extend.cpp index 73f2d0cb45..0c316c7a50 100644 --- a/stepmania/src/RageSoundReader_Extend.cpp +++ b/stepmania/src/RageSoundReader_Extend.cpp @@ -123,7 +123,7 @@ int RageSoundReader_Extend::Read( float *pBuffer, int iFrames ) const int iEndSecond = m_iPositionFrames + iFramesRead; const float fStartVolume = SCALE( iStartSecond, iFullVolumePositionFrames, iSilencePositionFrames, 1.0f, 0.0f ); const float fEndVolume = SCALE( iEndSecond, iFullVolumePositionFrames, iSilencePositionFrames, 1.0f, 0.0f ); - RageSoundUtil::Fade( pBuffer, iFramesRead, fStartVolume, fEndVolume ); + RageSoundUtil::Fade( pBuffer, iFramesRead, this->GetNumChannels(), fStartVolume, fEndVolume ); } m_iPositionFrames += iFramesRead; diff --git a/stepmania/src/RageSoundUtil.cpp b/stepmania/src/RageSoundUtil.cpp index c547c0598f..55d3d9a031 100644 --- a/stepmania/src/RageSoundUtil.cpp +++ b/stepmania/src/RageSoundUtil.cpp @@ -48,7 +48,7 @@ void RageSoundUtil::Pan( float *buffer, int frames, float fPos ) } } -void RageSoundUtil::Fade( float *pBuffer, int iFrames, float fStartVolume, float fEndVolume ) +void RageSoundUtil::Fade( float *pBuffer, int iFrames, int iChannels, float fStartVolume, float fEndVolume ) { /* If the whole buffer is full volume, skip. */ if( fStartVolume > .9999f && fEndVolume > .9999f ) @@ -59,7 +59,7 @@ void RageSoundUtil::Fade( float *pBuffer, int iFrames, float fStartVolume, float float fVolPercent = SCALE( iFrame, 0, iFrames, fStartVolume, fEndVolume ); fVolPercent = clamp( fVolPercent, 0.f, 1.f ); - for( int i = 0; i < channels; ++i ) + for( int i = 0; i < iChannels; ++i ) { *pBuffer *= fVolPercent; pBuffer++; diff --git a/stepmania/src/RageSoundUtil.h b/stepmania/src/RageSoundUtil.h index 8755c3ccc6..ab5218e53b 100644 --- a/stepmania/src/RageSoundUtil.h +++ b/stepmania/src/RageSoundUtil.h @@ -7,7 +7,7 @@ namespace RageSoundUtil { void Attenuate( float *pBuf, int iSamples, float fVolume ); void Pan( float *pBuffer, int iFrames, float fPos ); - void Fade( float *pBuffer, int iFrames, float fStartVolume, float fEndVolume ); + void Fade( float *pBuffer, int iFrames, int iChannels, float fStartVolume, float fEndVolume ); void ConvertMonoToStereoInPlace( float *pBuffer, int iFrames ); void ConvertNativeInt16ToFloat( const int16_t *pFrom, float *pTo, int iSamples ); void ConvertFloatToNativeInt16( const float *pFrom, int16_t *pTo, int iSamples );