PortAudio 2.0
pa_process.h
Go to the documentation of this file.
1#ifndef PA_PROCESS_H
2#define PA_PROCESS_H
3/*
4 * $Id$
5 * Portable Audio I/O Library callback buffer processing adapters
6 *
7 * Based on the Open Source API proposed by Ross Bencina
8 * Copyright (c) 1999-2002 Phil Burk, Ross Bencina
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files
12 * (the "Software"), to deal in the Software without restriction,
13 * including without limitation the rights to use, copy, modify, merge,
14 * publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so,
16 * subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
25 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30/*
31 * The text above constitutes the entire PortAudio license; however,
32 * the PortAudio community also makes the following non-binding requests:
33 *
34 * Any person wishing to distribute modifications to the Software is
35 * requested to send the modifications to the original developer so that
36 * they can be incorporated into the canonical version. It is also
37 * requested that these non-binding requests be included along with the
38 * license above.
39 */
40
203#include "portaudio.h"
204#include "pa_converters.h"
205#include "pa_dither.h"
206
207#ifdef __cplusplus
208extern "C"
209{
210#endif /* __cplusplus */
211
212
238
239
246
247
253typedef struct {
254 unsigned long framesPerUserBuffer;
255 unsigned long framesPerHostBuffer;
256
261 unsigned long framesPerTempBuffer;
262
263 unsigned int inputChannelCount;
269
270 unsigned int outputChannelCount;
276
279
289
291
293 unsigned long hostInputFrameCount[2];
294 PaUtilChannelDescriptor *hostInputChannels[2];
300 unsigned long hostOutputFrameCount[2];
301 PaUtilChannelDescriptor *hostOutputChannels[2];
308
310
312 void *userData;
314
315
318
378 int inputChannelCount, PaSampleFormat userInputSampleFormat,
379 PaSampleFormat hostInputSampleFormat,
380 int outputChannelCount, PaSampleFormat userOutputSampleFormat,
381 PaSampleFormat hostOutputSampleFormat,
382 double sampleRate,
383 PaStreamFlags streamFlags,
384 unsigned long framesPerUserBuffer, /* 0 indicates don't care */
385 unsigned long framesPerHostBuffer,
386 PaUtilHostBufferSizeMode hostBufferSizeMode,
387 PaStreamCallback *streamCallback, void *userData );
388
389
398
399
407
408
418
428
438
439
452 unsigned long frameCount );
453
454
462void PaUtil_SetNoInput( PaUtilBufferProcessor* bufferProcessor );
463
464
474void PaUtil_SetInputChannel( PaUtilBufferProcessor* bufferProcessor,
475 unsigned int channel, void *data, unsigned int stride );
476
477
489 unsigned int firstChannel, void *data, unsigned int channelCount );
490
491
500 unsigned int channel, void *data );
501
502
507 unsigned long frameCount );
508
513 unsigned int channel, void *data, unsigned int stride );
514
519 unsigned int firstChannel, void *data, unsigned int channelCount );
520
525 unsigned int channel, void *data );
526
527
540 unsigned long frameCount );
541
542
548void PaUtil_SetNoOutput( PaUtilBufferProcessor* bufferProcessor );
549
550
561 unsigned int channel, void *data, unsigned int stride );
562
563
575 unsigned int firstChannel, void *data, unsigned int channelCount );
576
577
586 unsigned int channel, void *data );
587
588
593 unsigned long frameCount );
594
599 unsigned int channel, void *data, unsigned int stride );
600
605 unsigned int firstChannel, void *data, unsigned int channelCount );
606
611 unsigned int channel, void *data );
612
619
633 PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags callbackStatusFlags );
634
635
659unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
660 int *callbackResult );
661
662
675
682
704unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bufferProcessor,
705 void **buffer, unsigned long frameCount );
706
707
708/* Copy samples from a user supplied buffer to host output channels set up by
709 the PaUtil_Set*OutputChannels functions. This function is intended for use with
710 blocking read/write streams. Copies the minimum of the number of
711 user frames (specified by the frameCount parameter) and the number of
712 host frames (specified in a previous call to SetOutputFrameCount()).
713
714 @param bufferProcessor The buffer processor.
715
716 @param buffer A pointer to the user buffer pointer, or a pointer to a pointer
717 to an array of user buffer pointers for a non-interleaved stream. It is
718 important that this parameter points to a copy of the user buffer pointers,
719 not to the actual user buffer pointers, because this function updates the
720 pointers before returning.
721
722 @param frameCount The number of frames of data in the buffer(s) pointed to by
723 the buffer parameter.
724
725 @return The number of frames copied. The buffer pointer(s) pointed to by the
726 buffer parameter are advanced to point to the frame(s) following the last one
727 copied.
728*/
729unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bufferProcessor,
730 const void ** buffer, unsigned long frameCount );
731
732
733/* Zero samples in host output channels set up by the PaUtil_Set*OutputChannels
734 functions. This function is useful for flushing streams.
735 Zeros the minimum of frameCount and the number of host frames specified in a
736 previous call to SetOutputFrameCount().
737
738 @param bufferProcessor The buffer processor.
739
740 @param frameCount The maximum number of frames to zero.
741
742 @return The number of frames zeroed.
743*/
744unsigned long PaUtil_ZeroOutput( PaUtilBufferProcessor* bufferProcessor,
745 unsigned long frameCount );
746
747
751#ifdef __cplusplus
752}
753#endif /* __cplusplus */
754#endif /* PA_PROCESS_H */
Conversion functions used to convert buffers of samples from one format to another.
void PaUtilConverter(void *destinationBuffer, signed int destinationStride, void *sourceBuffer, signed int sourceStride, unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator)
Definition pa_converters.h:90
void PaUtilZeroer(void *destinationBuffer, signed int destinationStride, unsigned int count)
Definition pa_converters.h:119
Functions for generating dither noise.
PaUtilHostBufferSizeMode
Mode flag passed to PaUtil_InitializeBufferProcessor indicating the type of buffering that the host A...
Definition pa_process.h:219
@ paUtilBoundedHostBufferSize
Definition pa_process.h:224
@ paUtilUnknownHostBufferSize
Definition pa_process.h:227
@ paUtilFixedHostBufferSize
Definition pa_process.h:221
@ paUtilVariableHostBufferSizePartialUsageAllowed
Definition pa_process.h:236
void PaUtil_Set2ndOutputFrameCount(PaUtilBufferProcessor *bufferProcessor, unsigned long frameCount)
Definition pa_process.c:625
void PaUtil_SetNonInterleavedInputChannel(PaUtilBufferProcessor *bufferProcessor, unsigned int channel, void *data)
Definition pa_process.c:500
void PaUtil_SetInterleavedOutputChannels(PaUtilBufferProcessor *bufferProcessor, unsigned int firstChannel, void *data, unsigned int channelCount)
Definition pa_process.c:593
void PaUtil_Set2ndInputFrameCount(PaUtilBufferProcessor *bufferProcessor, unsigned long frameCount)
Definition pa_process.c:511
void PaUtil_SetNoInput(PaUtilBufferProcessor *bufferProcessor)
Definition pa_process.c:459
unsigned long PaUtil_GetBufferProcessorInputLatencyFrames(PaUtilBufferProcessor *bufferProcessor)
Definition pa_process.c:437
void PaUtil_SetInputFrameCount(PaUtilBufferProcessor *bufferProcessor, unsigned long frameCount)
Definition pa_process.c:449
unsigned long PaUtil_ZeroOutput(PaUtilBufferProcessor *bufferProcessor, unsigned long frameCount)
Definition pa_process.c:1813
void PaUtil_ResetBufferProcessor(PaUtilBufferProcessor *bufferProcessor)
Definition pa_process.c:414
void PaUtil_Set2ndNonInterleavedInputChannel(PaUtilBufferProcessor *bufferProcessor, unsigned int channel, void *data)
Definition pa_process.c:551
void PaUtil_SetOutputChannel(PaUtilBufferProcessor *bufferProcessor, unsigned int channel, void *data, unsigned int stride)
Definition pa_process.c:582
void PaUtil_SetNonInterleavedOutputChannel(PaUtilBufferProcessor *bufferProcessor, unsigned int channel, void *data)
Definition pa_process.c:615
void PaUtil_Set2ndInputChannel(PaUtilBufferProcessor *bufferProcessor, unsigned int channel, void *data, unsigned int stride)
Definition pa_process.c:518
void PaUtil_Set2ndInterleavedOutputChannels(PaUtilBufferProcessor *bufferProcessor, unsigned int firstChannel, void *data, unsigned int channelCount)
Definition pa_process.c:643
unsigned long PaUtil_GetBufferProcessorOutputLatencyFrames(PaUtilBufferProcessor *bufferProcessor)
Definition pa_process.c:443
void PaUtil_SetInputChannel(PaUtilBufferProcessor *bufferProcessor, unsigned int channel, void *data, unsigned int stride)
Definition pa_process.c:467
unsigned long PaUtil_CopyInput(PaUtilBufferProcessor *bufferProcessor, void **buffer, unsigned long frameCount)
Definition pa_process.c:1668
int PaUtil_IsBufferProcessorOutputEmpty(PaUtilBufferProcessor *bufferProcessor)
Definition pa_process.c:1662
void PaUtil_SetOutputFrameCount(PaUtilBufferProcessor *bufferProcessor, unsigned long frameCount)
Definition pa_process.c:562
struct PaUtilChannelDescriptor PaUtilChannelDescriptor
An auxiliary data structure used internally by the buffer processor to represent host input and outpu...
void PaUtil_SetInterleavedInputChannels(PaUtilBufferProcessor *bufferProcessor, unsigned int firstChannel, void *data, unsigned int channelCount)
Definition pa_process.c:477
void PaUtil_Set2ndNonInterleavedOutputChannel(PaUtilBufferProcessor *bufferProcessor, unsigned int channel, void *data)
Definition pa_process.c:665
void PaUtil_SetNoOutput(PaUtilBufferProcessor *bufferProcessor)
Definition pa_process.c:572
void PaUtil_Set2ndInterleavedInputChannels(PaUtilBufferProcessor *bufferProcessor, unsigned int firstChannel, void *data, unsigned int channelCount)
Definition pa_process.c:528
void PaUtil_Set2ndOutputChannel(PaUtilBufferProcessor *bufferProcessor, unsigned int channel, void *data, unsigned int stride)
Definition pa_process.c:632
PaError PaUtil_InitializeBufferProcessor(PaUtilBufferProcessor *bufferProcessor, int inputChannelCount, PaSampleFormat userInputSampleFormat, PaSampleFormat hostInputSampleFormat, int outputChannelCount, PaSampleFormat userOutputSampleFormat, PaSampleFormat hostOutputSampleFormat, double sampleRate, PaStreamFlags streamFlags, unsigned long framesPerUserBuffer, unsigned long framesPerHostBuffer, PaUtilHostBufferSizeMode hostBufferSizeMode, PaStreamCallback *streamCallback, void *userData)
Definition pa_process.c:90
void PaUtil_BeginBufferProcessing(PaUtilBufferProcessor *bufferProcessor, PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags callbackStatusFlags)
Definition pa_process.c:675
unsigned long PaUtil_CopyOutput(PaUtilBufferProcessor *bufferProcessor, const void **buffer, unsigned long frameCount)
Definition pa_process.c:1739
void PaUtil_TerminateBufferProcessor(PaUtilBufferProcessor *bufferProcessor)
Definition pa_process.c:392
unsigned long PaUtil_EndBufferProcessing(PaUtilBufferProcessor *bufferProcessor, int *callbackResult)
Definition pa_process.c:1490
The portable PortAudio API.
unsigned long PaStreamFlags
Definition portaudio.h:662
unsigned long PaSampleFormat
Definition portaudio.h:489
int PaError
Definition portaudio.h:122
unsigned long PaStreamCallbackFlags
Definition portaudio.h:721
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition portaudio.h:839
char buffer[NUM_BYTES]
Definition recplay.c:26
Definition portaudio.h:708
The main buffer processor data structure.
Definition pa_process.h:253
PaUtilZeroer * inputZeroer
Definition pa_process.h:268
int userInputIsInterleaved
Definition pa_process.h:266
PaUtilTriangularDitherGenerator ditherGenerator
Definition pa_process.h:307
PaUtilZeroer * outputZeroer
Definition pa_process.h:275
PaStreamCallbackFlags callbackStatusFlags
Definition pa_process.h:290
unsigned long framesPerUserBuffer
Definition pa_process.h:254
void * tempInputBuffer
Definition pa_process.h:280
int hostOutputIsInterleaved
Definition pa_process.h:299
int userOutputIsInterleaved
Definition pa_process.h:273
unsigned long initialFramesInTempInputBuffer
Definition pa_process.h:277
unsigned long framesPerTempBuffer
Definition pa_process.h:261
int useNonAdaptingProcess
Definition pa_process.h:258
int hostInputIsInterleaved
Definition pa_process.h:292
void * tempOutputBuffer
Definition pa_process.h:284
PaUtilHostBufferSizeMode hostBufferSizeMode
Definition pa_process.h:257
unsigned long framesInTempOutputBuffer
Definition pa_process.h:286
int userInputSampleFormatIsEqualToHost
Definition pa_process.h:260
unsigned int inputChannelCount
Definition pa_process.h:263
void ** tempOutputBufferPtrs
Definition pa_process.h:285
unsigned int bytesPerHostOutputSample
Definition pa_process.h:271
unsigned long framesInTempInputBuffer
Definition pa_process.h:282
PaUtilConverter * inputConverter
Definition pa_process.h:267
void * userData
Definition pa_process.h:312
unsigned int bytesPerUserOutputSample
Definition pa_process.h:272
unsigned int bytesPerUserInputSample
Definition pa_process.h:265
PaUtilConverter * outputConverter
Definition pa_process.h:274
void ** tempInputBufferPtrs
Definition pa_process.h:281
int userOutputSampleFormatIsEqualToHost
Definition pa_process.h:259
unsigned int bytesPerHostInputSample
Definition pa_process.h:264
PaStreamCallbackTimeInfo * timeInfo
Definition pa_process.h:288
double samplePeriod
Definition pa_process.h:309
unsigned long initialFramesInTempOutputBuffer
Definition pa_process.h:278
unsigned long framesPerHostBuffer
Definition pa_process.h:255
unsigned int outputChannelCount
Definition pa_process.h:270
PaStreamCallback * streamCallback
Definition pa_process.h:311
An auxiliary data structure used internally by the buffer processor to represent host input and outpu...
Definition pa_process.h:242
void * data
Definition pa_process.h:243
unsigned int stride
Definition pa_process.h:244
State needed to generate a dither signal.
Definition pa_dither.h:61