Tutorial   Class/Enum List   File List   Compound Members  

RtAudio Class Reference

Realtime audio i/o C++ classes. More...

#include <RtAudio.h>

List of all members.

Public Types

enum  RtAudioApi {
  UNSPECIFIED, LINUX_ALSA, LINUX_OSS, LINUX_JACK,
  MACOSX_CORE, IRIX_AL, WINDOWS_ASIO, WINDOWS_DS
}
 Audio API specifier arguments. More...

Public Member Functions

 RtAudio (RtAudioApi api=UNSPECIFIED)
 The default class constructor.
 RtAudio (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers, RtAudioApi api=UNSPECIFIED)
 A constructor which can be used to open a stream during instantiation.
 RtAudio (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int *numberOfBuffers, RtAudioApi api=UNSPECIFIED)
 An overloaded constructor which opens a stream and also returns numberOfBuffers parameter via pointer argument.
 ~RtAudio ()
 The destructor.
void openStream (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers)
 A public method for opening a stream with the specified parameters.
void openStream (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int *numberOfBuffers)
 A public method for opening a stream and also returning numberOfBuffers parameter via pointer argument.
void setStreamCallback (RtAudioCallback callback, void *userData)
 A public method which sets a user-defined callback function for a given stream.
void cancelStreamCallback ()
 A public method which cancels a callback process and function for the stream.
int getDeviceCount (void)
 A public method which returns the number of audio devices found.
RtAudioDeviceInfo getDeviceInfo (int device)
 Return an RtAudioDeviceInfo structure for a specified device number.
char *const getStreamBuffer ()
 A public method which returns a pointer to the buffer for an open stream.
void tickStream ()
 Public method used to trigger processing of input/output data for a stream.
void closeStream ()
 Public method which closes a stream and frees any associated buffers.
void startStream ()
 Public method which starts a stream.
void stopStream ()
 Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.
void abortStream ()
 Stop a stream, discarding any samples remaining in the input/output queue.


Detailed Description

Realtime audio i/o C++ classes.

RtAudio provides a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA, Jack, and OSS), SGI, Macintosh OS X (CoreAudio), and Windows (DirectSound and ASIO) operating systems.

RtAudio WWW site: http://music.mcgill.ca/~gary/rtaudio/

RtAudio: realtime audio i/o C++ classes Copyright (c) 2001-2005 Gary P. Scavone

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Any person wishing to distribute modifications to the Software is requested to send the modifications to the original developer so that they can be incorporated into the canonical version.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Member Enumeration Documentation

enum RtAudio::RtAudioApi
 

Audio API specifier arguments.

Enumerator:
UNSPECIFIED  Search for a working compiled API.
LINUX_ALSA  The Advanced Linux Sound Architecture API.
LINUX_OSS  The Linux Open Sound System API.
LINUX_JACK  The Linux Jack Low-Latency Audio Server API.
MACOSX_CORE  Macintosh OS-X Core Audio API.
IRIX_AL  The Irix Audio Library API.
WINDOWS_ASIO  The Steinberg Audio Stream I/O API.
WINDOWS_DS  The Microsoft Direct Sound API.


Constructor & Destructor Documentation

RtAudio::RtAudio RtAudioApi  api = UNSPECIFIED  ) 
 

The default class constructor.

Probes the system to make sure at least one audio input/output device is available and determines the api-specific identifier for each device found. An RtError error can be thrown if no devices are found or if a memory allocation error occurs.

If no API argument is specified and multiple API support has been compiled, the default order of use is JACK, ALSA, OSS (Linux systems) and ASIO, DS (Windows systems).

RtAudio::RtAudio int  outputDevice,
int  outputChannels,
int  inputDevice,
int  inputChannels,
RtAudioFormat  format,
int  sampleRate,
int *  bufferSize,
int  numberOfBuffers,
RtAudioApi  api = UNSPECIFIED
 

A constructor which can be used to open a stream during instantiation.

The specified output and/or input device identifiers correspond to those enumerated via the getDeviceInfo() method. If device = 0, the default or first available devices meeting the given parameters is selected. If an output or input channel value is zero, the corresponding device value is ignored. When a stream is successfully opened, its identifier is returned via the "streamId" pointer. An RtError can be thrown if no devices are found for the given parameters, if a memory allocation error occurs, or if a driver error occurs.

See also:
openStream()

RtAudio::RtAudio int  outputDevice,
int  outputChannels,
int  inputDevice,
int  inputChannels,
RtAudioFormat  format,
int  sampleRate,
int *  bufferSize,
int *  numberOfBuffers,
RtAudioApi  api = UNSPECIFIED
 

An overloaded constructor which opens a stream and also returns numberOfBuffers parameter via pointer argument.

See the previous constructor call for details. This overloaded version differs only in that it takes a pointer argument for the numberOfBuffers parameter and returns the value used by the audio device (which may be different from that requested). Note that the numberofBuffers parameter is not used with the Linux Jack, Macintosh CoreAudio, and Windows ASIO APIs.

RtAudio::~RtAudio  ) 
 

The destructor.

Stops and closes an open stream and devices and deallocates buffer and structure memory.


Member Function Documentation

void RtAudio::openStream int  outputDevice,
int  outputChannels,
int  inputDevice,
int  inputChannels,
RtAudioFormat  format,
int  sampleRate,
int *  bufferSize,
int  numberOfBuffers
 

A public method for opening a stream with the specified parameters.

An RtError is thrown if a stream cannot be opened.

Parameters:
outputDevice,: If equal to 0, the default or first device found meeting the given parameters is opened. Otherwise, the device number should correspond to one of those enumerated via the getDeviceInfo() method.
outputChannels,: The desired number of output channels. If equal to zero, the outputDevice identifier is ignored.
inputDevice,: If equal to 0, the default or first device found meeting the given parameters is opened. Otherwise, the device number should correspond to one of those enumerated via the getDeviceInfo() method.
inputChannels,: The desired number of input channels. If equal to zero, the inputDevice identifier is ignored.
format,: An RtAudioFormat specifying the desired sample data format.
sampleRate,: The desired sample rate (sample frames per second).
*bufferSize,: A pointer value indicating the desired internal buffer size in sample frames. The actual value used by the device is returned via the same pointer. A value of zero can be specified, in which case the lowest allowable value is determined.
numberOfBuffers,: A value which can be used to help control device latency. More buffers typically result in more robust performance, though at a cost of greater latency. A value of zero can be specified, in which case the lowest allowable value is used.

void RtAudio::openStream int  outputDevice,
int  outputChannels,
int  inputDevice,
int  inputChannels,
RtAudioFormat  format,
int  sampleRate,
int *  bufferSize,
int *  numberOfBuffers
 

A public method for opening a stream and also returning numberOfBuffers parameter via pointer argument.

See the previous function call for details. This overloaded version differs only in that it takes a pointer argument for the numberOfBuffers parameter and returns the value used by the audio device (which may be different from that requested). Note that the numberofBuffers parameter is not used with the Linux Jack, Macintosh CoreAudio, and Windows ASIO APIs.

void RtAudio::setStreamCallback RtAudioCallback  callback,
void *  userData
[inline]
 

A public method which sets a user-defined callback function for a given stream.

This method assigns a callback function to a previously opened stream for non-blocking stream functionality. A separate process is initiated, though the user function is called only when the stream is "running" (between calls to the startStream() and stopStream() methods, respectively). The callback process remains active for the duration of the stream and is automatically shutdown when the stream is closed (via the closeStream() method or by object destruction). The callback process can also be shutdown and the user function de-referenced through an explicit call to the cancelStreamCallback() method. Note that the stream can use only blocking or callback functionality at a particular time, though it is possible to alternate modes on the same stream through the use of the setStreamCallback() and cancelStreamCallback() methods (the blocking tickStream() method can be used before a callback is set and/or after a callback is cancelled). An RtError will be thrown if called when no stream is open or a thread errors occurs.

void RtAudio::cancelStreamCallback  )  [inline]
 

A public method which cancels a callback process and function for the stream.

This method shuts down a callback process and de-references the user function for the stream. Callback functionality can subsequently be restarted on the stream via the setStreamCallback() method. An RtError will be thrown if called when no stream is open.

RtAudioDeviceInfo RtAudio::getDeviceInfo int  device  )  [inline]
 

Return an RtAudioDeviceInfo structure for a specified device number.

Any device integer between 1 and getDeviceCount() is valid. If a device is busy or otherwise unavailable, the structure member "probed" will have a value of "false" and all other members are undefined. If the specified device is the current default input or output device, the "isDefault" member will have a value of "true". An RtError will be thrown for an invalid device argument.

char* const RtAudio::getStreamBuffer  )  [inline]
 

A public method which returns a pointer to the buffer for an open stream.

The user should fill and/or read the buffer data in interleaved format and then call the tickStream() method. An RtError will be thrown if called when no stream is open.

void RtAudio::tickStream  )  [inline]
 

Public method used to trigger processing of input/output data for a stream.

This method blocks until all buffer data is read/written. An RtError will be thrown if a driver error occurs or if called when no stream is open.

void RtAudio::closeStream  )  [inline]
 

Public method which closes a stream and frees any associated buffers.

If a stream is not open, this method issues a warning and returns (an RtError is not thrown).

void RtAudio::startStream  )  [inline]
 

Public method which starts a stream.

An RtError will be thrown if a driver error occurs or if called when no stream is open.

void RtAudio::stopStream  )  [inline]
 

Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.

An RtError will be thrown if a driver error occurs or if called when no stream is open.

void RtAudio::abortStream  )  [inline]
 

Stop a stream, discarding any samples remaining in the input/output queue.

An RtError will be thrown if a driver error occurs or if called when no stream is open.


The documentation for this class was generated from the following file:
©2001-2005 Gary P. Scavone, McGill University. All Rights Reserved.
Maintained by Gary P. Scavone, gary@music.mcgill.ca