Jamoma API  0.6.0.a19
portaudio.h
Go to the documentation of this file.
1 #ifndef PORTAUDIO_H
2 #define PORTAUDIO_H
3 /*
4  * $Id: portaudio.h 1247 2007-08-11 16:29:09Z rossb $
5  * PortAudio Portable Real-Time Audio Library
6  * PortAudio API Header File
7  * Latest version available at: http://www.portaudio.com/
8  *
9  * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files
13  * (the "Software"), to deal in the Software without restriction,
14  * including without limitation the rights to use, copy, modify, merge,
15  * publish, distribute, sublicense, and/or sell copies of the Software,
16  * and to permit persons to whom the Software is furnished to do so,
17  * subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29  */
30 
31 /*
32  * The text above constitutes the entire PortAudio license; however,
33  * the PortAudio community also makes the following non-binding requests:
34  *
35  * Any person wishing to distribute modifications to the Software is
36  * requested to send the modifications to the original developer so that
37  * they can be incorporated into the canonical version. It is also
38  * requested that these non-binding requests be included along with the
39  * license above.
40  */
41 
42 /** @file
43  @brief The PortAudio API.
44 */
45 
46 
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif /* __cplusplus */
51 
52 
53 /** Retrieve the release number of the currently running PortAudio build,
54  eg 1900.
55 */
56 int Pa_GetVersion( void );
57 
58 
59 /** Retrieve a textual description of the current PortAudio build,
60  eg "PortAudio V19-devel 13 October 2002".
61 */
62 const char* Pa_GetVersionText( void );
63 
64 
65 /** Error codes returned by PortAudio functions.
66  Note that with the exception of paNoError, all PaErrorCodes are negative.
67 */
68 
69 typedef int PaError;
70 typedef enum PaErrorCode
71 {
72  paNoError = 0,
73 
74  paNotInitialized = -10000,
75  paUnanticipatedHostError,
76  paInvalidChannelCount,
77  paInvalidSampleRate,
78  paInvalidDevice,
79  paInvalidFlag,
80  paSampleFormatNotSupported,
81  paBadIODeviceCombination,
82  paInsufficientMemory,
83  paBufferTooBig,
84  paBufferTooSmall,
85  paNullCallback,
86  paBadStreamPtr,
87  paTimedOut,
88  paInternalError,
89  paDeviceUnavailable,
90  paIncompatibleHostApiSpecificStreamInfo,
91  paStreamIsStopped,
92  paStreamIsNotStopped,
93  paInputOverflowed,
94  paOutputUnderflowed,
95  paHostApiNotFound,
96  paInvalidHostApi,
97  paCanNotReadFromACallbackStream, /**< @todo review error code name */
98  paCanNotWriteToACallbackStream, /**< @todo review error code name */
99  paCanNotReadFromAnOutputOnlyStream, /**< @todo review error code name */
100  paCanNotWriteToAnInputOnlyStream, /**< @todo review error code name */
101  paIncompatibleStreamHostApi,
102  paBadBufferPtr
103 } PaErrorCode;
104 
105 
106 /** Translate the supplied PortAudio error code into a human readable
107  message.
108 */
109 const char *Pa_GetErrorText( PaError errorCode );
110 
111 
112 /** Library initialization function - call this before using PortAudio.
113  This function initialises internal data structures and prepares underlying
114  host APIs for use. With the exception of Pa_GetVersion(), Pa_GetVersionText(),
115  and Pa_GetErrorText(), this function MUST be called before using any other
116  PortAudio API functions.
117 
118  If Pa_Initialize() is called multiple times, each successful
119  call must be matched with a corresponding call to Pa_Terminate().
120  Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not
121  required to be fully nested.
122 
123  Note that if Pa_Initialize() returns an error code, Pa_Terminate() should
124  NOT be called.
125 
126  @return paNoError if successful, otherwise an error code indicating the cause
127  of failure.
128 
129  @see Pa_Terminate
130 */
131 PaError Pa_Initialize( void );
132 
133 
134 /** Library termination function - call this when finished using PortAudio.
135  This function deallocates all resources allocated by PortAudio since it was
136  initializied by a call to Pa_Initialize(). In cases where Pa_Initialise() has
137  been called multiple times, each call must be matched with a corresponding call
138  to Pa_Terminate(). The final matching call to Pa_Terminate() will automatically
139  close any PortAudio streams that are still open.
140 
141  Pa_Terminate() MUST be called before exiting a program which uses PortAudio.
142  Failure to do so may result in serious resource leaks, such as audio devices
143  not being available until the next reboot.
144 
145  @return paNoError if successful, otherwise an error code indicating the cause
146  of failure.
147 
148  @see Pa_Initialize
149 */
150 PaError Pa_Terminate( void );
151 
152 
153 
154 /** The type used to refer to audio devices. Values of this type usually
155  range from 0 to (Pa_GetDeviceCount()-1), and may also take on the PaNoDevice
156  and paUseHostApiSpecificDeviceSpecification values.
157 
158  @see Pa_GetDeviceCount, paNoDevice, paUseHostApiSpecificDeviceSpecification
159 */
160 typedef int PaDeviceIndex;
161 
162 
163 /** A special PaDeviceIndex value indicating that no device is available,
164  or should be used.
165 
166  @see PaDeviceIndex
167 */
168 #define paNoDevice ((PaDeviceIndex)-1)
169 
170 
171 /** A special PaDeviceIndex value indicating that the device(s) to be used
172  are specified in the host api specific stream info structure.
173 
174  @see PaDeviceIndex
175 */
176 #define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
177 
178 
179 /* Host API enumeration mechanism */
180 
181 /** The type used to enumerate to host APIs at runtime. Values of this type
182  range from 0 to (Pa_GetHostApiCount()-1).
183 
184  @see Pa_GetHostApiCount
185 */
186 typedef int PaHostApiIndex;
187 
188 
189 /** Retrieve the number of available host APIs. Even if a host API is
190  available it may have no devices available.
191 
192  @return A non-negative value indicating the number of available host APIs
193  or, a PaErrorCode (which are always negative) if PortAudio is not initialized
194  or an error is encountered.
195 
196  @see PaHostApiIndex
197 */
198 PaHostApiIndex Pa_GetHostApiCount( void );
199 
200 
201 /** Retrieve the index of the default host API. The default host API will be
202  the lowest common denominator host API on the current platform and is
203  unlikely to provide the best performance.
204 
205  @return A non-negative value ranging from 0 to (Pa_GetHostApiCount()-1)
206  indicating the default host API index or, a PaErrorCode (which are always
207  negative) if PortAudio is not initialized or an error is encountered.
208 */
209 PaHostApiIndex Pa_GetDefaultHostApi( void );
210 
211 
212 /** Unchanging unique identifiers for each supported host API. This type
213  is used in the PaHostApiInfo structure. The values are guaranteed to be
214  unique and to never change, thus allowing code to be written that
215  conditionally uses host API specific extensions.
216 
217  New type ids will be allocated when support for a host API reaches
218  "public alpha" status, prior to that developers should use the
219  paInDevelopment type id.
220 
221  @see PaHostApiInfo
222 */
223 typedef enum PaHostApiTypeId
224 {
225  paInDevelopment=0, /* use while developing support for a new host API */
226  paDirectSound=1,
227  paMME=2,
228  paASIO=3,
229  paSoundManager=4,
230  paCoreAudio=5,
231  paOSS=7,
232  paALSA=8,
233  paAL=9,
234  paBeOS=10,
235  paWDMKS=11,
236  paJACK=12,
237  paWASAPI=13,
238  paAudioScienceHPI=14
240 
241 
242 /** A structure containing information about a particular host API. */
243 
244 typedef struct PaHostApiInfo
245 {
246  /** this is struct version 1 */
248  /** The well known unique identifier of this host API @see PaHostApiTypeId */
250  /** A textual description of the host API for display on user interfaces. */
251  const char *name;
252 
253  /** The number of devices belonging to this host API. This field may be
254  used in conjunction with Pa_HostApiDeviceIndexToDeviceIndex() to enumerate
255  all devices for this host API.
256  @see Pa_HostApiDeviceIndexToDeviceIndex
257  */
259 
260  /** The default input device for this host API. The value will be a
261  device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice
262  if no default input device is available.
263  */
264  PaDeviceIndex defaultInputDevice;
265 
266  /** The default output device for this host API. The value will be a
267  device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice
268  if no default output device is available.
269  */
270  PaDeviceIndex defaultOutputDevice;
271 
272 } PaHostApiInfo;
273 
274 
275 /** Retrieve a pointer to a structure containing information about a specific
276  host Api.
277 
278  @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1)
279 
280  @return A pointer to an immutable PaHostApiInfo structure describing
281  a specific host API. If the hostApi parameter is out of range or an error
282  is encountered, the function returns NULL.
283 
284  The returned structure is owned by the PortAudio implementation and must not
285  be manipulated or freed. The pointer is only guaranteed to be valid between
286  calls to Pa_Initialize() and Pa_Terminate().
287 */
288 const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
289 
290 
291 /** Convert a static host API unique identifier, into a runtime
292  host API index.
293 
294  @param type A unique host API identifier belonging to the PaHostApiTypeId
295  enumeration.
296 
297  @return A valid PaHostApiIndex ranging from 0 to (Pa_GetHostApiCount()-1) or,
298  a PaErrorCode (which are always negative) if PortAudio is not initialized
299  or an error is encountered.
300 
301  The paHostApiNotFound error code indicates that the host API specified by the
302  type parameter is not available.
303 
304  @see PaHostApiTypeId
305 */
306 PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
307 
308 
309 /** Convert a host-API-specific device index to standard PortAudio device index.
310  This function may be used in conjunction with the deviceCount field of
311  PaHostApiInfo to enumerate all devices for the specified host API.
312 
313  @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1)
314 
315  @param hostApiDeviceIndex A valid per-host device index in the range
316  0 to (Pa_GetHostApiInfo(hostApi)->deviceCount-1)
317 
318  @return A non-negative PaDeviceIndex ranging from 0 to (Pa_GetDeviceCount()-1)
319  or, a PaErrorCode (which are always negative) if PortAudio is not initialized
320  or an error is encountered.
321 
322  A paInvalidHostApi error code indicates that the host API index specified by
323  the hostApi parameter is out of range.
324 
325  A paInvalidDevice error code indicates that the hostApiDeviceIndex parameter
326  is out of range.
327 
328  @see PaHostApiInfo
329 */
330 PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
331  int hostApiDeviceIndex );
332 
333 
334 
335 /** Structure used to return information about a host error condition.
336 */
337 typedef struct PaHostErrorInfo{
338  PaHostApiTypeId hostApiType; /**< the host API which returned the error code */
339  long errorCode; /**< the error code returned */
340  const char *errorText; /**< a textual description of the error if available, otherwise a zero-length string */
342 
343 
344 /** Return information about the last host error encountered. The error
345  information returned by Pa_GetLastHostErrorInfo() will never be modified
346  asyncronously by errors occurring in other PortAudio owned threads
347  (such as the thread that manages the stream callback.)
348 
349  This function is provided as a last resort, primarily to enhance debugging
350  by providing clients with access to all available error information.
351 
352  @return A pointer to an immutable structure constaining information about
353  the host error. The values in this structure will only be valid if a
354  PortAudio function has previously returned the paUnanticipatedHostError
355  error code.
356 */
358 
359 
360 
361 /* Device enumeration and capabilities */
362 
363 /** Retrieve the number of available devices. The number of available devices
364  may be zero.
365 
366  @return A non-negative value indicating the number of available devices or,
367  a PaErrorCode (which are always negative) if PortAudio is not initialized
368  or an error is encountered.
369 */
370 PaDeviceIndex Pa_GetDeviceCount( void );
371 
372 
373 /** Retrieve the index of the default input device. The result can be
374  used in the inputDevice parameter to Pa_OpenStream().
375 
376  @return The default input device index for the default host API, or paNoDevice
377  if no default input device is available or an error was encountered.
378 */
379 PaDeviceIndex Pa_GetDefaultInputDevice( void );
380 
381 
382 /** Retrieve the index of the default output device. The result can be
383  used in the outputDevice parameter to Pa_OpenStream().
384 
385  @return The default output device index for the defualt host API, or paNoDevice
386  if no default output device is available or an error was encountered.
387 
388  @note
389  On the PC, the user can specify a default device by
390  setting an environment variable. For example, to use device #1.
391 <pre>
392  set PA_RECOMMENDED_OUTPUT_DEVICE=1
393 </pre>
394  The user should first determine the available device ids by using
395  the supplied application "pa_devs".
396 */
397 PaDeviceIndex Pa_GetDefaultOutputDevice( void );
398 
399 
400 /** The type used to represent monotonic time in seconds that can be used
401  for syncronisation. The type is used for the outTime argument to the
402  PaStreamCallback and as the result of Pa_GetStreamTime().
403 
404  @see PaStreamCallback, Pa_GetStreamTime
405 */
406 typedef double PaTime;
407 
408 
409 /** A type used to specify one or more sample formats. Each value indicates
410  a possible format for sound data passed to and from the stream callback,
411  Pa_ReadStream and Pa_WriteStream.
412 
413  The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8
414  and aUInt8 are usually implemented by all implementations.
415 
416  The floating point representation (paFloat32) uses +1.0 and -1.0 as the
417  maximum and minimum respectively.
418 
419  paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
420 
421  The paNonInterleaved flag indicates that a multichannel buffer is passed
422  as a set of non-interleaved pointers.
423 
424  @see Pa_OpenStream, Pa_OpenDefaultStream, PaDeviceInfo
425  @see paFloat32, paInt16, paInt32, paInt24, paInt8
426  @see paUInt8, paCustomFormat, paNonInterleaved
427 */
428 typedef unsigned long PaSampleFormat;
429 
430 
431 #define paFloat32 ((PaSampleFormat) 0x00000001) /**< @see PaSampleFormat */
432 #define paInt32 ((PaSampleFormat) 0x00000002) /**< @see PaSampleFormat */
433 #define paInt24 ((PaSampleFormat) 0x00000004) /**< Packed 24 bit format. @see PaSampleFormat */
434 #define paInt16 ((PaSampleFormat) 0x00000008) /**< @see PaSampleFormat */
435 #define paInt8 ((PaSampleFormat) 0x00000010) /**< @see PaSampleFormat */
436 #define paUInt8 ((PaSampleFormat) 0x00000020) /**< @see PaSampleFormat */
437 #define paCustomFormat ((PaSampleFormat) 0x00010000)/**< @see PaSampleFormat */
438 
439 #define paNonInterleaved ((PaSampleFormat) 0x80000000)
440 
441 /** A structure providing information and capabilities of PortAudio devices.
442  Devices may support input, output or both input and output.
443 */
444 typedef struct PaDeviceInfo
445 {
446  int structVersion; /* this is struct version 2 */
447  const char *name;
448  PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/
449 
450  int maxInputChannels;
451  int maxOutputChannels;
452 
453  /* Default latency values for interactive performance. */
454  PaTime defaultLowInputLatency;
455  PaTime defaultLowOutputLatency;
456  /* Default latency values for robust non-interactive applications (eg. playing sound files). */
457  PaTime defaultHighInputLatency;
458  PaTime defaultHighOutputLatency;
459 
460  double defaultSampleRate;
461 } PaDeviceInfo;
462 
463 
464 /** Retrieve a pointer to a PaDeviceInfo structure containing information
465  about the specified device.
466  @return A pointer to an immutable PaDeviceInfo structure. If the device
467  parameter is out of range the function returns NULL.
468 
469  @param device A valid device index in the range 0 to (Pa_GetDeviceCount()-1)
470 
471  @note PortAudio manages the memory referenced by the returned pointer,
472  the client must not manipulate or free the memory. The pointer is only
473  guaranteed to be valid between calls to Pa_Initialize() and Pa_Terminate().
474 
475  @see PaDeviceInfo, PaDeviceIndex
476 */
477 const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceIndex device );
478 
479 
480 /** Parameters for one direction (input or output) of a stream.
481 */
482 typedef struct PaStreamParameters
483 {
484  /** A valid device index in the range 0 to (Pa_GetDeviceCount()-1)
485  specifying the device to be used or the special constant
486  paUseHostApiSpecificDeviceSpecification which indicates that the actual
487  device(s) to use are specified in hostApiSpecificStreamInfo.
488  This field must not be set to paNoDevice.
489  */
490  PaDeviceIndex device;
491 
492  /** The number of channels of sound to be delivered to the
493  stream callback or accessed by Pa_ReadStream() or Pa_WriteStream().
494  It can range from 1 to the value of maxInputChannels in the
495  PaDeviceInfo record for the device specified by the device parameter.
496  */
498 
499  /** The sample format of the buffer provided to the stream callback,
500  a_ReadStream() or Pa_WriteStream(). It may be any of the formats described
501  by the PaSampleFormat enumeration.
502  */
503  PaSampleFormat sampleFormat;
504 
505  /** The desired latency in seconds. Where practical, implementations should
506  configure their latency based on these parameters, otherwise they may
507  choose the closest viable latency instead. Unless the suggested latency
508  is greater than the absolute upper limit for the device implementations
509  should round the suggestedLatency up to the next practial value - ie to
510  provide an equal or higher latency than suggestedLatency wherever possibe.
511  Actual latency values for an open stream may be retrieved using the
512  inputLatency and outputLatency fields of the PaStreamInfo structure
513  returned by Pa_GetStreamInfo().
514  @see default*Latency in PaDeviceInfo, *Latency in PaStreamInfo
515  */
517 
518  /** An optional pointer to a host api specific data structure
519  containing additional information for device setup and/or stream processing.
520  hostApiSpecificStreamInfo is never required for correct operation,
521  if not used it should be set to NULL.
522  */
524 
526 
527 
528 /** Return code for Pa_IsFormatSupported indicating success. */
529 #define paFormatIsSupported (0)
530 
531 /** Determine whether it would be possible to open a stream with the specified
532  parameters.
533 
534  @param inputParameters A structure that describes the input parameters used to
535  open a stream. The suggestedLatency field is ignored. See PaStreamParameters
536  for a description of these parameters. inputParameters must be NULL for
537  output-only streams.
538 
539  @param outputParameters A structure that describes the output parameters used
540  to open a stream. The suggestedLatency field is ignored. See PaStreamParameters
541  for a description of these parameters. outputParameters must be NULL for
542  input-only streams.
543 
544  @param sampleRate The required sampleRate. For full-duplex streams it is the
545  sample rate for both input and output
546 
547  @return Returns 0 if the format is supported, and an error code indicating why
548  the format is not supported otherwise. The constant paFormatIsSupported is
549  provided to compare with the return value for success.
550 
551  @see paFormatIsSupported, PaStreamParameters
552 */
553 PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
554  const PaStreamParameters *outputParameters,
555  double sampleRate );
556 
557 
558 
559 /* Streaming types and functions */
560 
561 
562 /**
563  A single PaStream can provide multiple channels of real-time
564  streaming audio input and output to a client application. A stream
565  provides access to audio hardware represented by one or more
566  PaDevices. Depending on the underlying Host API, it may be possible
567  to open multiple streams using the same device, however this behavior
568  is implementation defined. Portable applications should assume that
569  a PaDevice may be simultaneously used by at most one PaStream.
570 
571  Pointers to PaStream objects are passed between PortAudio functions that
572  operate on streams.
573 
574  @see Pa_OpenStream, Pa_OpenDefaultStream, Pa_OpenDefaultStream, Pa_CloseStream,
575  Pa_StartStream, Pa_StopStream, Pa_AbortStream, Pa_IsStreamActive,
576  Pa_GetStreamTime, Pa_GetStreamCpuLoad
577 
578 */
579 typedef void PaStream;
580 
581 
582 /** Can be passed as the framesPerBuffer parameter to Pa_OpenStream()
583  or Pa_OpenDefaultStream() to indicate that the stream callback will
584  accept buffers of any size.
585 */
586 #define paFramesPerBufferUnspecified (0)
587 
588 
589 /** Flags used to control the behavior of a stream. They are passed as
590  parameters to Pa_OpenStream or Pa_OpenDefaultStream. Multiple flags may be
591  ORed together.
592 
593  @see Pa_OpenStream, Pa_OpenDefaultStream
594  @see paNoFlag, paClipOff, paDitherOff, paNeverDropInput,
595  paPrimeOutputBuffersUsingStreamCallback, paPlatformSpecificFlags
596 */
597 typedef unsigned long PaStreamFlags;
598 
599 /** @see PaStreamFlags */
600 #define paNoFlag ((PaStreamFlags) 0)
601 
602 /** Disable default clipping of out of range samples.
603  @see PaStreamFlags
604 */
605 #define paClipOff ((PaStreamFlags) 0x00000001)
606 
607 /** Disable default dithering.
608  @see PaStreamFlags
609 */
610 #define paDitherOff ((PaStreamFlags) 0x00000002)
611 
612 /** Flag requests that where possible a full duplex stream will not discard
613  overflowed input samples without calling the stream callback. This flag is
614  only valid for full duplex callback streams and only when used in combination
615  with the paFramesPerBufferUnspecified (0) framesPerBuffer parameter. Using
616  this flag incorrectly results in a paInvalidFlag error being returned from
617  Pa_OpenStream and Pa_OpenDefaultStream.
618 
619  @see PaStreamFlags, paFramesPerBufferUnspecified
620 */
621 #define paNeverDropInput ((PaStreamFlags) 0x00000004)
622 
623 /** Call the stream callback to fill initial output buffers, rather than the
624  default behavior of priming the buffers with zeros (silence). This flag has
625  no effect for input-only and blocking read/write streams.
626 
627  @see PaStreamFlags
628 */
629 #define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
630 
631 /** A mask specifying the platform specific bits.
632  @see PaStreamFlags
633 */
634 #define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
635 
636 /**
637  Timing information for the buffers passed to the stream callback.
638 */
640  PaTime inputBufferAdcTime;
641  PaTime currentTime;
642  PaTime outputBufferDacTime;
644 
645 
646 /**
647  Flag bit constants for the statusFlags to PaStreamCallback.
648 
649  @see paInputUnderflow, paInputOverflow, paOutputUnderflow, paOutputOverflow,
650  paPrimingOutput
651 */
652 typedef unsigned long PaStreamCallbackFlags;
653 
654 /** In a stream opened with paFramesPerBufferUnspecified, indicates that
655  input data is all silence (zeros) because no real data is available. In a
656  stream opened without paFramesPerBufferUnspecified, it indicates that one or
657  more zero samples have been inserted into the input buffer to compensate
658  for an input underflow.
659  @see PaStreamCallbackFlags
660 */
661 #define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
662 
663 /** In a stream opened with paFramesPerBufferUnspecified, indicates that data
664  prior to the first sample of the input buffer was discarded due to an
665  overflow, possibly because the stream callback is using too much CPU time.
666  Otherwise indicates that data prior to one or more samples in the
667  input buffer was discarded.
668  @see PaStreamCallbackFlags
669 */
670 #define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
671 
672 /** Indicates that output data (or a gap) was inserted, possibly because the
673  stream callback is using too much CPU time.
674  @see PaStreamCallbackFlags
675 */
676 #define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
677 
678 /** Indicates that output data will be discarded because no room is available.
679  @see PaStreamCallbackFlags
680 */
681 #define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
682 
683 /** Some of all of the output data will be used to prime the stream, input
684  data may be zero.
685  @see PaStreamCallbackFlags
686 */
687 #define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
688 
689 /**
690  Allowable return values for the PaStreamCallback.
691  @see PaStreamCallback
692 */
694 {
695  paContinue=0,
696  paComplete=1,
697  paAbort=2
699 
700 
701 /**
702  Functions of type PaStreamCallback are implemented by PortAudio clients.
703  They consume, process or generate audio in response to requests from an
704  active PortAudio stream.
705 
706  @param input and @param output are arrays of interleaved samples,
707  the format, packing and number of channels used by the buffers are
708  determined by parameters to Pa_OpenStream().
709 
710  @param frameCount The number of sample frames to be processed by
711  the stream callback.
712 
713  @param timeInfo The time in seconds when the first sample of the input
714  buffer was received at the audio input, the time in seconds when the first
715  sample of the output buffer will begin being played at the audio output, and
716  the time in seconds when the stream callback was called.
717  See also Pa_GetStreamTime()
718 
719  @param statusFlags Flags indicating whether input and/or output buffers
720  have been inserted or will be dropped to overcome underflow or overflow
721  conditions.
722 
723  @param userData The value of a user supplied pointer passed to
724  Pa_OpenStream() intended for storing synthesis data etc.
725 
726  @return
727  The stream callback should return one of the values in the
728  PaStreamCallbackResult enumeration. To ensure that the callback continues
729  to be called, it should return paContinue (0). Either paComplete or paAbort
730  can be returned to finish stream processing, after either of these values is
731  returned the callback will not be called again. If paAbort is returned the
732  stream will finish as soon as possible. If paComplete is returned, the stream
733  will continue until all buffers generated by the callback have been played.
734  This may be useful in applications such as soundfile players where a specific
735  duration of output is required. However, it is not necessary to utilise this
736  mechanism as Pa_StopStream(), Pa_AbortStream() or Pa_CloseStream() can also
737  be used to stop the stream. The callback must always fill the entire output
738  buffer irrespective of its return value.
739 
740  @see Pa_OpenStream, Pa_OpenDefaultStream
741 
742  @note With the exception of Pa_GetStreamCpuLoad() it is not permissable to call
743  PortAudio API functions from within the stream callback.
744 */
745 typedef int PaStreamCallback(
746  const void *input, void *output,
747  unsigned long frameCount,
748  const PaStreamCallbackTimeInfo* timeInfo,
749  PaStreamCallbackFlags statusFlags,
750  void *userData );
751 
752 
753 /** Opens a stream for either input, output or both.
754 
755  @param stream The address of a PaStream pointer which will receive
756  a pointer to the newly opened stream.
757 
758  @param inputParameters A structure that describes the input parameters used by
759  the opened stream. See PaStreamParameters for a description of these parameters.
760  inputParameters must be NULL for output-only streams.
761 
762  @param outputParameters A structure that describes the output parameters used by
763  the opened stream. See PaStreamParameters for a description of these parameters.
764  outputParameters must be NULL for input-only streams.
765 
766  @param sampleRate The desired sampleRate. For full-duplex streams it is the
767  sample rate for both input and output
768 
769  @param framesPerBuffer The number of frames passed to the stream callback
770  function, or the preferred block granularity for a blocking read/write stream.
771  The special value paFramesPerBufferUnspecified (0) may be used to request that
772  the stream callback will recieve an optimal (and possibly varying) number of
773  frames based on host requirements and the requested latency settings.
774  Note: With some host APIs, the use of non-zero framesPerBuffer for a callback
775  stream may introduce an additional layer of buffering which could introduce
776  additional latency. PortAudio guarantees that the additional latency
777  will be kept to the theoretical minimum however, it is strongly recommended
778  that a non-zero framesPerBuffer value only be used when your algorithm
779  requires a fixed number of frames per stream callback.
780 
781  @param streamFlags Flags which modify the behaviour of the streaming process.
782  This parameter may contain a combination of flags ORed together. Some flags may
783  only be relevant to certain buffer formats.
784 
785  @param streamCallback A pointer to a client supplied function that is responsible
786  for processing and filling input and output buffers. If this parameter is NULL
787  the stream will be opened in 'blocking read/write' mode. In blocking mode,
788  the client can receive sample data using Pa_ReadStream and write sample data
789  using Pa_WriteStream, the number of samples that may be read or written
790  without blocking is returned by Pa_GetStreamReadAvailable and
791  Pa_GetStreamWriteAvailable respectively.
792 
793  @param userData A client supplied pointer which is passed to the stream callback
794  function. It could for example, contain a pointer to instance data necessary
795  for processing the audio buffers. This parameter is ignored if streamCallback
796  is NULL.
797 
798  @return
799  Upon success Pa_OpenStream() returns paNoError and places a pointer to a
800  valid PaStream in the stream argument. The stream is inactive (stopped).
801  If a call to Pa_OpenStream() fails, a non-zero error code is returned (see
802  PaError for possible error codes) and the value of stream is invalid.
803 
804  @see PaStreamParameters, PaStreamCallback, Pa_ReadStream, Pa_WriteStream,
805  Pa_GetStreamReadAvailable, Pa_GetStreamWriteAvailable
806 */
807 PaError Pa_OpenStream( PaStream** stream,
808  const PaStreamParameters *inputParameters,
809  const PaStreamParameters *outputParameters,
810  double sampleRate,
811  unsigned long framesPerBuffer,
812  PaStreamFlags streamFlags,
813  PaStreamCallback *streamCallback,
814  void *userData );
815 
816 
817 /** A simplified version of Pa_OpenStream() that opens the default input
818  and/or output devices.
819 
820  @param stream The address of a PaStream pointer which will receive
821  a pointer to the newly opened stream.
822 
823  @param numInputChannels The number of channels of sound that will be supplied
824  to the stream callback or returned by Pa_ReadStream. It can range from 1 to
825  the value of maxInputChannels in the PaDeviceInfo record for the default input
826  device. If 0 the stream is opened as an output-only stream.
827 
828  @param numOutputChannels The number of channels of sound to be delivered to the
829  stream callback or passed to Pa_WriteStream. It can range from 1 to the value
830  of maxOutputChannels in the PaDeviceInfo record for the default output dvice.
831  If 0 the stream is opened as an output-only stream.
832 
833  @param sampleFormat The sample format of both the input and output buffers
834  provided to the callback or passed to and from Pa_ReadStream and Pa_WriteStream.
835  sampleFormat may be any of the formats described by the PaSampleFormat
836  enumeration.
837 
838  @param sampleRate Same as Pa_OpenStream parameter of the same name.
839  @param framesPerBuffer Same as Pa_OpenStream parameter of the same name.
840  @param streamCallback Same as Pa_OpenStream parameter of the same name.
841  @param userData Same as Pa_OpenStream parameter of the same name.
842 
843  @return As for Pa_OpenStream
844 
845  @see Pa_OpenStream, PaStreamCallback
846 */
847 PaError Pa_OpenDefaultStream( PaStream** stream,
848  int numInputChannels,
849  int numOutputChannels,
850  PaSampleFormat sampleFormat,
851  double sampleRate,
852  unsigned long framesPerBuffer,
853  PaStreamCallback *streamCallback,
854  void *userData );
855 
856 
857 /** Closes an audio stream. If the audio stream is active it
858  discards any pending buffers as if Pa_AbortStream() had been called.
859 */
860 PaError Pa_CloseStream( PaStream *stream );
861 
862 
863 /** Functions of type PaStreamFinishedCallback are implemented by PortAudio
864  clients. They can be registered with a stream using the Pa_SetStreamFinishedCallback
865  function. Once registered they are called when the stream becomes inactive
866  (ie once a call to Pa_StopStream() will not block).
867  A stream will become inactive after the stream callback returns non-zero,
868  or when Pa_StopStream or Pa_AbortStream is called. For a stream providing audio
869  output, if the stream callback returns paComplete, or Pa_StopStream is called,
870  the stream finished callback will not be called until all generated sample data
871  has been played.
872 
873  @param userData The userData parameter supplied to Pa_OpenStream()
874 
875  @see Pa_SetStreamFinishedCallback
876 */
877 typedef void PaStreamFinishedCallback( void *userData );
878 
879 
880 /** Register a stream finished callback function which will be called when the
881  stream becomes inactive. See the description of PaStreamFinishedCallback for
882  further details about when the callback will be called.
883 
884  @param stream a pointer to a PaStream that is in the stopped state - if the
885  stream is not stopped, the stream's finished callback will remain unchanged
886  and an error code will be returned.
887 
888  @param streamFinishedCallback a pointer to a function with the same signature
889  as PaStreamFinishedCallback, that will be called when the stream becomes
890  inactive. Passing NULL for this parameter will un-register a previously
891  registered stream finished callback function.
892 
893  @return on success returns paNoError, otherwise an error code indicating the cause
894  of the error.
895 
896  @see PaStreamFinishedCallback
897 */
898 PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
899 
900 
901 /** Commences audio processing.
902 */
903 PaError Pa_StartStream( PaStream *stream );
904 
905 
906 /** Terminates audio processing. It waits until all pending
907  audio buffers have been played before it returns.
908 */
909 PaError Pa_StopStream( PaStream *stream );
910 
911 
912 /** Terminates audio processing immediately without waiting for pending
913  buffers to complete.
914 */
915 PaError Pa_AbortStream( PaStream *stream );
916 
917 
918 /** Determine whether the stream is stopped.
919  A stream is considered to be stopped prior to a successful call to
920  Pa_StartStream and after a successful call to Pa_StopStream or Pa_AbortStream.
921  If a stream callback returns a value other than paContinue the stream is NOT
922  considered to be stopped.
923 
924  @return Returns one (1) when the stream is stopped, zero (0) when
925  the stream is running or, a PaErrorCode (which are always negative) if
926  PortAudio is not initialized or an error is encountered.
927 
928  @see Pa_StopStream, Pa_AbortStream, Pa_IsStreamActive
929 */
930 PaError Pa_IsStreamStopped( PaStream *stream );
931 
932 
933 /** Determine whether the stream is active.
934  A stream is active after a successful call to Pa_StartStream(), until it
935  becomes inactive either as a result of a call to Pa_StopStream() or
936  Pa_AbortStream(), or as a result of a return value other than paContinue from
937  the stream callback. In the latter case, the stream is considered inactive
938  after the last buffer has finished playing.
939 
940  @return Returns one (1) when the stream is active (ie playing or recording
941  audio), zero (0) when not playing or, a PaErrorCode (which are always negative)
942  if PortAudio is not initialized or an error is encountered.
943 
944  @see Pa_StopStream, Pa_AbortStream, Pa_IsStreamStopped
945 */
946 PaError Pa_IsStreamActive( PaStream *stream );
947 
948 
949 
950 /** A structure containing unchanging information about an open stream.
951  @see Pa_GetStreamInfo
952 */
953 
954 typedef struct PaStreamInfo
955 {
956  /** this is struct version 1 */
958 
959  /** The input latency of the stream in seconds. This value provides the most
960  accurate estimate of input latency available to the implementation. It may
961  differ significantly from the suggestedLatency value passed to Pa_OpenStream().
962  The value of this field will be zero (0.) for output-only streams.
963  @see PaTime
964  */
965  PaTime inputLatency;
966 
967  /** The output latency of the stream in seconds. This value provides the most
968  accurate estimate of output latency available to the implementation. It may
969  differ significantly from the suggestedLatency value passed to Pa_OpenStream().
970  The value of this field will be zero (0.) for input-only streams.
971  @see PaTime
972  */
974 
975  /** The sample rate of the stream in Hertz (samples per second). In cases
976  where the hardware sample rate is inaccurate and PortAudio is aware of it,
977  the value of this field may be different from the sampleRate parameter
978  passed to Pa_OpenStream(). If information about the actual hardware sample
979  rate is not available, this field will have the same value as the sampleRate
980  parameter passed to Pa_OpenStream().
981  */
982  double sampleRate;
983 
984 } PaStreamInfo;
985 
986 
987 /** Retrieve a pointer to a PaStreamInfo structure containing information
988  about the specified stream.
989  @return A pointer to an immutable PaStreamInfo structure. If the stream
990  parameter invalid, or an error is encountered, the function returns NULL.
991 
992  @param stream A pointer to an open stream previously created with Pa_OpenStream.
993 
994  @note PortAudio manages the memory referenced by the returned pointer,
995  the client must not manipulate or free the memory. The pointer is only
996  guaranteed to be valid until the specified stream is closed.
997 
998  @see PaStreamInfo
999 */
1000 const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
1001 
1002 
1003 /** Determine the current time for the stream according to the same clock used
1004  to generate buffer timestamps. This time may be used for syncronising other
1005  events to the audio stream, for example synchronizing audio to MIDI.
1006 
1007  @return The stream's current time in seconds, or 0 if an error occurred.
1008 
1009  @see PaTime, PaStreamCallback
1010 */
1011 PaTime Pa_GetStreamTime( PaStream *stream );
1012 
1013 
1014 /** Retrieve CPU usage information for the specified stream.
1015  The "CPU Load" is a fraction of total CPU time consumed by a callback stream's
1016  audio processing routines including, but not limited to the client supplied
1017  stream callback. This function does not work with blocking read/write streams.
1018 
1019  This function may be called from the stream callback function or the
1020  application.
1021 
1022  @return
1023  A floating point value, typically between 0.0 and 1.0, where 1.0 indicates
1024  that the stream callback is consuming the maximum number of CPU cycles possible
1025  to maintain real-time operation. A value of 0.5 would imply that PortAudio and
1026  the stream callback was consuming roughly 50% of the available CPU time. The
1027  return value may exceed 1.0. A value of 0.0 will always be returned for a
1028  blocking read/write stream, or if an error occurrs.
1029 */
1030 double Pa_GetStreamCpuLoad( PaStream* stream );
1031 
1032 
1033 /** Read samples from an input stream. The function doesn't return until
1034  the entire buffer has been filled - this may involve waiting for the operating
1035  system to supply the data.
1036 
1037  @param stream A pointer to an open stream previously created with Pa_OpenStream.
1038 
1039  @param buffer A pointer to a buffer of sample frames. The buffer contains
1040  samples in the format specified by the inputParameters->sampleFormat field
1041  used to open the stream, and the number of channels specified by
1042  inputParameters->numChannels. If non-interleaved samples were requested,
1043  buffer is a pointer to the first element of an array of non-interleaved
1044  buffer pointers, one for each channel.
1045 
1046  @param frames The number of frames to be read into buffer. This parameter
1047  is not constrained to a specific range, however high performance applications
1048  will want to match this parameter to the framesPerBuffer parameter used
1049  when opening the stream.
1050 
1051  @return On success PaNoError will be returned, or PaInputOverflowed if input
1052  data was discarded by PortAudio after the previous call and before this call.
1053 */
1054 PaError Pa_ReadStream( PaStream* stream,
1055  void *buffer,
1056  unsigned long frames );
1057 
1058 
1059 /** Write samples to an output stream. This function doesn't return until the
1060  entire buffer has been consumed - this may involve waiting for the operating
1061  system to consume the data.
1062 
1063  @param stream A pointer to an open stream previously created with Pa_OpenStream.
1064 
1065  @param buffer A pointer to a buffer of sample frames. The buffer contains
1066  samples in the format specified by the outputParameters->sampleFormat field
1067  used to open the stream, and the number of channels specified by
1068  outputParameters->numChannels. If non-interleaved samples were requested,
1069  buffer is a pointer to the first element of an array of non-interleaved
1070  buffer pointers, one for each channel.
1071 
1072  @param frames The number of frames to be written from buffer. This parameter
1073  is not constrained to a specific range, however high performance applications
1074  will want to match this parameter to the framesPerBuffer parameter used
1075  when opening the stream.
1076 
1077  @return On success PaNoError will be returned, or paOutputUnderflowed if
1078  additional output data was inserted after the previous call and before this
1079  call.
1080 */
1081 PaError Pa_WriteStream( PaStream* stream,
1082  const void *buffer,
1083  unsigned long frames );
1084 
1085 
1086 /** Retrieve the number of frames that can be read from the stream without
1087  waiting.
1088 
1089  @return Returns a non-negative value representing the maximum number of frames
1090  that can be read from the stream without blocking or busy waiting or, a
1091  PaErrorCode (which are always negative) if PortAudio is not initialized or an
1092  error is encountered.
1093 */
1094 signed long Pa_GetStreamReadAvailable( PaStream* stream );
1095 
1096 
1097 /** Retrieve the number of frames that can be written to the stream without
1098  waiting.
1099 
1100  @return Returns a non-negative value representing the maximum number of frames
1101  that can be written to the stream without blocking or busy waiting or, a
1102  PaErrorCode (which are always negative) if PortAudio is not initialized or an
1103  error is encountered.
1104 */
1105 signed long Pa_GetStreamWriteAvailable( PaStream* stream );
1106 
1107 
1108 /* Miscellaneous utilities */
1109 
1110 
1111 /** Retrieve the size of a given sample format in bytes.
1112 
1113  @return The size in bytes of a single sample in the specified format,
1114  or paSampleFormatNotSupported if the format is not supported.
1115 */
1116 PaError Pa_GetSampleSize( PaSampleFormat format );
1117 
1118 
1119 /** Put the caller to sleep for at least 'msec' milliseconds. This function is
1120  provided only as a convenience for authors of portable code (such as the tests
1121  and examples in the PortAudio distribution.)
1122 
1123  The function may sleep longer than requested so don't rely on this for accurate
1124  musical timing.
1125 */
1126 void Pa_Sleep( long msec );
1127 
1128 
1129 
1130 #ifdef __cplusplus
1131 }
1132 #endif /* __cplusplus */
1133 #endif /* PORTAUDIO_H */
PaError Pa_Initialize(void)
Library initialization function - call this before using PortAudio.
int structVersion
this is struct version 1
Definition: portaudio.h:247
int PaHostApiIndex
The type used to enumerate to host APIs at runtime.
Definition: portaudio.h:186
PaDeviceIndex Pa_GetDefaultInputDevice(void)
Retrieve the index of the default input device.
PaDeviceIndex Pa_GetDeviceCount(void)
Retrieve the number of available devices.
PaHostApiTypeId type
The well known unique identifier of this host API.
Definition: portaudio.h:249
PaError Pa_StopStream(PaStream *stream)
Terminates audio processing.
void PaStream
A single PaStream can provide multiple channels of real-time streaming audio input and output to a cl...
Definition: portaudio.h:579
A structure containing unchanging information about an open stream.
Definition: portaudio.h:954
const PaStreamInfo * Pa_GetStreamInfo(PaStream *stream)
Retrieve a pointer to a PaStreamInfo structure containing information about the specified stream...
A structure providing information and capabilities of PortAudio devices.
Definition: portaudio.h:444
long errorCode
the error code returned
Definition: portaudio.h:339
PaError Pa_GetSampleSize(PaSampleFormat format)
Retrieve the size of a given sample format in bytes.
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
Opens a stream for either input, output or both.
double sampleRate
The sample rate of the stream in Hertz (samples per second).
Definition: portaudio.h:982
PaHostApiIndex Pa_GetDefaultHostApi(void)
Retrieve the index of the default host API.
const char * name
A textual description of the host API for display on user interfaces.
Definition: portaudio.h:251
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Functions of type PaStreamCallback are implemented by PortAudio clients.
Definition: portaudio.h:745
A structure containing information about a particular host API.
Definition: portaudio.h:244
const PaHostErrorInfo * Pa_GetLastHostErrorInfo(void)
Return information about the last host error encountered.
PaError Pa_IsFormatSupported(const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate)
Determine whether it would be possible to open a stream with the specified parameters.
void PaStreamFinishedCallback(void *userData)
Functions of type PaStreamFinishedCallback are implemented by PortAudio clients.
Definition: portaudio.h:877
int PaDeviceIndex
The type used to refer to audio devices.
Definition: portaudio.h:160
PaError Pa_SetStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback *streamFinishedCallback)
Register a stream finished callback function which will be called when the stream becomes inactive...
PaError Pa_StartStream(PaStream *stream)
Commences audio processing.
void * hostApiSpecificStreamInfo
An optional pointer to a host api specific data structure containing additional information for devic...
Definition: portaudio.h:523
PaDeviceIndex defaultInputDevice
The default input device for this host API.
Definition: portaudio.h:264
int deviceCount
The number of devices belonging to this host API.
Definition: portaudio.h:258
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(PaHostApiIndex hostApi, int hostApiDeviceIndex)
Convert a host-API-specific device index to standard PortAudio device index.
PaError Pa_IsStreamStopped(PaStream *stream)
Determine whether the stream is stopped.
PaTime inputLatency
The input latency of the stream in seconds.
Definition: portaudio.h:965
PaSampleFormat sampleFormat
The sample format of the buffer provided to the stream callback, a_ReadStream() or Pa_WriteStream()...
Definition: portaudio.h:503
const char * errorText
a textual description of the error if available, otherwise a zero-length string
Definition: portaudio.h:340
unsigned long PaStreamFlags
Flags used to control the behavior of a stream.
Definition: portaudio.h:597
int PaError
Error codes returned by PortAudio functions.
Definition: portaudio.h:69
PaError Pa_IsStreamActive(PaStream *stream)
Determine whether the stream is active.
PaHostApiTypeId
Unchanging unique identifiers for each supported host API.
Definition: portaudio.h:223
PaTime suggestedLatency
The desired latency in seconds.
Definition: portaudio.h:516
int Pa_GetVersion(void)
Retrieve the release number of the currently running PortAudio build, eg 1900.
Parameters for one direction (input or output) of a stream.
Definition: portaudio.h:482
unsigned long PaStreamCallbackFlags
Flag bit constants for the statusFlags to PaStreamCallback.
Definition: portaudio.h:652
PaTime Pa_GetStreamTime(PaStream *stream)
Determine the current time for the stream according to the same clock used to generate buffer timesta...
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
A simplified version of Pa_OpenStream() that opens the default input and/or output devices...
PaDeviceIndex defaultOutputDevice
The default output device for this host API.
Definition: portaudio.h:270
int structVersion
this is struct version 1
Definition: portaudio.h:957
PaError Pa_AbortStream(PaStream *stream)
Terminates audio processing immediately without waiting for pending buffers to complete.
Structure used to return information about a host error condition.
Definition: portaudio.h:337
const PaHostApiInfo * Pa_GetHostApiInfo(PaHostApiIndex hostApi)
Retrieve a pointer to a structure containing information about a specific host Api.
unsigned long PaSampleFormat
A type used to specify one or more sample formats.
Definition: portaudio.h:428
signed long Pa_GetStreamReadAvailable(PaStream *stream)
Retrieve the number of frames that can be read from the stream without waiting.
PaHostApiIndex Pa_GetHostApiCount(void)
Retrieve the number of available host APIs.
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
Retrieve a pointer to a PaDeviceInfo structure containing information about the specified device...
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
Retrieve the index of the default output device.
PaStreamCallbackResult
Allowable return values for the PaStreamCallback.
Definition: portaudio.h:693
PaDeviceIndex device
A valid device index in the range 0 to (Pa_GetDeviceCount()-1) specifying the device to be used or th...
Definition: portaudio.h:490
PaErrorCode
Definition: portaudio.h:70
void Pa_Sleep(long msec)
Put the caller to sleep for at least 'msec' milliseconds.
PaError Pa_ReadStream(PaStream *stream, void *buffer, unsigned long frames)
Read samples from an input stream.
PaHostApiTypeId hostApiType
the host API which returned the error code
Definition: portaudio.h:338
PaTime outputLatency
The output latency of the stream in seconds.
Definition: portaudio.h:973
PaError Pa_WriteStream(PaStream *stream, const void *buffer, unsigned long frames)
Write samples to an output stream.
double PaTime
The type used to represent monotonic time in seconds that can be used for syncronisation.
Definition: portaudio.h:406
const char * Pa_GetErrorText(PaError errorCode)
Translate the supplied PortAudio error code into a human readable message.
int channelCount
The number of channels of sound to be delivered to the stream callback or accessed by Pa_ReadStream()...
Definition: portaudio.h:497
PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type)
Convert a static host API unique identifier, into a runtime host API index.
signed long Pa_GetStreamWriteAvailable(PaStream *stream)
Retrieve the number of frames that can be written to the stream without waiting.
PaError Pa_CloseStream(PaStream *stream)
Closes an audio stream.
PaError Pa_Terminate(void)
Library termination function - call this when finished using PortAudio.
const char * Pa_GetVersionText(void)
Retrieve a textual description of the current PortAudio build, eg "PortAudio V19-devel 13 October 200...
Timing information for the buffers passed to the stream callback.
Definition: portaudio.h:639
double Pa_GetStreamCpuLoad(PaStream *stream)
Retrieve CPU usage information for the specified stream.