PortAudio  2.0
Data Structures | Typedefs | Functions | Variables
pa_converters.h File Reference

Conversion functions used to convert buffers of samples from one format to another. More...

#include "portaudio.h"

Go to the source code of this file.

Data Structures

struct  PaUtilConverterTable
 
struct  PaUtilZeroerTable
 

Typedefs

typedef void PaUtilConverter (void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator)
 
typedef void PaUtilZeroer (void *destinationBuffer, signed int destinationStride, unsigned int count)
 

Functions

PaSampleFormat PaUtil_SelectClosestAvailableFormat (PaSampleFormat availableFormats, PaSampleFormat format)
 
PaUtilConverterPaUtil_SelectConverter (PaSampleFormat sourceFormat, PaSampleFormat destinationFormat, PaStreamFlags flags)
 
PaUtilZeroerPaUtil_SelectZeroer (PaSampleFormat destinationFormat)
 

Variables

PaUtilConverterTable paConverters
 
PaUtilZeroerTable paZeroers
 

Detailed Description

Conversion functions used to convert buffers of samples from one format to another.

Typedef Documentation

typedef void PaUtilConverter(void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator)

The generic sample converter prototype. Sample converters convert count samples from sourceBuffer to destinationBuffer. The actual type of the data pointed to by these parameters varys for different converter functions.

Parameters
destinationBufferA pointer to the first sample of the destination.
destinationStrideAn offset between successive destination samples expressed in samples (not bytes.) It may be negative.
sourceBufferA pointer to the first sample of the source.
sourceStrideAn offset between successive source samples expressed in samples (not bytes.) It may be negative.
countThe number of samples to convert.
ditherStateState information used to calculate dither. Converters that do not perform dithering will ignore this parameter, in which case NULL or invalid dither state may be passed.
typedef void PaUtilZeroer(void *destinationBuffer, signed int destinationStride, unsigned int count)

The generic buffer zeroer prototype. Buffer zeroers copy count zeros to destinationBuffer. The actual type of the data pointed to varys for different zeroer functions.

Parameters
destinationBufferA pointer to the first sample of the destination.
destinationStrideAn offset between successive destination samples expressed in samples (not bytes.) It may be negative.
countThe number of samples to zero.

Function Documentation

PaSampleFormat PaUtil_SelectClosestAvailableFormat ( PaSampleFormat  availableFormats,
PaSampleFormat  format 
)

Choose an available sample format which is most appropriate for representing the requested format. If the requested format is not available higher quality formats are considered before lower quality formats.

Parameters
availableFormatsA variable containing the logical OR of all available formats.
formatThe desired format.
Returns
The most appropriate available format for representing the requested format.

References paCustomFormat, paNonInterleaved, and paSampleFormatNotSupported.

Referenced by OpenStream().

PaUtilConverter* PaUtil_SelectConverter ( PaSampleFormat  sourceFormat,
PaSampleFormat  destinationFormat,
PaStreamFlags  flags 
)

Find a sample converter function for the given source and destinations formats and flags (clip and dither.)

Returns
A pointer to a PaUtilConverter which will perform the requested conversion, or NULL if the given format conversion is not supported. For conversions where clipping or dithering is not necessary, the clip and dither flags are ignored and a non-clipping or dithering version is returned. If the source and destination formats are the same, a function which copies data of the appropriate size will be returned.

References PA_SELECT_CONVERTER_DITHER_, PA_SELECT_CONVERTER_DITHER_CLIP_, PA_SELECT_FORMAT_, PA_UNITY_CONVERSION_, and PA_USE_CONVERTER_.

Referenced by main(), and PaUtil_InitializeBufferProcessor().

PaUtilZeroer* PaUtil_SelectZeroer ( PaSampleFormat  destinationFormat)

Find a buffer zeroer function for the given destination format.

Returns
A pointer to a PaUtilZeroer which will perform the requested zeroing.

References paFloat32, paInt16, paInt24, paInt32, paInt8, paNonInterleaved, paUInt8, paZeroers, PaUtilZeroerTable::Zero16, PaUtilZeroerTable::Zero24, PaUtilZeroerTable::Zero32, PaUtilZeroerTable::Zero8, and PaUtilZeroerTable::ZeroU8.

Referenced by PaUtil_InitializeBufferProcessor().

Variable Documentation

PaUtilConverterTable paConverters

A table of pointers to all required converter functions. PaUtil_SelectConverter() uses this table to lookup the appropriate conversion functions. The fields of this structure are initialized with default conversion functions. Fields may be NULL, indicating that no conversion function is available. User code may substitute optimised conversion functions by assigning different function pointers to these fields.

Note
If the PA_NO_STANDARD_CONVERTERS preprocessor variable is defined, PortAudio's standard converters will not be compiled, and all fields of this structure will be initialized to NULL. In such cases, users should supply their own conversion functions if the require PortAudio to open a stream that requires sample conversion.
See Also
PaUtilConverterTable, PaUtilConverter, PaUtil_SelectConverter

Referenced by PaUtil_InitializeX86PlainConverters().

PaUtilZeroerTable paZeroers

A table of pointers to all required zeroer functions. PaUtil_SelectZeroer() uses this table to lookup the appropriate conversion functions. The fields of this structure are initialized with default conversion functions. User code may substitute optimised conversion functions by assigning different function pointers to these fields.

Note
If the PA_NO_STANDARD_ZEROERS preprocessor variable is defined, PortAudio's standard zeroers will not be compiled, and all fields of this structure will be initialized to NULL. In such cases, users should supply their own zeroing functions for the sample sizes which they intend to use.
See Also
PaUtilZeroerTable, PaUtilZeroer, PaUtil_SelectZeroer

Referenced by PaUtil_SelectZeroer().