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
00203 #include "portaudio.h"
00204 #include "pa_converters.h"
00205 #include "pa_dither.h"
00206
00207 #ifdef __cplusplus
00208 extern "C"
00209 {
00210 #endif
00211
00212
00219 typedef enum {
00221 paUtilFixedHostBufferSize,
00222
00224 paUtilBoundedHostBufferSize,
00225
00227 paUtilUnknownHostBufferSize,
00228
00236 paUtilVariableHostBufferSizePartialUsageAllowed
00237 }PaUtilHostBufferSizeMode;
00238
00239
00242 typedef struct PaUtilChannelDescriptor{
00243 void *data;
00244 unsigned int stride;
00245 }PaUtilChannelDescriptor;
00246
00247
00253 typedef struct {
00254 unsigned long framesPerUserBuffer;
00255 unsigned long framesPerHostBuffer;
00256
00257 PaUtilHostBufferSizeMode hostBufferSizeMode;
00258 int useNonAdaptingProcess;
00259 int userOutputSampleFormatIsEqualToHost;
00260 int userInputSampleFormatIsEqualToHost;
00261 unsigned long framesPerTempBuffer;
00262
00263 unsigned int inputChannelCount;
00264 unsigned int bytesPerHostInputSample;
00265 unsigned int bytesPerUserInputSample;
00266 int userInputIsInterleaved;
00267 PaUtilConverter *inputConverter;
00268 PaUtilZeroer *inputZeroer;
00269
00270 unsigned int outputChannelCount;
00271 unsigned int bytesPerHostOutputSample;
00272 unsigned int bytesPerUserOutputSample;
00273 int userOutputIsInterleaved;
00274 PaUtilConverter *outputConverter;
00275 PaUtilZeroer *outputZeroer;
00276
00277 unsigned long initialFramesInTempInputBuffer;
00278 unsigned long initialFramesInTempOutputBuffer;
00279
00280 void *tempInputBuffer;
00281 void **tempInputBufferPtrs;
00282 unsigned long framesInTempInputBuffer;
00284 void *tempOutputBuffer;
00285 void **tempOutputBufferPtrs;
00286 unsigned long framesInTempOutputBuffer;
00288 PaStreamCallbackTimeInfo *timeInfo;
00289
00290 PaStreamCallbackFlags callbackStatusFlags;
00291
00292 int hostInputIsInterleaved;
00293 unsigned long hostInputFrameCount[2];
00294 PaUtilChannelDescriptor *hostInputChannels[2];
00299 int hostOutputIsInterleaved;
00300 unsigned long hostOutputFrameCount[2];
00301 PaUtilChannelDescriptor *hostOutputChannels[2];
00307 PaUtilTriangularDitherGenerator ditherGenerator;
00308
00309 double samplePeriod;
00310
00311 PaStreamCallback *streamCallback;
00312 void *userData;
00313 } PaUtilBufferProcessor;
00314
00315
00318
00377 PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bufferProcessor,
00378 int inputChannelCount, PaSampleFormat userInputSampleFormat,
00379 PaSampleFormat hostInputSampleFormat,
00380 int outputChannelCount, PaSampleFormat userOutputSampleFormat,
00381 PaSampleFormat hostOutputSampleFormat,
00382 double sampleRate,
00383 PaStreamFlags streamFlags,
00384 unsigned long framesPerUserBuffer,
00385 unsigned long framesPerHostBuffer,
00386 PaUtilHostBufferSizeMode hostBufferSizeMode,
00387 PaStreamCallback *streamCallback, void *userData );
00388
00389
00397 void PaUtil_TerminateBufferProcessor( PaUtilBufferProcessor* bufferProcessor );
00398
00399
00406 void PaUtil_ResetBufferProcessor( PaUtilBufferProcessor* bufferProcessor );
00407
00408
00417 unsigned long PaUtil_GetBufferProcessorInputLatency( PaUtilBufferProcessor* bufferProcessor );
00418
00427 unsigned long PaUtil_GetBufferProcessorOutputLatency( PaUtilBufferProcessor* bufferProcessor );
00428
00438
00439
00451 void PaUtil_SetInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00452 unsigned long frameCount );
00453
00454
00462 void PaUtil_SetNoInput( PaUtilBufferProcessor* bufferProcessor );
00463
00464
00474 void PaUtil_SetInputChannel( PaUtilBufferProcessor* bufferProcessor,
00475 unsigned int channel, void *data, unsigned int stride );
00476
00477
00488 void PaUtil_SetInterleavedInputChannels( PaUtilBufferProcessor* bufferProcessor,
00489 unsigned int firstChannel, void *data, unsigned int channelCount );
00490
00491
00499 void PaUtil_SetNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
00500 unsigned int channel, void *data );
00501
00502
00506 void PaUtil_Set2ndInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00507 unsigned long frameCount );
00508
00512 void PaUtil_Set2ndInputChannel( PaUtilBufferProcessor* bufferProcessor,
00513 unsigned int channel, void *data, unsigned int stride );
00514
00518 void PaUtil_Set2ndInterleavedInputChannels( PaUtilBufferProcessor* bufferProcessor,
00519 unsigned int firstChannel, void *data, unsigned int channelCount );
00520
00524 void PaUtil_Set2ndNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
00525 unsigned int channel, void *data );
00526
00527
00539 void PaUtil_SetOutputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00540 unsigned long frameCount );
00541
00542
00548 void PaUtil_SetNoOutput( PaUtilBufferProcessor* bufferProcessor );
00549
00550
00560 void PaUtil_SetOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00561 unsigned int channel, void *data, unsigned int stride );
00562
00563
00574 void PaUtil_SetInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
00575 unsigned int firstChannel, void *data, unsigned int channelCount );
00576
00577
00585 void PaUtil_SetNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00586 unsigned int channel, void *data );
00587
00588
00592 void PaUtil_Set2ndOutputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00593 unsigned long frameCount );
00594
00598 void PaUtil_Set2ndOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00599 unsigned int channel, void *data, unsigned int stride );
00600
00604 void PaUtil_Set2ndInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
00605 unsigned int firstChannel, void *data, unsigned int channelCount );
00606
00610 void PaUtil_Set2ndNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00611 unsigned int channel, void *data );
00612
00619
00632 void PaUtil_BeginBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
00633 PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags callbackStatusFlags );
00634
00635
00659 unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
00660 int *callbackResult );
00661
00662
00674 int PaUtil_IsBufferProcessorOutputEmpty( PaUtilBufferProcessor* bufferProcessor );
00675
00682
00704 unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bufferProcessor,
00705 void **buffer, unsigned long frameCount );
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729 unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bufferProcessor,
00730 const void ** buffer, unsigned long frameCount );
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744 unsigned long PaUtil_ZeroOutput( PaUtilBufferProcessor* bufferProcessor,
00745 unsigned long frameCount );
00746
00747
00751 #ifdef __cplusplus
00752 }
00753 #endif
00754 #endif