RtAudio 3.0.3 review
DownloadRtAudio is a set of C++ classes which provide a common API for realtime audio input/output across Linux (native JACK, ALSA and OSS),
|
|
RtAudio is a set of C++ classes which provide a common API for realtime audio input/output across Linux (native JACK, ALSA and OSS), Macintosh OS X, SGI, and Windows (DirectSound and ASIO) operating systems. RtAudio significantly simplifies the process of interacting with computer audio hardware.
Here are some key features of "RtAudio":
object oriented C++ design
simple, common API across all supported platforms
only two header files and one source file for easy inclusion in programming projects
allow simultaneous multi-api support
blocking functionality
callback functionality
extensive audio device parameter control
audio device capability probing
automatic internal conversion for data format, channel number compensation, de-interleaving, and byte-swapping
RtAudio incorporates the concept of audio streams, which represent audio output (playback) and/or input (recording). Available audio devices and their capabilities can be enumerated and then specified when opening a stream. Where applicable, multiple API support can be compiled and a particular API specified when creating an RtAudio instance. See the API Notes section for information specific to each of the supported audio APIs.
The RtAudio API provides both blocking (synchronous) and callback (asynchronous) functionality. Callbacks are typically used in conjunction with graphical user interfaces (GUI). Blocking functionality is often necessary for explicit control of multiple input/output stream synchronization or when audio must be synchronized with other system events.
Getting Started
With version 3.0, it is now possible to compile multiple API support on a given platform and to specify an API choice during class instantiation. In the examples that follow, no API will be specified (in which case, RtAudio attempts to select the most "logical" available API).
The first thing that must be done when using RtAudio is to create an instance of the class. The default constructor scans the underlying audio system to verify that at least one device is available. RtAudio often uses C++ exceptions to report errors, necessitating try/catch blocks around most member functions. The following code example demonstrates default object construction and destruction:
#include "RtAudio.h"
int main()
{
RtAudio *audio = 0;
// Default RtAudio constructor
try {
audio = new RtAudio();
}
catch (RtError &error) {
// Handle the exception here
error.printMessage();
}
// Clean up
delete audio;
}
Obviously, this example doesn't demonstrate any of the real functionality of RtAudio. However, all uses of RtAudio must begin with a constructor (either default or overloaded varieties) and must end with class destruction. Further, it is necessary that all class methods that can throw a C++ exception be called within a try/catch block.
What's New in This Release:
RtAudio now allows simultaneous multi-api support. For example, you can compile RtAudio to provide both DirectSound and ASIO support on Windows platforms or ALSA, JACK, and OSS support on Linux platforms. This was accomplished by creating an abstract base class, RtApi, with subclasses for each supported API (RtApiAlsa, RtApiJack, RtApiOss, RtApiDs, RtApiAsio, RtApiCore, and RtApiAl). The class RtAudio is now a "controller" which creates an instance of an RtApi subclass based on the user's API choice via an optional RtAudio::RtAudioApi instantiation argument. If no API is specified, RtAudio attempts to make a "logical" API selection.
Support for the JACK low-latency audio server has been added with this version of RtAudio. It is necessary to have the JACK server running before creating an instance of RtAudio.
Several API changes have been made in version 3.0 of RtAudio in an effort to provide more consistent behavior across all supported audio APIs. The most significant of these changes is that multiple stream support from a single RtAudio instance has been discontinued. As a result, stream identifier input arguments are no longer required. Also, the RtAudio::streamWillBlock() function was poorly supported by most APIs and has been deprecated (though the function still exists in those subclasses of RtApi that do allow it to be implemented).
The RtAudio::getDeviceInfo() function was modified to return a globally defined RtAudioDeviceInfo structure. This structure is a simplified version of the previous RTAUDIO_DEVICE structure. In addition, the RTAUDIO_FORMAT structure was renamed RtAudioFormat and defined globally within RtAudio.h. These changes were made for clarity and to better conform with standard C++ programming practices.
The RtError class declaration and definition have been extracted to a separate file (RtError.h). This was done in preparation for a new release of the RtMidi class (planned for Summer 2004).
RtAudio 3.0.3 keywords