CrystalSpace

Public API Reference

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 CS
00059 {
00060 namespace SndSys
00061 {
00101 class CS_CRYSTALSPACE_EXPORT PCMSampleConverter
00102 {
00103 public:
00105   PCMSampleConverter(int source_channels, int source_bitspersample, 
00106     int source_frequency, bool swap16=false);
00107   ~PCMSampleConverter();
00108 
00121   int GetRequiredOutputBufferMultiple(int dest_channels, 
00122     int dest_bitspersample, int dest_frequency);
00123 
00124 
00135   int ConvertBuffer(const void *source, size_t source_len, void *dest, 
00136     int dest_channels, int dest_bitspersample, int dest_frequency);
00137 
00152   void SetSourceProperties(int source_channels, int source_bitspersample, 
00153     int source_frequency);
00154 
00155 protected:
00156   bool ReadFullSample8(const void **source, size_t *source_len, 
00157     int *sample_buffer);
00158   bool ReadFullSample16(const void **source, size_t *source_len, 
00159     int *sample_buffer);
00160   bool ReadFullSample(const void **source, size_t  *source_len, 
00161     int *sample_buffer);
00162   int WriteSample8(int *sample_buffer, void **dest, int dest_channels);
00163   int WriteSample16(int *sample_buffer, void **dest, int dest_channels);
00164   int WriteSample(int *sample_buffer, void **dest, int dest_channels, 
00165     int dest_bitspersample);
00166   size_t AdvanceSourceSamples(const void **source, size_t *source_len, 
00167     size_t samples_to_advance, int *sample_buffer);
00168 
00169 protected:
00170   int last_sample[CS_SOUND_ELEMENT_MAX_CHANNELS];
00171   int position_offset;
00172   int src_channels,src_bytes,src_frequency;
00173   bool swap_16;
00174 };
00175 
00176 } // namespace SndSys
00177 } // namespace CS
00178 
00179 #endif // __CS_SNDSYS_CONVERT_H__

Generated for Crystal Space by doxygen 1.4.7