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

Generated on Sun Feb 3 05:57:02 2008 for PortAudio by  doxygen 1.5.4