csplugincommon/sndsys/convert.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2004 by Andrew Mann 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_SNDSYS_CONVERT_H__ 00020 #define __CS_SNDSYS_CONVERT_H__ 00021 00032 #define CS_SOUND_ELEMENT_MAX_CHANNELS 8 00033 00056 #define CS_SOUND_INTERNAL_FREQUENCY_DIVISOR 1024 00057 00058 namespace CrystalSpace 00059 { 00060 00100 class PCMSampleConverter 00101 { 00102 public: 00104 PCMSampleConverter(int source_channels, int source_bitspersample, 00105 int source_frequency, bool swap16=false); 00106 ~PCMSampleConverter(); 00107 00120 int GetRequiredOutputBufferMultiple(int dest_channels, 00121 int dest_bitspersample, int dest_frequency); 00122 00123 00134 int ConvertBuffer(const void *source, size_t source_len, void *dest, 00135 int dest_channels, int dest_bitspersample, int dest_frequency); 00136 00151 void SetSourceProperties(int source_channels, int source_bitspersample, 00152 int source_frequency); 00153 00154 protected: 00155 bool ReadFullSample8(const void **source, size_t *source_len, 00156 int *sample_buffer); 00157 bool ReadFullSample16(const void **source, size_t *source_len, 00158 int *sample_buffer); 00159 bool ReadFullSample(const void **source, size_t *source_len, 00160 int *sample_buffer); 00161 int WriteSample8(int *sample_buffer, void **dest, int dest_channels); 00162 int WriteSample16(int *sample_buffer, void **dest, int dest_channels); 00163 int WriteSample(int *sample_buffer, void **dest, int dest_channels, 00164 int dest_bitspersample); 00165 size_t AdvanceSourceSamples(const void **source, size_t *source_len, 00166 size_t samples_to_advance, int *sample_buffer); 00167 00168 protected: 00169 int last_sample[CS_SOUND_ELEMENT_MAX_CHANNELS]; 00170 int position_offset; 00171 int src_channels,src_bytes,src_frequency; 00172 bool swap_16; 00173 }; 00174 00175 } // namespace CrystalSpace 00176 00177 #endif // __CS_SNDSYS_CONVERT_H__
Generated for Crystal Space by doxygen 1.4.6