Files
itgmania212121/stepmania/src/RageSoundReader_Resample_Good.h
T

70 lines
2.5 KiB
C++
Raw Normal View History

2006-02-13 04:50:28 +00:00
/* RageSoundReader_Resample_Good - fast audio resampling. */
2005-02-13 03:08:45 +00:00
#ifndef RAGE_SOUND_READER_RESAMPLE_GOOD_H
#define RAGE_SOUND_READER_RESAMPLE_GOOD_H
#include "RageSoundReader_Filter.h"
2006-02-13 04:50:28 +00:00
class RageSoundResampler_Polyphase;
/* This class changes the sampling rate of a sound. */
class RageSoundReader_Resample_Good: public RageSoundReader_Filter
{
2004-07-24 04:11:07 +00:00
public:
/* We own source. */
RageSoundReader_Resample_Good( RageSoundReader *pSource, int iSampleRate );
2006-11-29 02:38:56 +00:00
RageSoundReader_Resample_Good( const RageSoundReader_Resample_Good &cpy );
int SetPosition( int iFrame );
2007-01-27 07:14:58 +00:00
int Read( float *pBuf, int iFrames );
2004-07-24 04:11:07 +00:00
virtual ~RageSoundReader_Resample_Good();
2006-10-20 00:01:18 +00:00
RageSoundReader_Resample_Good *Copy() const;
2006-11-30 03:57:09 +00:00
bool SetProperty( const RString &sProperty, float fValue );
2006-11-29 21:47:23 +00:00
int GetNextSourceFrame() const;
float GetStreamToSourceRatio() const;
2006-11-30 03:57:09 +00:00
/* Change the rate of a sound without changing the sample rate. */
void SetRate( float fRatio );
2004-07-24 04:11:07 +00:00
2006-12-27 07:38:11 +00:00
/* SetRate() will be rounded. Get the exact rate. */
float GetRate() const;
2006-02-13 04:50:28 +00:00
int GetSampleRate() const { return m_iSampleRate; }
2004-07-24 04:11:07 +00:00
private:
void Reset();
void ReopenResampler();
2006-11-30 07:23:56 +00:00
void GetFactors( int &iDownFactor, int &iUpFactor ) const;
2006-02-13 04:50:28 +00:00
2006-10-27 05:53:23 +00:00
vector<RageSoundResampler_Polyphase *> m_apResamplers; /* one per channel */
2006-02-13 04:50:28 +00:00
int m_iSampleRate;
2006-11-30 03:57:09 +00:00
float m_fRate;
};
#endif
2004-05-06 02:40:33 +00:00
/*
2006-02-13 04:50:28 +00:00
* (c) 2006 Glenn Maynard
2004-05-06 02:40:33 +00:00
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/