Move the linear resampler to RageSoundReader_Resample_Fast.

Add RageSoundReader_Resample_Good, using libresample.
This commit is contained in:
Glenn Maynard
2003-09-24 22:31:34 +00:00
parent 83c58f3b3a
commit 6954e0facf
6 changed files with 440 additions and 113 deletions
@@ -0,0 +1,52 @@
#ifndef RAGE_SOUND_READER_RESAMPLE_GOOD
#define RAGE_SOUND_READER_RESAMPLE_GOOD
#include "RageSoundReader.h"
#include "RageSoundReader_Resample.h"
/* This class changes the sampling rate of a sound. */
class RageSoundReader_Resample_Good: public RageSoundReader_Resample
{
enum { BUFSIZE = 4096 };
SoundReader *source;
bool HighQuality;
int samplerate;
/* Mutable hell, since GetLength pretends to be const but isn't yet. */
mutable void *resamp[2];
mutable void *empty_resamp[2];
float inbuf[2][BUFSIZE];
mutable int BufSamples;
mutable bool eof;
void Reset() const;
void FlushResampler() const;
void ReopenResampler() const;
float GetFactor() const;
bool FillBuf();
public:
/* We own source. */
void Open(SoundReader *source);
int GetLength() const;
int GetLength_Fast() const;
int SetPosition_Accurate(int ms);
int SetPosition_Fast(int ms);
int Read(char *buf, unsigned len);
RageSoundReader_Resample_Good();
virtual ~RageSoundReader_Resample_Good();
SoundReader *Copy() const;
/* Change the actual sample rate of a sound. */
void SetSampleRate( int hz );
void SetHighQuality( bool hq ) { HighQuality = hq; }
int GetSampleRate() const { return samplerate; }
};
#endif
/*
* Copyright (c) 2003 by the person(s) listed below. All rights reserved.
* Glenn Maynard
*/