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 unsigned long framesPerTempBuffer;
00260
00261 unsigned int inputChannelCount;
00262 unsigned int bytesPerHostInputSample;
00263 unsigned int bytesPerUserInputSample;
00264 int userInputIsInterleaved;
00265 PaUtilConverter *inputConverter;
00266 PaUtilZeroer *inputZeroer;
00267
00268 unsigned int outputChannelCount;
00269 unsigned int bytesPerHostOutputSample;
00270 unsigned int bytesPerUserOutputSample;
00271 int userOutputIsInterleaved;
00272 PaUtilConverter *outputConverter;
00273 PaUtilZeroer *outputZeroer;
00274
00275 unsigned long initialFramesInTempInputBuffer;
00276 unsigned long initialFramesInTempOutputBuffer;
00277
00278 void *tempInputBuffer;
00279 void **tempInputBufferPtrs;
00280 unsigned long framesInTempInputBuffer;
00282 void *tempOutputBuffer;
00283 void **tempOutputBufferPtrs;
00284 unsigned long framesInTempOutputBuffer;
00286 PaStreamCallbackTimeInfo *timeInfo;
00287
00288 PaStreamCallbackFlags callbackStatusFlags;
00289
00290 unsigned long hostInputFrameCount[2];
00291 PaUtilChannelDescriptor *hostInputChannels[2];
00296 unsigned long hostOutputFrameCount[2];
00297 PaUtilChannelDescriptor *hostOutputChannels[2];
00303 PaUtilTriangularDitherGenerator ditherGenerator;
00304
00305 double samplePeriod;
00306
00307 PaStreamCallback *streamCallback;
00308 void *userData;
00309 } PaUtilBufferProcessor;
00310
00311
00314
00373 PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bufferProcessor,
00374 int inputChannelCount, PaSampleFormat userInputSampleFormat,
00375 PaSampleFormat hostInputSampleFormat,
00376 int outputChannelCount, PaSampleFormat userOutputSampleFormat,
00377 PaSampleFormat hostOutputSampleFormat,
00378 double sampleRate,
00379 PaStreamFlags streamFlags,
00380 unsigned long framesPerUserBuffer,
00381 unsigned long framesPerHostBuffer,
00382 PaUtilHostBufferSizeMode hostBufferSizeMode,
00383 PaStreamCallback *streamCallback, void *userData );
00384
00385
00393 void PaUtil_TerminateBufferProcessor( PaUtilBufferProcessor* bufferProcessor );
00394
00395
00402 void PaUtil_ResetBufferProcessor( PaUtilBufferProcessor* bufferProcessor );
00403
00404
00413 unsigned long PaUtil_GetBufferProcessorInputLatency( PaUtilBufferProcessor* bufferProcessor );
00414
00423 unsigned long PaUtil_GetBufferProcessorOutputLatency( PaUtilBufferProcessor* bufferProcessor );
00424
00434
00435
00447 void PaUtil_SetInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00448 unsigned long frameCount );
00449
00450
00458 void PaUtil_SetNoInput( PaUtilBufferProcessor* bufferProcessor );
00459
00460
00470 void PaUtil_SetInputChannel( PaUtilBufferProcessor* bufferProcessor,
00471 unsigned int channel, void *data, unsigned int stride );
00472
00473
00484 void PaUtil_SetInterleavedInputChannels( PaUtilBufferProcessor* bufferProcessor,
00485 unsigned int firstChannel, void *data, unsigned int channelCount );
00486
00487
00495 void PaUtil_SetNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
00496 unsigned int channel, void *data );
00497
00498
00502 void PaUtil_Set2ndInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00503 unsigned long frameCount );
00504
00508 void PaUtil_Set2ndInputChannel( PaUtilBufferProcessor* bufferProcessor,
00509 unsigned int channel, void *data, unsigned int stride );
00510
00514 void PaUtil_Set2ndInterleavedInputChannels( PaUtilBufferProcessor* bufferProcessor,
00515 unsigned int firstChannel, void *data, unsigned int channelCount );
00516
00520 void PaUtil_Set2ndNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
00521 unsigned int channel, void *data );
00522
00523
00535 void PaUtil_SetOutputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00536 unsigned long frameCount );
00537
00538
00544 void PaUtil_SetNoOutput( PaUtilBufferProcessor* bufferProcessor );
00545
00546
00556 void PaUtil_SetOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00557 unsigned int channel, void *data, unsigned int stride );
00558
00559
00570 void PaUtil_SetInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
00571 unsigned int firstChannel, void *data, unsigned int channelCount );
00572
00573
00581 void PaUtil_SetNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00582 unsigned int channel, void *data );
00583
00584
00588 void PaUtil_Set2ndOutputFrameCount( PaUtilBufferProcessor* bufferProcessor,
00589 unsigned long frameCount );
00590
00594 void PaUtil_Set2ndOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00595 unsigned int channel, void *data, unsigned int stride );
00596
00600 void PaUtil_Set2ndInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
00601 unsigned int firstChannel, void *data, unsigned int channelCount );
00602
00606 void PaUtil_Set2ndNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProcessor,
00607 unsigned int channel, void *data );
00608
00615
00628 void PaUtil_BeginBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
00629 PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags callbackStatusFlags );
00630
00631
00655 unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
00656 int *callbackResult );
00657
00658
00670 int PaUtil_IsBufferProcessorOutputEmpty( PaUtilBufferProcessor* bufferProcessor );
00671
00678
00700 unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bufferProcessor,
00701 void **buffer, unsigned long frameCount );
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725 unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bufferProcessor,
00726 const void ** buffer, unsigned long frameCount );
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740 unsigned long PaUtil_ZeroOutput( PaUtilBufferProcessor* bufferProcessor,
00741 unsigned long frameCount );
00742
00743
00747 #ifdef __cplusplus
00748 }
00749 #endif
00750 #endif