From 14c8d02e9e8862ff574c138f83f348d8d1a31350 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 29 Nov 2006 21:47:23 +0000 Subject: [PATCH] GetNextSourceFrame, GetStreamToSourceRatio --- stepmania/src/RageSoundReader_Resample_Good.cpp | 17 +++++++++++++++++ stepmania/src/RageSoundReader_Resample_Good.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/stepmania/src/RageSoundReader_Resample_Good.cpp b/stepmania/src/RageSoundReader_Resample_Good.cpp index 39cc096de8..d25906df30 100644 --- a/stepmania/src/RageSoundReader_Resample_Good.cpp +++ b/stepmania/src/RageSoundReader_Resample_Good.cpp @@ -502,6 +502,7 @@ public: int NumInputsForOutputSamples( int iOut ) const { return m_pPolyphase->NumInputsForOutputSamples(*m_pState, iOut, m_iDownFactor); } int GetLatency() const { return m_pPolyphase->GetLatency(); } + int GetFilled() const { return m_pState->m_iFilled; } RageSoundResampler_Polyphase( const RageSoundResampler_Polyphase &cpy ) { @@ -540,6 +541,22 @@ private: int m_iDownFactor; }; +int RageSoundReader_Resample_Good::GetNextSourceFrame() const +{ + uint64_t iPosition = m_pSource->GetNextSourceFrame(); + iPosition -= m_apResamplers[0]->GetFilled(); + + iPosition *= m_iSampleRate; + iPosition /= m_pSource->GetSampleRate(); + return (int) iPosition; +} + +float RageSoundReader_Resample_Good::GetStreamToSourceRatio() const +{ + float fRatio = m_pSource->GetStreamToSourceRatio(); + return fRatio; +} + RageSoundReader_Resample_Good::RageSoundReader_Resample_Good( RageSoundReader *pSource, int iSampleRate ) { m_pSource = pSource; diff --git a/stepmania/src/RageSoundReader_Resample_Good.h b/stepmania/src/RageSoundReader_Resample_Good.h index 8acc06d6db..be31daba40 100644 --- a/stepmania/src/RageSoundReader_Resample_Good.h +++ b/stepmania/src/RageSoundReader_Resample_Good.h @@ -21,6 +21,8 @@ public: int Read( char *pBuf, unsigned iLen ); virtual ~RageSoundReader_Resample_Good(); RageSoundReader_Resample_Good *Copy() const; + int GetNextSourceFrame() const; + float GetStreamToSourceRatio() const; int GetSampleRate() const { return m_iSampleRate; } unsigned GetNumChannels() const { return m_pSource->GetNumChannels(); }