pa_process.h

Go to the documentation of this file.
00001 #ifndef PA_PROCESS_H
00002 #define PA_PROCESS_H
00003 /*
00004  * $Id: pa_process.h 1083 2006-08-23 07:30:49Z rossb $
00005  * Portable Audio I/O Library callback buffer processing adapters
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  
00201 #include "portaudio.h"
00202 #include "pa_converters.h"
00203 #include "pa_dither.h"
00204 
00205 #ifdef __cplusplus
00206 extern "C"
00207 {
00208 #endif /* __cplusplus */
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, /* 0 indicates don't care */
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 /* Copy samples from a user supplied buffer to host output channels set up by
00703  the PaUtil_Set*OutputChannels functions. This function is intended for use with
00704  blocking read/write streams. Copies the minimum of the number of
00705  user frames (specified by the frameCount parameter) and the number of
00706  host frames (specified in a previous call to SetOutputFrameCount()).
00707 
00708  @param bufferProcessor The buffer processor.
00709 
00710  @param buffer A pointer to the user buffer pointer, or a pointer to a pointer
00711  to an array of user buffer pointers for a non-interleaved stream. It is
00712  important that this parameter points to a copy of the user buffer pointers,
00713  not to the actual user buffer pointers, because this function updates the
00714  pointers before returning.
00715 
00716  @param frameCount The number of frames of data in the buffer(s) pointed to by
00717  the buffer parameter.
00718 
00719  @return The number of frames copied. The buffer pointer(s) pointed to by the
00720  buffer parameter are advanced to point to the frame(s) following the last one
00721  copied.
00722 */
00723 unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bufferProcessor,
00724         const void ** buffer, unsigned long frameCount );
00725 
00726 
00727 /* Zero samples in host output channels set up by the PaUtil_Set*OutputChannels
00728  functions. This function is useful for flushing streams.
00729  Zeros the minimum of frameCount and the number of host frames specified in a
00730  previous call to SetOutputFrameCount().
00731 
00732  @param bufferProcessor The buffer processor.
00733 
00734  @param frameCount The maximum number of frames to zero.
00735  
00736  @return The number of frames zeroed.
00737 */
00738 unsigned long PaUtil_ZeroOutput( PaUtilBufferProcessor* bufferProcessor,
00739         unsigned long frameCount );
00740 
00741 
00745 #ifdef __cplusplus
00746 }
00747 #endif /* __cplusplus */
00748 #endif /* PA_PROCESS_H */

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