make RageSoundReader_Resample_Good a RageSoundReader_Filter

This commit is contained in:
Glenn Maynard
2006-12-23 06:38:42 +00:00
parent dc876225b5
commit 71be488f42
2 changed files with 5 additions and 23 deletions
@@ -594,9 +594,9 @@ float RageSoundReader_Resample_Good::GetStreamToSourceRatio() const
return fRatio; return fRatio;
} }
RageSoundReader_Resample_Good::RageSoundReader_Resample_Good( RageSoundReader *pSource, int iSampleRate ) RageSoundReader_Resample_Good::RageSoundReader_Resample_Good( RageSoundReader *pSource, int iSampleRate ):
RageSoundReader_Filter( pSource )
{ {
m_pSource = pSource;
m_iSampleRate = iSampleRate; m_iSampleRate = iSampleRate;
m_fRate = -1; m_fRate = -1;
ReopenResampler(); ReopenResampler();
@@ -661,17 +661,6 @@ RageSoundReader_Resample_Good::~RageSoundReader_Resample_Good()
{ {
for( size_t iChannel = 0; iChannel < m_apResamplers.size(); ++iChannel ) for( size_t iChannel = 0; iChannel < m_apResamplers.size(); ++iChannel )
delete m_apResamplers[iChannel]; delete m_apResamplers[iChannel];
delete m_pSource;
}
int RageSoundReader_Resample_Good::GetLength() const
{
return m_pSource->GetLength();
}
int RageSoundReader_Resample_Good::GetLength_Fast() const
{
return m_pSource->GetLength_Fast();
} }
/* iFrame is in the destination rate. Seek the source in its own sample rate. */ /* iFrame is in the destination rate. Seek the source in its own sample rate. */
@@ -790,11 +779,10 @@ void RageSoundReader_Resample_Good::SetRate( float fRatio )
} }
RageSoundReader_Resample_Good::RageSoundReader_Resample_Good( const RageSoundReader_Resample_Good &cpy ): RageSoundReader_Resample_Good::RageSoundReader_Resample_Good( const RageSoundReader_Resample_Good &cpy ):
RageSoundReader(cpy) RageSoundReader_Filter(cpy)
{ {
for( size_t i = 0; i < cpy.m_apResamplers.size(); ++i ) for( size_t i = 0; i < cpy.m_apResamplers.size(); ++i )
this->m_apResamplers.push_back( new RageSoundResampler_Polyphase(*cpy.m_apResamplers[i]) ); this->m_apResamplers.push_back( new RageSoundResampler_Polyphase(*cpy.m_apResamplers[i]) );
this->m_pSource = cpy.m_pSource->Copy();
this->m_iSampleRate = cpy.m_iSampleRate; this->m_iSampleRate = cpy.m_iSampleRate;
this->m_fRate = cpy.m_fRate; this->m_fRate = cpy.m_fRate;
} }
@@ -3,19 +3,17 @@
#ifndef RAGE_SOUND_READER_RESAMPLE_GOOD_H #ifndef RAGE_SOUND_READER_RESAMPLE_GOOD_H
#define RAGE_SOUND_READER_RESAMPLE_GOOD_H #define RAGE_SOUND_READER_RESAMPLE_GOOD_H
#include "RageSoundReader.h" #include "RageSoundReader_Filter.h"
class RageSoundResampler_Polyphase; class RageSoundResampler_Polyphase;
/* This class changes the sampling rate of a sound. */ /* This class changes the sampling rate of a sound. */
class RageSoundReader_Resample_Good: public RageSoundReader class RageSoundReader_Resample_Good: public RageSoundReader_Filter
{ {
public: public:
/* We own source. */ /* We own source. */
RageSoundReader_Resample_Good( RageSoundReader *pSource, int iSampleRate ); RageSoundReader_Resample_Good( RageSoundReader *pSource, int iSampleRate );
RageSoundReader_Resample_Good( const RageSoundReader_Resample_Good &cpy ); RageSoundReader_Resample_Good( const RageSoundReader_Resample_Good &cpy );
int GetLength() const;
int GetLength_Fast() const;
int SetPosition( int iFrame ); int SetPosition( int iFrame );
int Read( char *pBuf, int iFrames ); int Read( char *pBuf, int iFrames );
virtual ~RageSoundReader_Resample_Good(); virtual ~RageSoundReader_Resample_Good();
@@ -23,14 +21,11 @@ public:
bool SetProperty( const RString &sProperty, float fValue ); bool SetProperty( const RString &sProperty, float fValue );
int GetNextSourceFrame() const; int GetNextSourceFrame() const;
float GetStreamToSourceRatio() const; float GetStreamToSourceRatio() const;
RageSoundReader *GetSource() { return m_pSource; }
/* Change the rate of a sound without changing the sample rate. */ /* Change the rate of a sound without changing the sample rate. */
void SetRate( float fRatio ); void SetRate( float fRatio );
int GetSampleRate() const { return m_iSampleRate; } int GetSampleRate() const { return m_iSampleRate; }
unsigned GetNumChannels() const { return m_pSource->GetNumChannels(); }
bool IsStreamingFromDisk() const { return m_pSource->IsStreamingFromDisk(); }
private: private:
void Reset(); void Reset();
@@ -39,7 +34,6 @@ private:
vector<RageSoundResampler_Polyphase *> m_apResamplers; /* one per channel */ vector<RageSoundResampler_Polyphase *> m_apResamplers; /* one per channel */
RageSoundReader *m_pSource;
int m_iSampleRate; int m_iSampleRate;
float m_fRate; float m_fRate;
}; };