pa_converters.h

Go to the documentation of this file.
00001 #ifndef PA_CONVERTERS_H
00002 #define PA_CONVERTERS_H
00003 /*
00004  * $Id: pa_converters.h 1083 2006-08-23 07:30:49Z rossb $
00005  * Portable Audio I/O Library sample conversion mechanism
00006  *
00007  * Based on the Open Source API proposed by Ross Bencina
00008  * Copyright (c) 1999-2002 Phil Burk, Ross Bencina
00009  *
00010  * Permission is hereby granted, free of charge, to any person obtaining
00011  * a copy of this software and associated documentation files
00012  * (the "Software"), to deal in the Software without restriction,
00013  * including without limitation the rights to use, copy, modify, merge,
00014  * publish, distribute, sublicense, and/or sell copies of the Software,
00015  * and to permit persons to whom the Software is furnished to do so,
00016  * subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be
00019  * included in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
00025  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00026  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00027  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00028  */
00029 
00030 /*
00031  * The text above constitutes the entire PortAudio license; however, 
00032  * the PortAudio community also makes the following non-binding requests:
00033  *
00034  * Any person wishing to distribute modifications to the Software is
00035  * requested to send the modifications to the original developer so that
00036  * they can be incorporated into the canonical version. It is also 
00037  * requested that these non-binding requests be included along with the 
00038  * license above.
00039  */
00040 
00047 #include "portaudio.h"  /* for PaSampleFormat */
00048 
00049 #ifdef __cplusplus
00050 extern "C"
00051 {
00052 #endif /* __cplusplus */
00053 
00054 
00055 struct PaUtilTriangularDitherGenerator;
00056 
00057 
00067 PaSampleFormat PaUtil_SelectClosestAvailableFormat(
00068         PaSampleFormat availableFormats, PaSampleFormat format );
00069 
00070 
00071 /* high level conversions functions for use by implementations */
00072 
00073 
00088 typedef void PaUtilConverter(
00089     void *destinationBuffer, signed int destinationStride,
00090     void *sourceBuffer, signed int sourceStride,
00091     unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator );
00092 
00093 
00105 PaUtilConverter* PaUtil_SelectConverter( PaSampleFormat sourceFormat,
00106         PaSampleFormat destinationFormat, PaStreamFlags flags );
00107 
00108 
00117 typedef void PaUtilZeroer(
00118     void *destinationBuffer, signed int destinationStride, unsigned int count );
00119 
00120     
00126 PaUtilZeroer* PaUtil_SelectZeroer( PaSampleFormat destinationFormat );
00127 
00128 /*----------------------------------------------------------------------------*/
00129 /* low level functions and data structures which may be used for
00130     substituting conversion functions */
00131 
00132 
00136 typedef struct{
00137     PaUtilConverter *Float32_To_Int32;
00138     PaUtilConverter *Float32_To_Int32_Dither;
00139     PaUtilConverter *Float32_To_Int32_Clip;
00140     PaUtilConverter *Float32_To_Int32_DitherClip;
00141 
00142     PaUtilConverter *Float32_To_Int24;
00143     PaUtilConverter *Float32_To_Int24_Dither;
00144     PaUtilConverter *Float32_To_Int24_Clip;
00145     PaUtilConverter *Float32_To_Int24_DitherClip;
00146     
00147     PaUtilConverter *Float32_To_Int16;
00148     PaUtilConverter *Float32_To_Int16_Dither;
00149     PaUtilConverter *Float32_To_Int16_Clip;
00150     PaUtilConverter *Float32_To_Int16_DitherClip;
00151 
00152     PaUtilConverter *Float32_To_Int8;
00153     PaUtilConverter *Float32_To_Int8_Dither;
00154     PaUtilConverter *Float32_To_Int8_Clip;
00155     PaUtilConverter *Float32_To_Int8_DitherClip;
00156 
00157     PaUtilConverter *Float32_To_UInt8;
00158     PaUtilConverter *Float32_To_UInt8_Dither;
00159     PaUtilConverter *Float32_To_UInt8_Clip;
00160     PaUtilConverter *Float32_To_UInt8_DitherClip;
00161 
00162     PaUtilConverter *Int32_To_Float32;
00163     PaUtilConverter *Int32_To_Int24;
00164     PaUtilConverter *Int32_To_Int24_Dither;
00165     PaUtilConverter *Int32_To_Int16;
00166     PaUtilConverter *Int32_To_Int16_Dither;
00167     PaUtilConverter *Int32_To_Int8;
00168     PaUtilConverter *Int32_To_Int8_Dither;
00169     PaUtilConverter *Int32_To_UInt8;
00170     PaUtilConverter *Int32_To_UInt8_Dither;
00171 
00172     PaUtilConverter *Int24_To_Float32;
00173     PaUtilConverter *Int24_To_Int32;
00174     PaUtilConverter *Int24_To_Int16;
00175     PaUtilConverter *Int24_To_Int16_Dither;
00176     PaUtilConverter *Int24_To_Int8;
00177     PaUtilConverter *Int24_To_Int8_Dither;
00178     PaUtilConverter *Int24_To_UInt8;
00179     PaUtilConverter *Int24_To_UInt8_Dither;
00180 
00181     PaUtilConverter *Int16_To_Float32;
00182     PaUtilConverter *Int16_To_Int32;
00183     PaUtilConverter *Int16_To_Int24;
00184     PaUtilConverter *Int16_To_Int8;
00185     PaUtilConverter *Int16_To_Int8_Dither;
00186     PaUtilConverter *Int16_To_UInt8;
00187     PaUtilConverter *Int16_To_UInt8_Dither;
00188 
00189     PaUtilConverter *Int8_To_Float32;
00190     PaUtilConverter *Int8_To_Int32;
00191     PaUtilConverter *Int8_To_Int24;
00192     PaUtilConverter *Int8_To_Int16;
00193     PaUtilConverter *Int8_To_UInt8;
00194     
00195     PaUtilConverter *UInt8_To_Float32;
00196     PaUtilConverter *UInt8_To_Int32;
00197     PaUtilConverter *UInt8_To_Int24;
00198     PaUtilConverter *UInt8_To_Int16;
00199     PaUtilConverter *UInt8_To_Int8;
00200 
00201     PaUtilConverter *Copy_8_To_8;       /* copy without any conversion */
00202     PaUtilConverter *Copy_16_To_16;     /* copy without any conversion */
00203     PaUtilConverter *Copy_24_To_24;     /* copy without any conversion */
00204     PaUtilConverter *Copy_32_To_32;     /* copy without any conversion */
00205 } PaUtilConverterTable;
00206 
00207 
00225 extern PaUtilConverterTable paConverters;
00226 
00227 
00231 typedef struct{
00232     PaUtilZeroer *ZeroU8; /* unsigned 8 bit, zero == 128 */
00233     PaUtilZeroer *Zero8;
00234     PaUtilZeroer *Zero16;
00235     PaUtilZeroer *Zero24;
00236     PaUtilZeroer *Zero32;
00237 } PaUtilZeroerTable;
00238 
00239 
00256 extern PaUtilZeroerTable paZeroers;
00257 
00258 #ifdef __cplusplus
00259 }
00260 #endif /* __cplusplus */
00261 #endif /* PA_CONVERTERS_H */

Generated on Fri Aug 25 17:18:23 2006 for PortAudio by  doxygen 1.4.7