00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 // 00018 // Last changed : $Date: 2006-05-23 13:40:36 -0400 (Tue, 23 May 2006) $ 00019 // File revision : $Revision: 9996 $ 00020 // 00021 // $Id: FIFOSampleBuffer.h 9996 2006-05-23 17:40:36Z danielk $ 00022 // 00024 // 00025 // License : 00026 // 00027 // SoundTouch audio processing library 00028 // Copyright (c) Olli Parviainen 00029 // 00030 // This library is free software; you can redistribute it and/or 00031 // modify it under the terms of the GNU Lesser General Public 00032 // License as published by the Free Software Foundation; either 00033 // version 2.1 of the License, or (at your option) any later version. 00034 // 00035 // This library is distributed in the hope that it will be useful, 00036 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00037 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00038 // Lesser General Public License for more details. 00039 // 00040 // You should have received a copy of the GNU Lesser General Public 00041 // License along with this library; if not, write to the Free Software 00042 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00043 // 00045 00046 #ifndef FIFOSampleBuffer_H 00047 #define FIFOSampleBuffer_H 00048 00049 #include "FIFOSamplePipe.h" 00050 00051 namespace soundtouch 00052 { 00053 00059 class FIFOSampleBuffer : public FIFOSamplePipe 00060 { 00061 private: 00063 SAMPLETYPE *buffer; 00064 00065 // Raw unaligned buffer memory. 'buffer' is made aligned by pointing it to first 00066 // 16-byte aligned location of this buffer 00067 SAMPLETYPE *bufferUnaligned; 00068 00070 uint sizeInBytes; 00071 00073 uint samplesInBuffer; 00074 00076 uint channels; 00077 00081 uint bufferPos; 00082 00085 void rewind(); 00086 00088 void ensureCapacity(const uint capacityRequirement); 00089 00091 uint getCapacity() const; 00092 00093 public: 00094 00096 FIFOSampleBuffer(uint numChannels = 2 00097 00098 ); 00099 00101 ~FIFOSampleBuffer(); 00102 00110 virtual SAMPLETYPE *ptrBegin() const; 00111 00120 SAMPLETYPE *ptrEnd( 00121 uint slackCapacity 00122 00123 00124 00125 ); 00126 00129 virtual void putSamples(const SAMPLETYPE *samples, 00130 uint numSamples 00131 ); 00132 00139 virtual void putSamples(uint numSamples 00140 ); 00141 00147 virtual uint receiveSamples(SAMPLETYPE *output, 00148 uint maxSamples 00149 ); 00150 00156 virtual uint receiveSamples(uint maxSamples 00157 ); 00158 00160 virtual uint numSamples() const; 00161 00163 void setChannels(uint numChannels); 00164 00166 virtual int isEmpty() const; 00167 00169 virtual void clear(); 00170 }; 00171 00172 } 00173 00174 #endif
1.5.5