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

RageSoundResampler.h

Go to the documentation of this file.
00001 #ifndef RAGE_SOUND_RESAMPLER_H 00002 #define RAGE_SOUND_RESAMPLER_H 00003 00004 class RageSoundResampler 00005 { 00006 int InputRate, OutputRate, Channels; 00007 00008 enum { MAX_CHANNELS = 15 }; 00009 int16_t prev[MAX_CHANNELS]; 00010 00011 vector<int16_t> outbuf; 00012 bool at_eof; 00013 int ipos; 00014 00015 float t[MAX_CHANNELS]; 00016 00017 public: 00018 RageSoundResampler(); 00019 00020 /* Configuration: */ 00021 void SetChannels( int c ) { ASSERT( c < MAX_CHANNELS ); Channels = c; } 00022 void SetInputSampleRate(int hz) { InputRate = hz; } 00023 void SetOutputSampleRate(int hz) { OutputRate = hz; } 00024 00025 /* Write data to be converted. */ 00026 void write(const void *data, int bytes); 00027 00028 /* Indicate that there is no more data. */ 00029 void eof(); 00030 00031 void reset(); 00032 00033 /* Return the number of bytes currently readable. */ 00034 unsigned avail() const { return outbuf.size() / 2; } 00035 00036 /* Read converted data. Returns the number of bytes filled. 00037 * If eof() has been called and the output is completely 00038 * flushed, returns -1. */ 00039 int read(void *data, unsigned bytes); 00040 }; 00041 00042 #endif 00043 00044 /* 00045 * Copyright (c) 2003 Glenn Maynard 00046 * All rights reserved. 00047 * 00048 * Permission is hereby granted, free of charge, to any person obtaining a 00049 * copy of this software and associated documentation files (the 00050 * "Software"), to deal in the Software without restriction, including 00051 * without limitation the rights to use, copy, modify, merge, publish, 00052 * distribute, and/or sell copies of the Software, and to permit persons to 00053 * whom the Software is furnished to do so, provided that the above 00054 * copyright notice(s) and this permission notice appear in all copies of 00055 * the Software and that both the above copyright notice(s) and this 00056 * permission notice appear in supporting documentation. 00057 * 00058 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00059 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00060 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00061 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00062 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00063 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00064 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00065 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00066 * PERFORMANCE OF THIS SOFTWARE. 00067 */

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