00001 #ifndef PA_PROCESS_H
00002 #define PA_PROCESS_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00201 #include "portaudio.h"
00202 #include "pa_converters.h"
00203 #include "pa_dither.h"
00204
00205 #ifdef __cplusplus
00206 extern "C"
00207 {
00208 #endif
00209
00210
00217 typedef enum {
00219 paUtilFixedHostBufferSize,
00220
00222 paUtilBoundedHostBufferSize,
00223
00225 paUtilUnknownHostBufferSize,
00226
00234 paUtilVariableHostBufferSizePartialUsageAllowed
00235 }PaUtilHostBufferSizeMode;
00236
00237
00240 typedef struct PaUtilChannelDescriptor{
00241 void *data;
00242 unsigned int stride;
00243 }PaUtilChannelDescriptor;
00244
00245
00251 typedef struct {
00252 unsigned long framesPerUserBuffer;
00253 unsigned long framesPerHostBuffer;
00254
00255 PaUtilHostBufferSizeMode hostBufferSizeMode;
00256 int useNonAdaptingProcess;
00257 unsigned long framesPerTempBuffer;
00258
00259 unsigned int inputChannelCount;
00260 unsigned int bytesPerHostInputSample;
00261 unsigned int bytesPerUserInputSample;
00262 int userInputIsInterleaved;
00263 PaUtilConverter *inputConverter;
00264 PaUtilZeroer *inputZeroer;
00265
00266 unsigned int outputChannelCount;
00267 unsigned int bytesPerHostOutputSample;
00268 unsigned int bytesPerUserOutputSample;
00269 int userOutputIsInterleaved;
00270 PaUtilConverter *outputConverter;
00271 PaUtilZeroer *outputZeroer;
00272
00273 unsigned long initialFramesInTempInputBuffer;
00274 unsigned long initialFramesInTempOutputBuffer;
00275
00276 void *tempInputBuffer;
00277 void **tempInputBufferPtrs;
00278 unsigned long framesInTempInputBuffer;
00280 void *tempOutputBuffer;
00281 void **tempOutputBufferPtrs;
00282 unsigned long framesInTempOutputBuffer;
00284 PaStreamCallbackTimeInfo *timeInfo;
00285
00286 PaStreamCallbackFlags callbackStatusFlags;
00287
00288 unsigned long hostInputFrameCount[2];
00289 PaUtilChannelDescriptor *hostInputChannels[2];
00294 unsigned long hostOutputFrameCount[2];
00295 PaUtilChannelDescriptor *hostOutputChannels[2];
00301 PaUtilTriangularDitherGenerator ditherGenerator;
00302
00303 double samplePeriod;
00304
00305 PaStreamCallback *streamCallback;
00306 void *userData;
00307 } PaUtilBufferProcessor;
00308
00309
00312
00371 PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bufferProcessor,
00372 int inputChannelCount, PaSampleFormat userInputSampleFormat,
00373 PaSampleFormat hostInputSampleFormat,
00374 int outputChannelCount, PaSampleFormat userOutputSampleFormat,
00375 PaSampleFormat hostOutputSampleFormat,
00376 double sampleRate,
00377 PaStreamFlags streamFlags,
00378 unsigned long framesPerUserBuffer,
00379 unsigned long framesPerHostBuffer,
00380 PaUtilHostBufferSizeMode hostBufferSizeMode,
00381 PaStreamCallback *streamCallback, void *userData );
00382
00383
00391 void PaUtil_TerminateBufferProcessor( PaUtilBufferProcessor* bufferProcessor );
00392
00393
00400 void PaUtil_ResetBufferProcessor( PaUtilBufferProcessor* bufferProcessor );
00401
00402
00411 unsigned long PaUtil_GetBufferProcessorInputLatency( PaUtilBufferProcessor* bufferProcessor );
00412
00421 unsigned long PaUtil_GetBufferProcessorOutputLatency( PaUtilBufferProcessor* bufferProcessor );
00422
00432
00433
00445 void PaUtil_SetInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00446 unsigned long frameCount );
00447
00448
00456 void PaUtil_SetNoInput( PaUtilBufferProcessor* bufferProcessor );
00457
00458
00468 void PaUtil_SetInputChannel( PaUtilBufferProcessor* bufferProcessor,
00469 unsigned int channel, void *data, unsigned int stride );
00470
00471
00482 void PaUtil_SetInterleavedInputChannels( PaUtilBufferProcessor* bufferProcessor,
00483 unsigned int firstChannel, void *data, unsigned int channelCount );
00484
00485
00493 void PaUtil_SetNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
00494 unsigned int channel, void *data );
00495
00496
00500 void PaUtil_Set2ndInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00501 unsigned long frameCount );
00502
00506 void PaUtil_Set2ndInputChannel( PaUtilBufferProcessor* bufferProcessor,
00507 unsigned int channel, void *data, unsigned int stride );
00508
00512 void PaUtil_Set2ndInterleavedInputChannels( PaUtilBufferProcessor* bufferProcessor,
00513 unsigned int firstChannel, void *data, unsigned int channelCount );
00514
00518 void PaUtil_Set2ndNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
00519 unsigned int channel, void *data );
00520
00521
00533 void PaUtil_SetOutputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00534 unsigned long frameCount );
00535
00536
00542 void PaUtil_SetNoOutput( PaUtilBufferProcessor* bufferProcessor );
00543
00544
00554 void PaUtil_SetOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00555 unsigned int channel, void *data, unsigned int stride );
00556
00557
00568 void PaUtil_SetInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
00569 unsigned int firstChannel, void *data, unsigned int channelCount );
00570
00571
00579 void PaUtil_SetNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00580 unsigned int channel, void *data );
00581
00582
00586 void PaUtil_Set2ndOutputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00587 unsigned long frameCount );
00588
00592 void PaUtil_Set2ndOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00593 unsigned int channel, void *data, unsigned int stride );
00594
00598 void PaUtil_Set2ndInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
00599 unsigned int firstChannel, void *data, unsigned int channelCount );
00600
00604 void PaUtil_Set2ndNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00605 unsigned int channel, void *data );
00606
00613
00626 void PaUtil_BeginBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
00627 PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags callbackStatusFlags );
00628
00629
00653 unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
00654 int *callbackResult );
00655
00656
00668 int PaUtil_IsBufferProcessorOutputEmpty( PaUtilBufferProcessor* bufferProcessor );
00669
00676
00698 unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bufferProcessor,
00699 void **buffer, unsigned long frameCount );
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723 unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bufferProcessor,
00724 const void ** buffer, unsigned long frameCount );
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738 unsigned long PaUtil_ZeroOutput( PaUtilBufferProcessor* bufferProcessor,
00739 unsigned long frameCount );
00740
00741
00745 #ifdef __cplusplus
00746 }
00747 #endif
00748 #endif