Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RageSoundReader_Resample_Good.h

Go to the documentation of this file.
00001 #ifndef RAGE_SOUND_READER_RESAMPLE_GOOD 00002 #define RAGE_SOUND_READER_RESAMPLE_GOOD 00003 00004 #include "RageSoundReader.h" 00005 #include "RageSoundReader_Resample.h" 00006 00007 /* This class changes the sampling rate of a sound. */ 00008 class RageSoundReader_Resample_Good: public RageSoundReader_Resample 00009 { 00010 public: 00011 /* We own source. */ 00012 void Open(SoundReader *source); 00013 int GetLength() const; 00014 int GetLength_Fast() const; 00015 int SetPosition_Accurate(int ms); 00016 int SetPosition_Fast(int ms); 00017 int Read(char *buf, unsigned len); 00018 RageSoundReader_Resample_Good(); 00019 virtual ~RageSoundReader_Resample_Good(); 00020 SoundReader *Copy() const; 00021 00022 /* Change the actual sample rate of a sound. */ 00023 void SetSampleRate( int hz ); 00024 void SetHighQuality( bool hq ) { HighQuality = hq; } 00025 00026 int GetSampleRate() const { return samplerate; } 00027 unsigned GetNumChannels() const { return source->GetNumChannels(); } 00028 bool IsStreamingFromDisk() const { return source->IsStreamingFromDisk(); } 00029 00030 enum { BUFSIZE = 4096 }; 00031 00032 private: 00033 SoundReader *source; 00034 bool HighQuality; 00035 int samplerate; 00036 00037 void *empty_resamp; 00038 struct resample_channel 00039 { 00040 resample_channel(): resamp(NULL) { } 00041 void *resamp; 00042 float inbuf[BUFSIZE]; 00043 }; 00044 vector<resample_channel> resamplers; /* one per channel */ 00045 int BufSamples; 00046 bool eof; 00047 00048 void Reset(); 00049 void ReopenResampler(); 00050 float GetFactor() const; 00051 bool FillBuf(); 00052 }; 00053 00054 #endif 00055 00056 /* 00057 * Copyright (c) 2003 Glenn Maynard 00058 * All rights reserved. 00059 * 00060 * Permission is hereby granted, free of charge, to any person obtaining a 00061 * copy of this software and associated documentation files (the 00062 * "Software"), to deal in the Software without restriction, including 00063 * without limitation the rights to use, copy, modify, merge, publish, 00064 * distribute, and/or sell copies of the Software, and to permit persons to 00065 * whom the Software is furnished to do so, provided that the above 00066 * copyright notice(s) and this permission notice appear in all copies of 00067 * the Software and that both the above copyright notice(s) and this 00068 * permission notice appear in supporting documentation. 00069 * 00070 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00071 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00072 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00073 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00074 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00075 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00076 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00077 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00078 * PERFORMANCE OF THIS SOFTWARE. 00079 */

Generated on Thu Jan 27 20:57:29 2005 for StepMania by doxygen 1.3.7