portaudio.h | portaudio.h | |||
---|---|---|---|---|
#ifndef PORTAUDIO_H | #ifndef PORTAUDIO_H | |||
#define PORTAUDIO_H | #define PORTAUDIO_H | |||
/* | /* | |||
* $Id: portaudio.h 1247 2007-08-11 16:29:09Z rossb $ | * $Id: portaudio.h 1594 2011-02-05 14:33:29Z rossb $ | |||
* PortAudio Portable Real-Time Audio Library | * PortAudio Portable Real-Time Audio Library | |||
* PortAudio API Header File | * PortAudio API Header File | |||
* Latest version available at: http://www.portaudio.com/ | * Latest version available at: http://www.portaudio.com/ | |||
* | * | |||
* Copyright (c) 1999-2002 Ross Bencina and Phil Burk | * Copyright (c) 1999-2002 Ross Bencina and Phil Burk | |||
* | * | |||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | |||
* a copy of this software and associated documentation files | * a copy of this software and associated documentation files | |||
* (the "Software"), to deal in the Software without restriction, | * (the "Software"), to deal in the Software without restriction, | |||
* including without limitation the rights to use, copy, modify, merge, | * including without limitation the rights to use, copy, modify, merge, | |||
skipping to change at line 43 | skipping to change at line 43 | |||
* the PortAudio community also makes the following non-binding requests: | * the PortAudio community also makes the following non-binding requests: | |||
* | * | |||
* Any person wishing to distribute modifications to the Software is | * Any person wishing to distribute modifications to the Software is | |||
* requested to send the modifications to the original developer so that | * requested to send the modifications to the original developer so that | |||
* they can be incorporated into the canonical version. It is also | * they can be incorporated into the canonical version. It is also | |||
* requested that these non-binding requests be included along with the | * requested that these non-binding requests be included along with the | |||
* license above. | * license above. | |||
*/ | */ | |||
/** @file | /** @file | |||
@brief The PortAudio API. | @ingroup public_header | |||
@brief The portable PortAudio API. | ||||
*/ | */ | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" | extern "C" | |||
{ | { | |||
#endif /* __cplusplus */ | #endif /* __cplusplus */ | |||
/** Retrieve the release number of the currently running PortAudio build, | /** Retrieve the release number of the currently running PortAudio build, | |||
eg 1900. | eg 1900. | |||
*/ | */ | |||
skipping to change at line 93 | skipping to change at line 94 | |||
paTimedOut, | paTimedOut, | |||
paInternalError, | paInternalError, | |||
paDeviceUnavailable, | paDeviceUnavailable, | |||
paIncompatibleHostApiSpecificStreamInfo, | paIncompatibleHostApiSpecificStreamInfo, | |||
paStreamIsStopped, | paStreamIsStopped, | |||
paStreamIsNotStopped, | paStreamIsNotStopped, | |||
paInputOverflowed, | paInputOverflowed, | |||
paOutputUnderflowed, | paOutputUnderflowed, | |||
paHostApiNotFound, | paHostApiNotFound, | |||
paInvalidHostApi, | paInvalidHostApi, | |||
paCanNotReadFromACallbackStream, /**< @todo review error code name | paCanNotReadFromACallbackStream, | |||
*/ | paCanNotWriteToACallbackStream, | |||
paCanNotWriteToACallbackStream, /**< @todo review error code name | paCanNotReadFromAnOutputOnlyStream, | |||
*/ | paCanNotWriteToAnInputOnlyStream, | |||
paCanNotReadFromAnOutputOnlyStream, /**< @todo review error code name | ||||
*/ | ||||
paCanNotWriteToAnInputOnlyStream, /**< @todo review error code name | ||||
*/ | ||||
paIncompatibleStreamHostApi, | paIncompatibleStreamHostApi, | |||
paBadBufferPtr | paBadBufferPtr | |||
} PaErrorCode; | } PaErrorCode; | |||
/** Translate the supplied PortAudio error code into a human readable | /** Translate the supplied PortAudio error code into a human readable | |||
message. | message. | |||
*/ | */ | |||
const char *Pa_GetErrorText( PaError errorCode ); | const char *Pa_GetErrorText( PaError errorCode ); | |||
/** Library initialization function - call this before using PortAudio. | /** Library initialization function - call this before using PortAudio. | |||
This function initialises internal data structures and prepares underlying | This function initializes internal data structures and prepares underlying | |||
host APIs for use. With the exception of Pa_GetVersion(), Pa_GetVersionTe xt(), | host APIs for use. With the exception of Pa_GetVersion(), Pa_GetVersionTe xt(), | |||
and Pa_GetErrorText(), this function MUST be called before using any other | and Pa_GetErrorText(), this function MUST be called before using any other | |||
PortAudio API functions. | PortAudio API functions. | |||
If Pa_Initialize() is called multiple times, each successful | If Pa_Initialize() is called multiple times, each successful | |||
call must be matched with a corresponding call to Pa_Terminate(). | call must be matched with a corresponding call to Pa_Terminate(). | |||
Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not | Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not | |||
required to be fully nested. | required to be fully nested. | |||
Note that if Pa_Initialize() returns an error code, Pa_Terminate() should | Note that if Pa_Initialize() returns an error code, Pa_Terminate() should | |||
skipping to change at line 129 | skipping to change at line 130 | |||
@return paNoError if successful, otherwise an error code indicating the ca use | @return paNoError if successful, otherwise an error code indicating the ca use | |||
of failure. | of failure. | |||
@see Pa_Terminate | @see Pa_Terminate | |||
*/ | */ | |||
PaError Pa_Initialize( void ); | PaError Pa_Initialize( void ); | |||
/** Library termination function - call this when finished using PortAudio. | /** Library termination function - call this when finished using PortAudio. | |||
This function deallocates all resources allocated by PortAudio since it wa s | This function deallocates all resources allocated by PortAudio since it wa s | |||
initializied by a call to Pa_Initialize(). In cases where Pa_Initialise() has | initialized by a call to Pa_Initialize(). In cases where Pa_Initialise() h as | |||
been called multiple times, each call must be matched with a corresponding call | been called multiple times, each call must be matched with a corresponding call | |||
to Pa_Terminate(). The final matching call to Pa_Terminate() will automati cally | to Pa_Terminate(). The final matching call to Pa_Terminate() will automati cally | |||
close any PortAudio streams that are still open. | close any PortAudio streams that are still open. | |||
Pa_Terminate() MUST be called before exiting a program which uses PortAudi o. | Pa_Terminate() MUST be called before exiting a program which uses PortAudi o. | |||
Failure to do so may result in serious resource leaks, such as audio devic es | Failure to do so may result in serious resource leaks, such as audio devic es | |||
not being available until the next reboot. | not being available until the next reboot. | |||
@return paNoError if successful, otherwise an error code indicating the ca use | @return paNoError if successful, otherwise an error code indicating the ca use | |||
of failure. | of failure. | |||
skipping to change at line 324 | skipping to change at line 325 | |||
/** Structure used to return information about a host error condition. | /** Structure used to return information about a host error condition. | |||
*/ | */ | |||
typedef struct PaHostErrorInfo{ | typedef struct PaHostErrorInfo{ | |||
PaHostApiTypeId hostApiType; /**< the host API which returned the er ror code */ | PaHostApiTypeId hostApiType; /**< the host API which returned the er ror code */ | |||
long errorCode; /**< the error code returned */ | long errorCode; /**< the error code returned */ | |||
const char *errorText; /**< a textual description of the error if available, otherwise a zero-length string */ | const char *errorText; /**< a textual description of the error if available, otherwise a zero-length string */ | |||
}PaHostErrorInfo; | }PaHostErrorInfo; | |||
/** Return information about the last host error encountered. The error | /** Return information about the last host error encountered. The error | |||
information returned by Pa_GetLastHostErrorInfo() will never be modified | information returned by Pa_GetLastHostErrorInfo() will never be modified | |||
asyncronously by errors occurring in other PortAudio owned threads | asynchronously by errors occurring in other PortAudio owned threads | |||
(such as the thread that manages the stream callback.) | (such as the thread that manages the stream callback.) | |||
This function is provided as a last resort, primarily to enhance debugging | This function is provided as a last resort, primarily to enhance debugging | |||
by providing clients with access to all available error information. | by providing clients with access to all available error information. | |||
@return A pointer to an immutable structure constaining information about | @return A pointer to an immutable structure constraining information about | |||
the host error. The values in this structure will only be valid if a | the host error. The values in this structure will only be valid if a | |||
PortAudio function has previously returned the paUnanticipatedHostError | PortAudio function has previously returned the paUnanticipatedHostError | |||
error code. | error code. | |||
*/ | */ | |||
const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void ); | const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void ); | |||
/* Device enumeration and capabilities */ | /* Device enumeration and capabilities */ | |||
/** Retrieve the number of available devices. The number of available devic es | /** Retrieve the number of available devices. The number of available devic es | |||
may be zero. | may be zero. | |||
skipping to change at line 359 | skipping to change at line 360 | |||
used in the inputDevice parameter to Pa_OpenStream(). | used in the inputDevice parameter to Pa_OpenStream(). | |||
@return The default input device index for the default host API, or paNoDe vice | @return The default input device index for the default host API, or paNoDe vice | |||
if no default input device is available or an error was encountered. | if no default input device is available or an error was encountered. | |||
*/ | */ | |||
PaDeviceIndex Pa_GetDefaultInputDevice( void ); | PaDeviceIndex Pa_GetDefaultInputDevice( void ); | |||
/** Retrieve the index of the default output device. The result can be | /** Retrieve the index of the default output device. The result can be | |||
used in the outputDevice parameter to Pa_OpenStream(). | used in the outputDevice parameter to Pa_OpenStream(). | |||
@return The default output device index for the defualt host API, or paNoD evice | @return The default output device index for the default host API, or paNoD evice | |||
if no default output device is available or an error was encountered. | if no default output device is available or an error was encountered. | |||
@note | @note | |||
On the PC, the user can specify a default device by | On the PC, the user can specify a default device by | |||
setting an environment variable. For example, to use device #1. | setting an environment variable. For example, to use device #1. | |||
<pre> | <pre> | |||
set PA_RECOMMENDED_OUTPUT_DEVICE=1 | set PA_RECOMMENDED_OUTPUT_DEVICE=1 | |||
</pre> | </pre> | |||
The user should first determine the available device ids by using | The user should first determine the available device ids by using | |||
the supplied application "pa_devs". | the supplied application "pa_devs". | |||
*/ | */ | |||
PaDeviceIndex Pa_GetDefaultOutputDevice( void ); | PaDeviceIndex Pa_GetDefaultOutputDevice( void ); | |||
/** The type used to represent monotonic time in seconds that can be used | /** The type used to represent monotonic time in seconds. PaTime is | |||
for syncronisation. The type is used for the outTime argument to the | used for the fields of the PaStreamCallbackTimeInfo argument to the | |||
PaStreamCallback and as the result of Pa_GetStreamTime(). | PaStreamCallback and as the result of Pa_GetStreamTime(). | |||
@see PaStreamCallback, Pa_GetStreamTime | PaTime values have unspecified origin. | |||
@see PaStreamCallback, PaStreamCallbackTimeInfo, Pa_GetStreamTime | ||||
*/ | */ | |||
typedef double PaTime; | typedef double PaTime; | |||
/** A type used to specify one or more sample formats. Each value indicates | /** A type used to specify one or more sample formats. Each value indicates | |||
a possible format for sound data passed to and from the stream callback, | a possible format for sound data passed to and from the stream callback, | |||
Pa_ReadStream and Pa_WriteStream. | Pa_ReadStream and Pa_WriteStream. | |||
The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8 | The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8 | |||
and aUInt8 are usually implemented by all implementations. | and aUInt8 are usually implemented by all implementations. | |||
The floating point representation (paFloat32) uses +1.0 and -1.0 as the | The floating point representation (paFloat32) uses +1.0 and -1.0 as the | |||
maximum and minimum respectively. | maximum and minimum respectively. | |||
paUInt8 is an unsigned 8 bit format where 128 is considered "ground" | paUInt8 is an unsigned 8 bit format where 128 is considered "ground" | |||
The paNonInterleaved flag indicates that a multichannel buffer is passed | The paNonInterleaved flag indicates that audio data is passed as an array | |||
as a set of non-interleaved pointers. | of pointers to separate buffers, one buffer for each channel. Usually, | |||
when this flag is not used, audio data is passed as a single buffer with | ||||
all channels interleaved. | ||||
@see Pa_OpenStream, Pa_OpenDefaultStream, PaDeviceInfo | @see Pa_OpenStream, Pa_OpenDefaultStream, PaDeviceInfo | |||
@see paFloat32, paInt16, paInt32, paInt24, paInt8 | @see paFloat32, paInt16, paInt32, paInt24, paInt8 | |||
@see paUInt8, paCustomFormat, paNonInterleaved | @see paUInt8, paCustomFormat, paNonInterleaved | |||
*/ | */ | |||
typedef unsigned long PaSampleFormat; | typedef unsigned long PaSampleFormat; | |||
#define paFloat32 ((PaSampleFormat) 0x00000001) /**< @see PaSampleFo rmat */ | #define paFloat32 ((PaSampleFormat) 0x00000001) /**< @see PaSampleFo rmat */ | |||
#define paInt32 ((PaSampleFormat) 0x00000002) /**< @see PaSampleFo rmat */ | #define paInt32 ((PaSampleFormat) 0x00000002) /**< @see PaSampleFo rmat */ | |||
#define paInt24 ((PaSampleFormat) 0x00000004) /**< Packed 24 bit f ormat. @see PaSampleFormat */ | #define paInt24 ((PaSampleFormat) 0x00000004) /**< Packed 24 bit f ormat. @see PaSampleFormat */ | |||
#define paInt16 ((PaSampleFormat) 0x00000008) /**< @see PaSampleFo rmat */ | #define paInt16 ((PaSampleFormat) 0x00000008) /**< @see PaSampleFo rmat */ | |||
#define paInt8 ((PaSampleFormat) 0x00000010) /**< @see PaSampleFo rmat */ | #define paInt8 ((PaSampleFormat) 0x00000010) /**< @see PaSampleFo rmat */ | |||
#define paUInt8 ((PaSampleFormat) 0x00000020) /**< @see PaSampleFo rmat */ | #define paUInt8 ((PaSampleFormat) 0x00000020) /**< @see PaSampleFo rmat */ | |||
#define paCustomFormat ((PaSampleFormat) 0x00010000)/**< @see PaSampleFor mat */ | #define paCustomFormat ((PaSampleFormat) 0x00010000) /**< @see PaSampleFo rmat */ | |||
#define paNonInterleaved ((PaSampleFormat) 0x80000000) | #define paNonInterleaved ((PaSampleFormat) 0x80000000) /**< @see PaSampleFo rmat */ | |||
/** A structure providing information and capabilities of PortAudio devices . | /** A structure providing information and capabilities of PortAudio devices . | |||
Devices may support input, output or both input and output. | Devices may support input, output or both input and output. | |||
*/ | */ | |||
typedef struct PaDeviceInfo | typedef struct PaDeviceInfo | |||
{ | { | |||
int structVersion; /* this is struct version 2 */ | int structVersion; /* this is struct version 2 */ | |||
const char *name; | const char *name; | |||
PaHostApiIndex hostApi; /* note this is a host API index, not a type id */ | PaHostApiIndex hostApi; /* note this is a host API index, not a type id */ | |||
skipping to change at line 478 | skipping to change at line 483 | |||
/** The sample format of the buffer provided to the stream callback, | /** The sample format of the buffer provided to the stream callback, | |||
a_ReadStream() or Pa_WriteStream(). It may be any of the formats descr ibed | a_ReadStream() or Pa_WriteStream(). It may be any of the formats descr ibed | |||
by the PaSampleFormat enumeration. | by the PaSampleFormat enumeration. | |||
*/ | */ | |||
PaSampleFormat sampleFormat; | PaSampleFormat sampleFormat; | |||
/** The desired latency in seconds. Where practical, implementations sh ould | /** The desired latency in seconds. Where practical, implementations sh ould | |||
configure their latency based on these parameters, otherwise they may | configure their latency based on these parameters, otherwise they may | |||
choose the closest viable latency instead. Unless the suggested latenc y | choose the closest viable latency instead. Unless the suggested latenc y | |||
is greater than the absolute upper limit for the device implementation s | is greater than the absolute upper limit for the device implementation s | |||
should round the suggestedLatency up to the next practial value - ie t | should round the suggestedLatency up to the next practical value - ie | |||
o | to | |||
provide an equal or higher latency than suggestedLatency wherever poss | provide an equal or higher latency than suggestedLatency wherever poss | |||
ibe. | ible. | |||
Actual latency values for an open stream may be retrieved using the | Actual latency values for an open stream may be retrieved using the | |||
inputLatency and outputLatency fields of the PaStreamInfo structure | inputLatency and outputLatency fields of the PaStreamInfo structure | |||
returned by Pa_GetStreamInfo(). | returned by Pa_GetStreamInfo(). | |||
@see default*Latency in PaDeviceInfo, *Latency in PaStreamInfo | @see default*Latency in PaDeviceInfo, *Latency in PaStreamInfo | |||
*/ | */ | |||
PaTime suggestedLatency; | PaTime suggestedLatency; | |||
/** An optional pointer to a host api specific data structure | /** An optional pointer to a host api specific data structure | |||
containing additional information for device setup and/or stream proce ssing. | containing additional information for device setup and/or stream proce ssing. | |||
hostApiSpecificStreamInfo is never required for correct operation, | hostApiSpecificStreamInfo is never required for correct operation, | |||
skipping to change at line 667 | skipping to change at line 672 | |||
paContinue=0, | paContinue=0, | |||
paComplete=1, | paComplete=1, | |||
paAbort=2 | paAbort=2 | |||
} PaStreamCallbackResult; | } PaStreamCallbackResult; | |||
/** | /** | |||
Functions of type PaStreamCallback are implemented by PortAudio clients. | Functions of type PaStreamCallback are implemented by PortAudio clients. | |||
They consume, process or generate audio in response to requests from an | They consume, process or generate audio in response to requests from an | |||
active PortAudio stream. | active PortAudio stream. | |||
@param input and @param output are arrays of interleaved samples, | @param input and @param output are either arrays of interleaved samples or | |||
the format, packing and number of channels used by the buffers are | ; | |||
if non-interleaved samples were requested using the paNonInterleaved sampl | ||||
e | ||||
format flag, an array of buffer pointers, one non-interleaved buffer for | ||||
each channel. | ||||
The format, packing and number of channels used by the buffers are | ||||
determined by parameters to Pa_OpenStream(). | determined by parameters to Pa_OpenStream(). | |||
@param frameCount The number of sample frames to be processed by | @param frameCount The number of sample frames to be processed by | |||
the stream callback. | the stream callback. | |||
@param timeInfo The time in seconds when the first sample of the input | @param timeInfo The time in seconds when the first sample of the input | |||
buffer was received at the audio input, the time in seconds when the first | buffer was received at the audio input, the time in seconds when the first | |||
sample of the output buffer will begin being played at the audio output, a nd | sample of the output buffer will begin being played at the audio output, a nd | |||
the time in seconds when the stream callback was called. | the time in seconds when the stream callback was called. | |||
See also Pa_GetStreamTime() | See also Pa_GetStreamTime() | |||
skipping to change at line 696 | skipping to change at line 705 | |||
@return | @return | |||
The stream callback should return one of the values in the | The stream callback should return one of the values in the | |||
PaStreamCallbackResult enumeration. To ensure that the callback continues | PaStreamCallbackResult enumeration. To ensure that the callback continues | |||
to be called, it should return paContinue (0). Either paComplete or paAbor t | to be called, it should return paContinue (0). Either paComplete or paAbor t | |||
can be returned to finish stream processing, after either of these values is | can be returned to finish stream processing, after either of these values is | |||
returned the callback will not be called again. If paAbort is returned the | returned the callback will not be called again. If paAbort is returned the | |||
stream will finish as soon as possible. If paComplete is returned, the str eam | stream will finish as soon as possible. If paComplete is returned, the str eam | |||
will continue until all buffers generated by the callback have been played . | will continue until all buffers generated by the callback have been played . | |||
This may be useful in applications such as soundfile players where a speci fic | This may be useful in applications such as soundfile players where a speci fic | |||
duration of output is required. However, it is not necessary to utilise th is | duration of output is required. However, it is not necessary to utilize th is | |||
mechanism as Pa_StopStream(), Pa_AbortStream() or Pa_CloseStream() can als o | mechanism as Pa_StopStream(), Pa_AbortStream() or Pa_CloseStream() can als o | |||
be used to stop the stream. The callback must always fill the entire outpu t | be used to stop the stream. The callback must always fill the entire outpu t | |||
buffer irrespective of its return value. | buffer irrespective of its return value. | |||
@see Pa_OpenStream, Pa_OpenDefaultStream | @see Pa_OpenStream, Pa_OpenDefaultStream | |||
@note With the exception of Pa_GetStreamCpuLoad() it is not permissable to call | @note With the exception of Pa_GetStreamCpuLoad() it is not permissible to call | |||
PortAudio API functions from within the stream callback. | PortAudio API functions from within the stream callback. | |||
*/ | */ | |||
typedef int PaStreamCallback( | typedef int PaStreamCallback( | |||
const void *input, void *output, | const void *input, void *output, | |||
unsigned long frameCount, | unsigned long frameCount, | |||
const PaStreamCallbackTimeInfo* timeInfo, | const PaStreamCallbackTimeInfo* timeInfo, | |||
PaStreamCallbackFlags statusFlags, | PaStreamCallbackFlags statusFlags, | |||
void *userData ); | void *userData ); | |||
/** Opens a stream for either input, output or both. | /** Opens a stream for either input, output or both. | |||
skipping to change at line 732 | skipping to change at line 741 | |||
@param outputParameters A structure that describes the output parameters u sed by | @param outputParameters A structure that describes the output parameters u sed by | |||
the opened stream. See PaStreamParameters for a description of these param eters. | the opened stream. See PaStreamParameters for a description of these param eters. | |||
outputParameters must be NULL for input-only streams. | outputParameters must be NULL for input-only streams. | |||
@param sampleRate The desired sampleRate. For full-duplex streams it is th e | @param sampleRate The desired sampleRate. For full-duplex streams it is th e | |||
sample rate for both input and output | sample rate for both input and output | |||
@param framesPerBuffer The number of frames passed to the stream callback | @param framesPerBuffer The number of frames passed to the stream callback | |||
function, or the preferred block granularity for a blocking read/write str eam. | function, or the preferred block granularity for a blocking read/write str eam. | |||
The special value paFramesPerBufferUnspecified (0) may be used to request that | The special value paFramesPerBufferUnspecified (0) may be used to request that | |||
the stream callback will recieve an optimal (and possibly varying) number of | the stream callback will receive an optimal (and possibly varying) number of | |||
frames based on host requirements and the requested latency settings. | frames based on host requirements and the requested latency settings. | |||
Note: With some host APIs, the use of non-zero framesPerBuffer for a callb ack | Note: With some host APIs, the use of non-zero framesPerBuffer for a callb ack | |||
stream may introduce an additional layer of buffering which could introduc e | stream may introduce an additional layer of buffering which could introduc e | |||
additional latency. PortAudio guarantees that the additional latency | additional latency. PortAudio guarantees that the additional latency | |||
will be kept to the theoretical minimum however, it is strongly recommende d | will be kept to the theoretical minimum however, it is strongly recommende d | |||
that a non-zero framesPerBuffer value only be used when your algorithm | that a non-zero framesPerBuffer value only be used when your algorithm | |||
requires a fixed number of frames per stream callback. | requires a fixed number of frames per stream callback. | |||
@param streamFlags Flags which modify the behaviour of the streaming proce ss. | @param streamFlags Flags which modify the behavior of the streaming proces s. | |||
This parameter may contain a combination of flags ORed together. Some flag s may | This parameter may contain a combination of flags ORed together. Some flag s may | |||
only be relevant to certain buffer formats. | only be relevant to certain buffer formats. | |||
@param streamCallback A pointer to a client supplied function that is resp onsible | @param streamCallback A pointer to a client supplied function that is resp onsible | |||
for processing and filling input and output buffers. If this parameter is NULL | for processing and filling input and output buffers. If this parameter is NULL | |||
the stream will be opened in 'blocking read/write' mode. In blocking mode, | the stream will be opened in 'blocking read/write' mode. In blocking mode, | |||
the client can receive sample data using Pa_ReadStream and write sample da ta | the client can receive sample data using Pa_ReadStream and write sample da ta | |||
using Pa_WriteStream, the number of samples that may be read or written | using Pa_WriteStream, the number of samples that may be read or written | |||
without blocking is returned by Pa_GetStreamReadAvailable and | without blocking is returned by Pa_GetStreamReadAvailable and | |||
Pa_GetStreamWriteAvailable respectively. | Pa_GetStreamWriteAvailable respectively. | |||
skipping to change at line 789 | skipping to change at line 798 | |||
@param stream The address of a PaStream pointer which will receive | @param stream The address of a PaStream pointer which will receive | |||
a pointer to the newly opened stream. | a pointer to the newly opened stream. | |||
@param numInputChannels The number of channels of sound that will be supp lied | @param numInputChannels The number of channels of sound that will be supp lied | |||
to the stream callback or returned by Pa_ReadStream. It can range from 1 t o | to the stream callback or returned by Pa_ReadStream. It can range from 1 t o | |||
the value of maxInputChannels in the PaDeviceInfo record for the default i nput | the value of maxInputChannels in the PaDeviceInfo record for the default i nput | |||
device. If 0 the stream is opened as an output-only stream. | device. If 0 the stream is opened as an output-only stream. | |||
@param numOutputChannels The number of channels of sound to be delivered t o the | @param numOutputChannels The number of channels of sound to be delivered t o the | |||
stream callback or passed to Pa_WriteStream. It can range from 1 to the va lue | stream callback or passed to Pa_WriteStream. It can range from 1 to the va lue | |||
of maxOutputChannels in the PaDeviceInfo record for the default output dvi ce. | of maxOutputChannels in the PaDeviceInfo record for the default output dev ice. | |||
If 0 the stream is opened as an output-only stream. | If 0 the stream is opened as an output-only stream. | |||
@param sampleFormat The sample format of both the input and output buffers | @param sampleFormat The sample format of both the input and output buffers | |||
provided to the callback or passed to and from Pa_ReadStream and Pa_WriteS tream. | provided to the callback or passed to and from Pa_ReadStream and Pa_WriteS tream. | |||
sampleFormat may be any of the formats described by the PaSampleFormat | sampleFormat may be any of the formats described by the PaSampleFormat | |||
enumeration. | enumeration. | |||
@param sampleRate Same as Pa_OpenStream parameter of the same name. | @param sampleRate Same as Pa_OpenStream parameter of the same name. | |||
@param framesPerBuffer Same as Pa_OpenStream parameter of the same name. | @param framesPerBuffer Same as Pa_OpenStream parameter of the same name. | |||
@param streamCallback Same as Pa_OpenStream parameter of the same name. | @param streamCallback Same as Pa_OpenStream parameter of the same name. | |||
skipping to change at line 950 | skipping to change at line 959 | |||
@param stream A pointer to an open stream previously created with Pa_OpenS tream. | @param stream A pointer to an open stream previously created with Pa_OpenS tream. | |||
@note PortAudio manages the memory referenced by the returned pointer, | @note PortAudio manages the memory referenced by the returned pointer, | |||
the client must not manipulate or free the memory. The pointer is only | the client must not manipulate or free the memory. The pointer is only | |||
guaranteed to be valid until the specified stream is closed. | guaranteed to be valid until the specified stream is closed. | |||
@see PaStreamInfo | @see PaStreamInfo | |||
*/ | */ | |||
const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream ); | const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream ); | |||
/** Determine the current time for the stream according to the same clock u | /** Returns the current time in seconds for a stream according to the same | |||
sed | clock used | |||
to generate buffer timestamps. This time may be used for syncronising othe | to generate callback PaStreamCallbackTimeInfo timestamps. The time values | |||
r | are | |||
events to the audio stream, for example synchronizing audio to MIDI. | monotonically increasing and have unspecified origin. | |||
Pa_GetStreamTime returns valid time values for the entire life of the stre | ||||
am, | ||||
from when the stream is opened until it is closed. Starting and stopping t | ||||
he stream | ||||
does not affect the passage of time returned by Pa_GetStreamTime. | ||||
This time may be used for synchronizing other events to the audio stream, | ||||
for | ||||
example synchronizing audio to MIDI. | ||||
@return The stream's current time in seconds, or 0 if an error occurred. | @return The stream's current time in seconds, or 0 if an error occurred. | |||
@see PaTime, PaStreamCallback | @see PaTime, PaStreamCallback, PaStreamCallbackTimeInfo | |||
*/ | */ | |||
PaTime Pa_GetStreamTime( PaStream *stream ); | PaTime Pa_GetStreamTime( PaStream *stream ); | |||
/** Retrieve CPU usage information for the specified stream. | /** Retrieve CPU usage information for the specified stream. | |||
The "CPU Load" is a fraction of total CPU time consumed by a callback stre am's | The "CPU Load" is a fraction of total CPU time consumed by a callback stre am's | |||
audio processing routines including, but not limited to the client supplie d | audio processing routines including, but not limited to the client supplie d | |||
stream callback. This function does not work with blocking read/write stre ams. | stream callback. This function does not work with blocking read/write stre ams. | |||
This function may be called from the stream callback function or the | This function may be called from the stream callback function or the | |||
application. | application. | |||
@return | @return | |||
A floating point value, typically between 0.0 and 1.0, where 1.0 indicates | A floating point value, typically between 0.0 and 1.0, where 1.0 indicates | |||
that the stream callback is consuming the maximum number of CPU cycles pos sible | that the stream callback is consuming the maximum number of CPU cycles pos sible | |||
to maintain real-time operation. A value of 0.5 would imply that PortAudio and | to maintain real-time operation. A value of 0.5 would imply that PortAudio and | |||
the stream callback was consuming roughly 50% of the available CPU time. T he | the stream callback was consuming roughly 50% of the available CPU time. T he | |||
return value may exceed 1.0. A value of 0.0 will always be returned for a | return value may exceed 1.0. A value of 0.0 will always be returned for a | |||
blocking read/write stream, or if an error occurrs. | blocking read/write stream, or if an error occurs. | |||
*/ | */ | |||
double Pa_GetStreamCpuLoad( PaStream* stream ); | double Pa_GetStreamCpuLoad( PaStream* stream ); | |||
/** Read samples from an input stream. The function doesn't return until | /** Read samples from an input stream. The function doesn't return until | |||
the entire buffer has been filled - this may involve waiting for the opera ting | the entire buffer has been filled - this may involve waiting for the opera ting | |||
system to supply the data. | system to supply the data. | |||
@param stream A pointer to an open stream previously created with Pa_OpenS tream. | @param stream A pointer to an open stream previously created with Pa_OpenS tream. | |||
@param buffer A pointer to a buffer of sample frames. The buffer contains | @param buffer A pointer to a buffer of sample frames. The buffer contains | |||
samples in the format specified by the inputParameters->sampleFormat field | samples in the format specified by the inputParameters->sampleFormat field | |||
used to open the stream, and the number of channels specified by | used to open the stream, and the number of channels specified by | |||
inputParameters->numChannels. If non-interleaved samples were requested, | inputParameters->numChannels. If non-interleaved samples were requested us | |||
buffer is a pointer to the first element of an array of non-interleaved | ing | |||
buffer pointers, one for each channel. | the paNonInterleaved sample format flag, buffer is a pointer to the first | |||
element | ||||
of an array of buffer pointers, one non-interleaved buffer for each channe | ||||
l. | ||||
@param frames The number of frames to be read into buffer. This parameter | @param frames The number of frames to be read into buffer. This parameter | |||
is not constrained to a specific range, however high performance applicati ons | is not constrained to a specific range, however high performance applicati ons | |||
will want to match this parameter to the framesPerBuffer parameter used | will want to match this parameter to the framesPerBuffer parameter used | |||
when opening the stream. | when opening the stream. | |||
@return On success PaNoError will be returned, or PaInputOverflowed if inp ut | @return On success PaNoError will be returned, or PaInputOverflowed if inp ut | |||
data was discarded by PortAudio after the previous call and before this ca ll. | data was discarded by PortAudio after the previous call and before this ca ll. | |||
*/ | */ | |||
PaError Pa_ReadStream( PaStream* stream, | PaError Pa_ReadStream( PaStream* stream, | |||
skipping to change at line 1012 | skipping to change at line 1028 | |||
/** Write samples to an output stream. This function doesn't return until t he | /** Write samples to an output stream. This function doesn't return until t he | |||
entire buffer has been consumed - this may involve waiting for the operati ng | entire buffer has been consumed - this may involve waiting for the operati ng | |||
system to consume the data. | system to consume the data. | |||
@param stream A pointer to an open stream previously created with Pa_OpenS tream. | @param stream A pointer to an open stream previously created with Pa_OpenS tream. | |||
@param buffer A pointer to a buffer of sample frames. The buffer contains | @param buffer A pointer to a buffer of sample frames. The buffer contains | |||
samples in the format specified by the outputParameters->sampleFormat fiel d | samples in the format specified by the outputParameters->sampleFormat fiel d | |||
used to open the stream, and the number of channels specified by | used to open the stream, and the number of channels specified by | |||
outputParameters->numChannels. If non-interleaved samples were requested, | outputParameters->numChannels. If non-interleaved samples were requested u | |||
buffer is a pointer to the first element of an array of non-interleaved | sing | |||
buffer pointers, one for each channel. | the paNonInterleaved sample format flag, buffer is a pointer to the first | |||
element | ||||
of an array of buffer pointers, one non-interleaved buffer for each channe | ||||
l. | ||||
@param frames The number of frames to be written from buffer. This paramet er | @param frames The number of frames to be written from buffer. This paramet er | |||
is not constrained to a specific range, however high performance applicati ons | is not constrained to a specific range, however high performance applicati ons | |||
will want to match this parameter to the framesPerBuffer parameter used | will want to match this parameter to the framesPerBuffer parameter used | |||
when opening the stream. | when opening the stream. | |||
@return On success PaNoError will be returned, or paOutputUnderflowed if | @return On success PaNoError will be returned, or paOutputUnderflowed if | |||
additional output data was inserted after the previous call and before thi s | additional output data was inserted after the previous call and before thi s | |||
call. | call. | |||
*/ | */ | |||
End of changes. 25 change blocks. | ||||
46 lines changed or deleted | 69 lines changed or added | |||