From 102ccf3ed17a790c9eeba06b5d15a00ce4e10e8d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 27 Dec 2006 01:58:52 +0000 Subject: [PATCH] snap ratio --- stepmania/src/RageSoundReader_PitchChange.cpp | 11 +++++++++++ stepmania/src/RageSoundReader_PitchChange.h | 1 + 2 files changed, 12 insertions(+) diff --git a/stepmania/src/RageSoundReader_PitchChange.cpp b/stepmania/src/RageSoundReader_PitchChange.cpp index 3303036965..5348cacef1 100644 --- a/stepmania/src/RageSoundReader_PitchChange.cpp +++ b/stepmania/src/RageSoundReader_PitchChange.cpp @@ -57,6 +57,17 @@ int RageSoundReader_PitchChange::Read( char *pBuf, int iFrames ) return RageSoundReader_Filter::Read( pBuf, iFrames ); } +float RageSoundReader_PitchChange::GetStreamToSourceRatio() const +{ + /* If m_fSpeedRatio is 1.0f and the underlying ratio is exactly 1.0, + * the ratio should be exactly 1. Rounding error prevents n * (1/n) + * from being exact. */ + float fRatio = m_pSource->GetStreamToSourceRatio(); + if( m_fSpeedRatio == 1.0f && fabsf(1.0f - fRatio) < 0.001f ) + fRatio = 1.0f; + return fRatio; +} + bool RageSoundReader_PitchChange::SetProperty( const RString &sProperty, float fValue ) { if( sProperty == "Rate" ) diff --git a/stepmania/src/RageSoundReader_PitchChange.h b/stepmania/src/RageSoundReader_PitchChange.h index 4c0673671a..0a91a85c94 100644 --- a/stepmania/src/RageSoundReader_PitchChange.h +++ b/stepmania/src/RageSoundReader_PitchChange.h @@ -15,6 +15,7 @@ public: virtual int Read( char *pBuf, int iFrames ); virtual bool SetProperty( const RString &sProperty, float fValue ); + virtual float GetStreamToSourceRatio() const; void SetSpeedRatio( float fRatio ) { m_fSpeedRatio = fRatio; } void SetPitchRatio( float fRatio ) { m_fPitchRatio = fRatio; }