1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-04-25 23:44:13 +02:00

Move library tree where it belongs

This commit is contained in:
ra
2010-01-24 09:19:39 +00:00
parent e74978ba77
commit 58caf78a86
6020 changed files with 2790154 additions and 0 deletions

View File

@@ -0,0 +1,155 @@
# Doxyfile 1.2.6
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = RtAudio
PROJECT_NUMBER =
OUTPUT_DIRECTORY = .
OUTPUT_LANGUAGE = English
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = NO
CLASS_DIAGRAMS = YES
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
VERBATIM_HEADERS = YES
SHOW_INCLUDE_FILES = YES
JAVADOC_AUTOBRIEF = NO
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
ENABLED_SECTIONS =
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
ALIASES =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = NO
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = tutorial.txt ../../RtAudio.h ../../RtError.h
FILE_PATTERNS =
RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = ../html
HTML_HEADER = header.html
HTML_FOOTER = footer.html
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = YES
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
COMPACT_LATEX = NO
PAPER_TYPE = letter
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_PATH =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME = search.cgi
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH = /usr/local/bin/
EXT_DOC_PATHS =

View File

@@ -0,0 +1,9 @@
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,9 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>

View File

@@ -0,0 +1,721 @@
/*! \mainpage The RtAudio Tutorial
<BODY BGCOLOR="white">
<CENTER>\ref intro &nbsp;&nbsp; \ref changes &nbsp;&nbsp;\ref download &nbsp;&nbsp; \ref start &nbsp;&nbsp; \ref error &nbsp;&nbsp; \ref probing &nbsp;&nbsp; \ref settings &nbsp;&nbsp; \ref playbackb &nbsp;&nbsp; \ref playbackc &nbsp;&nbsp; \ref recording &nbsp;&nbsp; \ref duplex &nbsp;&nbsp; \ref multi &nbsp;&nbsp; \ref methods &nbsp;&nbsp; \ref compiling &nbsp;&nbsp; \ref debug &nbsp;&nbsp; \ref apinotes &nbsp;&nbsp; \ref acknowledge &nbsp;&nbsp; \ref license</CENTER>
\section intro Introduction
RtAudio is a set of C++ classes which provide a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA, JACK, and OSS), Macintosh OS X, SGI, and Windows (DirectSound and ASIO) operating systems. RtAudio significantly simplifies the process of interacting with computer audio hardware. It was designed with the following goals:
<UL>
<LI>object oriented C++ design</LI>
<LI>simple, common API across all supported platforms</LI>
<LI>only two header files and one source file for easy inclusion in programming projects</LI>
<LI>allow simultaneous multi-api support</LI>
<LI>blocking functionality</LI>
<LI>callback functionality</LI>
<LI>extensive audio device parameter control</LI>
<LI>audio device capability probing</LI>
<LI>automatic internal conversion for data format, channel number compensation, de-interleaving, and byte-swapping</LI>
</UL>
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 \ref apinotes 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.
\section changes What's New (Version 3.0)
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).
\section download Download
Latest Release (22 March 2004): <A href="http://music.mcgill.ca/~gary/rtaudio/release/rtaudio-3.0.1.tar.gz">Version 3.0.1 (200 kB tar/gzipped)</A>
\section start 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:
\code
#include "RtAudio.h"
int main()
{
RtAudio *audio;
// Default RtAudio constructor
try {
audio = new RtAudio();
}
catch (RtError &error) {
// Handle the exception here
error.printMessage();
}
// Clean up
delete audio;
}
\endcode
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 which can throw a C++ exception be called within a try/catch block.
\section error Error Handling
RtAudio uses a C++ exception handler called RtError, which is declared and defined in RtError.h. The RtError class is quite simple but it does allow errors to be "caught" by RtError::Type. Almost all RtAudio methods can "throw" an RtError, most typically if a driver error occurs or a stream function is called when no stream is open. There are a number of cases within RtAudio where warning messages may be displayed but an exception is not thrown. There is a protected RtAudio method, error(), which can be modified to globally control how these messages are handled and reported. By default, error messages are not automatically displayed in RtAudio unless the preprocessor definition __RTAUDIO_DEBUG__ is defined. Messages associated with caught exceptions can be displayed with, for example, the RtError::printMessage() function.
\section probing Probing Device Capabilities
A programmer may wish to query the available audio device capabilities before deciding which to use. The following example outlines how this can be done.
\code
// probe.cpp
#include <iostream>
#include "RtAudio.h"
int main()
{
RtAudio *audio;
// Default RtAudio constructor
try {
audio = new RtAudio();
}
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
// Determine the number of devices available
int devices = audio->getDeviceCount();
// Scan through devices for various capabilities
RtAudioDeviceInfo info;
for (int i=1; i<=devices; i++) {
try {
info = audio->getDeviceInfo(i);
}
catch (RtError &error) {
error.printMessage();
break;
}
// Print, for example, the maximum number of output channels for each device
std::cout << "device = " << i;
std::cout << ": maximum output channels = " << info.outputChannels << "\n";
}
// Clean up
delete audio;
return 0;
}
\endcode
The RtAudioDeviceInfo structure is defined in RtAudio.h and provides a variety of information useful in assessing the capabilities of a device:
\code
typedef struct RtAudioDeviceInfo{
std::string name; // Character string device identifier.
bool probed; // true if the device capabilities were successfully probed.
int outputChannels; // Maximum output channels supported by device.
int inputChannels; // Maximum input channels supported by device.
int duplexChannels; // Maximum simultaneous input/output channels supported by device.
bool isDefault; // true if this is the default output or input device.
std::vector<int> sampleRates; // Supported sample rates.
RtAudioFormat nativeFormats; // Bit mask of supported data formats.
};
\endcode
The following data formats are defined and fully supported by RtAudio:
\code
typedef unsigned long RtAudioFormat;
static const RtAudioFormat RTAUDIO_SINT8; // Signed 8-bit integer
static const RtAudioFormat RTAUDIO_SINT16; // Signed 16-bit integer
static const RtAudioFormat RTAUDIO_SINT24; // Signed 24-bit integer (upper 3 bytes of 32-bit signed integer.)
static const RtAudioFormat RTAUDIO_SINT32; // Signed 32-bit integer
static const RtAudioFormat RTAUDIO_FLOAT32; // 32-bit float normalized between +/- 1.0
static const RtAudioFormat RTAUDIO_FLOAT64; // 64-bit double normalized between +/- 1.0
\endcode
The <I>nativeFormats</I> member of the RtAudioDeviceInfo structure is a bit mask of the above formats which are natively supported by the device. However, RtAudio will automatically provide format conversion if a particular format is not natively supported. When the <I>probed</I> member of the RtAudioDeviceInfo structure is false, the remaining structure members are undefined and the device is probably unuseable.
While some audio devices may require a minimum channel value greater than one, RtAudio will provide automatic channel number compensation when the number of channels set by the user is less than that required by the device. Channel compensation is <I>NOT</I> possible when the number of channels set by the user is greater than that supported by the device.
It should be noted that the capabilities reported by a device driver or underlying audio API are not always accurate and/or may be dependent on a combination of device settings. For this reason, RtAudio does not typically rely on the queried values when attempting to open a stream.
\section settings Device Settings
The next step in using RtAudio is to open a stream with particular device and parameter settings.
\code
#include "RtAudio.h"
int main()
{
int channels = 2;
int sampleRate = 44100;
int bufferSize = 256; // 256 sample frames
int nBuffers = 4; // number of internal buffers used by device
int device = 0; // 0 indicates the default or first available device
RtAudio *audio;
// Instantiate RtAudio and open a stream within a try/catch block
try {
audio = new RtAudio();
}
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
try {
audio->openStream(device, channels, 0, 0, RTAUDIO_FLOAT32,
sampleRate, &bufferSize, nBuffers);
}
catch (RtError &error) {
error.printMessage();
// Perhaps try other parameters?
}
// Clean up
delete audio;
return 0;
}
\endcode
The RtAudio::openStream() method attempts to open a stream with a specified set of parameter values. In this case, we attempt to open a two channel playback stream with the default output device, 32-bit floating point data, a sample rate of 44100 Hz, a frame rate of 256 sample frames per read/write, and 4 internal device buffers. When device = 0, RtAudio first attempts to open the default audio device with the given parameters. If that attempt fails, RtAudio searches through the remaining available devices in an effort to find a device which will meet the given parameters. If all attempts are unsuccessful, an RtError is thrown. When a non-zero device value is specified, an attempt is made to open that device \e ONLY (device = 1 specifies the first identified device, as reported by RtAudio::getDeviceInfo()).
RtAudio provides four signed integer and two floating point data formats which can be specified using the RtAudioFormat parameter values mentioned earlier. If the opened device does not natively support the given format, RtAudio will automatically perform the necessary data format conversion.
The <I>bufferSize</I> parameter specifies the desired number of sample frames which will be written to and/or read from a device per write/read operation. The <I>nBuffers</I> parameter is used in setting the underlying device buffer parameters. Both the <I>bufferSize</I> and <I>nBuffers</I> parameters can be used to control stream latency though there is no guarantee that the passed values will be those used by a device (the <I>nBuffers</I> parameter is ignored when using the OS X CoreAudio, Linux Jack, and the Windows ASIO APIs). In general, lower values for both parameters will produce less latency but perhaps less robust performance. Both parameters can be specified with values of zero, in which case the smallest allowable values will be used. The <I>bufferSize</I> parameter is passed as a pointer and the actual value used by the stream is set during the device setup procedure. <I>bufferSize</I> values should be a power of two. Optimal and allowable buffer values tend to vary between systems and devices. Check the \ref apinotes section for general guidelines.
As noted earlier, the device capabilities reported by a driver or underlying audio API are not always accurate and/or may be dependent on a combination of device settings. Because of this, RtAudio does not attempt to query a device's capabilities or use previously reported values when opening a device. Instead, RtAudio simply attempts to set the given parameters on a specified device and then checks whether the setup is successful or not.
\section playbackb Playback (blocking functionality)
Once the device is open for playback, there are only a few final steps necessary for realtime audio output. We'll first provide an example (blocking functionality) and then discuss the details.
\code
// playback.cpp
#include "RtAudio.h"
int main()
{
int count;
int channels = 2;
int sampleRate = 44100;
int bufferSize = 256; // 256 sample frames
int nBuffers = 4; // number of internal buffers used by device
float *buffer;
int device = 0; // 0 indicates the default or first available device
RtAudio *audio;
// Open a stream during RtAudio instantiation
try {
audio = new RtAudio(device, channels, 0, 0, RTAUDIO_FLOAT32,
sampleRate, &bufferSize, nBuffers);
}
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
try {
// Get a pointer to the stream buffer
buffer = (float *) audio->getStreamBuffer();
// Start the stream
audio->startStream();
}
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
// An example loop which runs for 40000 sample frames
count = 0;
while (count < 40000) {
// Generate your samples and fill the buffer with bufferSize sample frames of data
...
// Trigger the output of the data buffer
try {
audio->tickStream();
}
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
count += bufferSize;
}
try {
// Stop and close the stream
audio->stopStream();
audio->closeStream();
}
catch (RtError &error) {
error.printMessage();
}
cleanup:
delete audio;
return 0;
}
\endcode
The first thing to notice in this example is that we attempt to open a stream during class instantiation with an overloaded constructor. This constructor simply combines the functionality of the default constructor, used earlier, and the RtAudio::openStream() method. Again, we have specified a device value of 0, indicating that the default or first available device meeting the given parameters should be used. An attempt is made to open the stream with the specified <I>bufferSize</I> value. However, it is possible that the device will not accept this value, in which case the closest allowable size is used and returned via the pointer value. The constructor can fail if no available devices are found, or a memory allocation or device driver error occurs. Note that you should not call the RtAudio destructor if an exception is thrown during instantiation.
Assuming the constructor is successful, it is necessary to get a pointer to the buffer, provided by RtAudio, for use in feeding data to/from the opened stream. Note that the user should <I>NOT</I> attempt to deallocate the stream buffer memory ... memory management for the stream buffer will be automatically controlled by RtAudio. After starting the stream with RtAudio::startStream(), one simply fills that buffer, which is of length equal to the returned <I>bufferSize</I> value, with interleaved audio data (in the specified format) for playback. Finally, a call to the RtAudio::tickStream() routine triggers a blocking write call for the stream.
In general, one should call the RtAudio::stopStream() and RtAudio::closeStream() methods after finishing with a stream. However, both methods will implicitly be called during object destruction if necessary.
\section playbackc Playback (callback functionality)
The primary difference in using RtAudio with callback functionality involves the creation of a user-defined callback function. Here is an example which produces a sawtooth waveform for playback.
\code
#include <iostream>
#include "RtAudio.h"
// Two-channel sawtooth wave generator.
int sawtooth(char *buffer, int bufferSize, void *data)
{
int i, j;
double *my_buffer = (double *) buffer;
double *my_data = (double *) data;
// Write interleaved audio data.
for (i=0; i<bufferSize; i++) {
for (j=0; j<2; j++) {
*my_buffer++ = my_data[j];
my_data[j] += 0.005 * (j+1+(j*0.1));
if (my_data[j] >= 1.0) my_data[j] -= 2.0;
}
}
return 0;
}
int main()
{
int channels = 2;
int sampleRate = 44100;
int bufferSize = 256; // 256 sample frames
int nBuffers = 4; // number of internal buffers used by device
int device = 0; // 0 indicates the default or first available device
double data[2];
char input;
RtAudio *audio;
// Open a stream during RtAudio instantiation
try {
audio = new RtAudio(device, channels, 0, 0, RTAUDIO_FLOAT64,
sampleRate, &bufferSize, nBuffers);
}
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
try {
// Set the stream callback function
audio->setStreamCallback(&sawtooth, (void *)data);
// Start the stream
audio->startStream();
}
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
std::cout << "\nPlaying ... press <enter> to quit.\n";
std::cin.get(input);
try {
// Stop and close the stream
audio->stopStream();
audio->closeStream();
}
catch (RtError &error) {
error.printMessage();
}
cleanup:
delete audio;
return 0;
}
\endcode
After opening the device in exactly the same way as the previous example (except with a data format change), we must set our callback function for the stream using RtAudio::setStreamCallback(). When the underlying audio API uses blocking calls (OSS, ALSA, SGI, and Windows DirectSound), this method will spawn a new process (or thread) which automatically calls the callback function when more data is needed. Callback-based audio APIs (OS X CoreAudio Linux Jack, and ASIO) implement their own event notification schemes. Note that the callback function is called only when the stream is "running" (between calls to the RtAudio::startStream() and RtAudio::stopStream() methods). The last argument to RtAudio::setStreamCallback() is a pointer to arbitrary data that you wish to access from within your callback function.
In this example, we stop the stream with an explicit call to RtAudio::stopStream(). When using callback functionality, it is also possible to stop a stream by returning a non-zero value from the callback function.
Once set with RtAudio::setStreamCallback, the callback process exists for the life of the stream (until the stream is closed with RtAudio::closeStream() or the RtAudio instance is deleted). It is possible to disassociate a callback function and cancel its process for an open stream using the RtAudio::cancelStreamCallback() method. The stream can then be used with blocking functionality or a new callback can be associated with it.
\section recording Recording
Using RtAudio for audio input is almost identical to the way it is used for playback. Here's the blocking playback example rewritten for recording:
\code
// record.cpp
#include "RtAudio.h"
int main()
{
int count;
int channels = 2;
int sampleRate = 44100;
int bufferSize = 256; // 256 sample frames
int nBuffers = 4; // number of internal buffers used by device
float *buffer;
int device = 0; // 0 indicates the default or first available device
RtAudio *audio;
// Instantiate RtAudio and open a stream.
try {
audio = new RtAudio(&stream, 0, 0, device, channels,
RTAUDIO_FLOAT32, sampleRate, &bufferSize, nBuffers);
}
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
try {
// Get a pointer to the stream buffer
buffer = (float *) audio->getStreamBuffer();
// Start the stream
audio->startStream();
}
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
// An example loop which runs for about 40000 sample frames
count = 0;
while (count < 40000) {
// Read a buffer of data
try {
audio->tickStream();
}
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
// Process the input samples (bufferSize sample frames) that were read
...
count += bufferSize;
}
try {
// Stop the stream
audio->stopStream();
}
catch (RtError &error) {
error.printMessage();
}
cleanup:
delete audio;
return 0;
}
\endcode
In this example, the stream was opened for recording with a non-zero <I>inputChannels</I> value. The only other difference between this example and that for playback involves the order of data processing in the loop, where it is necessary to first read a buffer of input data before manipulating it.
\section duplex Duplex Mode
Finally, it is easy to use RtAudio for simultaneous audio input/output, or duplex operation. In this example, we use a callback function and simply scale the input data before sending it back to the output.
\code
// duplex.cpp
#include <iostream>
#include "RtAudio.h"
// Pass-through function.
int scale(char *buffer, int bufferSize, void *)
{
// Note: do nothing here for pass through.
double *my_buffer = (double *) buffer;
// Scale input data for output.
for (int i=0; i<bufferSize; i++) {
// Do for two channels.
*my_buffer++ *= 0.5;
*my_buffer++ *= 0.5;
}
return 0;
}
int main()
{
int channels = 2;
int sampleRate = 44100;
int bufferSize = 256; // 256 sample frames
int nBuffers = 4; // number of internal buffers used by device
int device = 0; // 0 indicates the default or first available device
char input;
RtAudio *audio;
// Open a stream during RtAudio instantiation
try {
audio = new RtAudio(device, channels, device, channels, RTAUDIO_FLOAT64,
sampleRate, &bufferSize, nBuffers);
}
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
try {
// Set the stream callback function
audio->setStreamCallback(&scale, NULL);
// Start the stream
audio->startStream();
}
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
std::cout << "\nRunning duplex ... press <enter> to quit.\n";
std::cin.get(input);
try {
// Stop and close the stream
audio->stopStream();
audio->closeStream();
}
catch (RtError &error) {
error.printMessage();
}
cleanup:
delete audio;
return 0;
}
\endcode
When an RtAudio stream is running in duplex mode (nonzero input <I>AND</I> output channels), the audio write (playback) operation always occurs before the audio read (record) operation. This sequence allows the use of a single buffer to store both output and input data.
As we see with this example, the write-read sequence of operations does not preclude the use of RtAudio in situations where input data is first processed and then output through a duplex stream. When the stream buffer is first allocated, it is initialized with zeros, which produces no audible result when output to the device. In this example, anything recorded by the audio stream input will be scaled and played out during the next round of audio processing.
Note that duplex operation can also be achieved by opening one output stream instance and one input stream instance using the same or different devices. However, there may be timing problems when attempting to use two different devices, due to possible device clock variations, unless a common external "sync" is provided. This becomes even more difficult to achieve using two separate callback streams because it is not possible to <I>explicitly</I> control the calling order of the callback functions.
\section multi Using Simultaneous Multiple APIs
Because support for each audio API is encapsulated in a specific RtApi subclass, it is possible to compile and instantiate multiple API-specific subclasses on a given operating system. For example, one can compile both the RtApiDs and RtApiAsio classes on Windows operating systems by providing the appropriate preprocessor definitions, include files, and libraries for each. In a run-time situation, one might first attempt to determine whether any ASIO device drivers exist. This can be done by specifying the api argument RtAudio::WINDOWS_ASIO when attempting to create an instance of RtAudio. If an RtError is thrown (indicating no available drivers), then an instance of RtAudio with the api argument RtAudio::WINDOWS_DS can be created. Alternately, if no api argument is specified, RtAudio will first look for ASIO drivers and then DirectSound drivers (on Linux systems, the default API search order is Jack, Alsa, and finally OSS). In theory, it should also be possible to have separate instances of RtAudio open at the same time with different underlying audio API support, though this has not been tested. It is difficult to know how well different audio APIs can simultaneously coexist on a given operating system. In particular, it is most unlikely that the same device could be simultaneously controlled with two different audio APIs.
\section methods Summary of Methods
The following is a short summary of public methods (not including constructors and the destructor) provided by RtAudio:
<UL>
<LI>RtAudio::openStream(): opens a stream with the specified parameters.</LI>
<LI>RtAudio::setStreamCallback(): sets a user-defined callback function for the stream.</LI>
<LI>RtAudio::cancelStreamCallback(): cancels a callback process and function for the stream.</LI>
<LI>RtAudio::getDeviceCount(): returns the number of audio devices available.</LI>
<LI>RtAudio::getDeviceInfo(): returns an RtAudioDeviceInfo structure for a specified device.</LI>
<LI>RtAudio::getStreamBuffer(): returns a pointer to the stream buffer.</LI>
<LI>RtAudio::tickStream(): triggers processing of input/output data for the stream (blocking).</LI>
<LI>RtAudio::closeStream(): closes the stream (implicitly called during object destruction).</LI>
<LI>RtAudio::startStream(): (re)starts the stream, typically after it has been stopped with either stopStream() or abortStream() or after first opening the stream.</LI>
<LI>RtAudio::stopStream(): stops the stream, allowing any remaining samples in the queue to be played out and/or read in. This does not implicitly call RtAudio::closeStream().</LI>
<LI>RtAudio::abortStream(): stops the stream, discarding any remaining samples in the queue. This does not implicitly call closeStream().</LI>
</UL>
\section compiling Compiling
In order to compile RtAudio for a specific OS and audio API, it is necessary to supply the appropriate preprocessor definition and library within the compiler statement:
<P>
<TABLE BORDER=2 COLS=5 WIDTH="100%">
<TR BGCOLOR="beige">
<TD WIDTH="5%"><B>OS:</B></TD>
<TD WIDTH="5%"><B>Audio API:</B></TD>
<TD WIDTH="5%"><B>C++ Class:</B></TD>
<TD WIDTH="5%"><B>Preprocessor Definition:</B></TD>
<TD WIDTH="5%"><B>Library or Framework:</B></TD>
<TD><B>Example Compiler Statement:</B></TD>
</TR>
<TR>
<TD>Linux</TD>
<TD>ALSA</TD>
<TD>RtApiAlsa</TD>
<TD>__LINUX_ALSA__</TD>
<TD><TT>asound, pthread</TT></TD>
<TD><TT>g++ -Wall -D__LINUX_ALSA__ -o probe probe.cpp RtAudio.cpp -lasound -lpthread</TT></TD>
</TR>
<TR>
<TD>Linux</TD>
<TD>Jack Audio Server</TD>
<TD>RtApiJack</TD>
<TD>__LINUX_JACK__</TD>
<TD><TT>jack, pthread</TT></TD>
<TD><TT>g++ -Wall -D__LINUX_JACK__ -o probe probe.cpp RtAudio.cpp `pkg-config --cflags --libs jack` -lpthread</TT></TD>
</TR>
<TR>
<TD>Linux</TD>
<TD>OSS</TD>
<TD>RtApiOss</TD>
<TD>__LINUX_OSS__</TD>
<TD><TT>pthread</TT></TD>
<TD><TT>g++ -Wall -D__LINUX_OSS__ -o probe probe.cpp RtAudio.cpp -lpthread</TT></TD>
</TR>
<TR>
<TD>Macintosh OS X</TD>
<TD>CoreAudio</TD>
<TD>RtApiCore</TD>
<TD>__MACOSX_CORE__</TD>
<TD><TT>pthread, stdc++, CoreAudio</TT></TD>
<TD><TT>g++ -Wall -D__MACOSX_CORE__ -o probe probe.cpp RtAudio.cpp -framework CoreAudio -lpthread</TT></TD>
</TR>
<TR>
<TD>Irix</TD>
<TD>AL</TD>
<TD>RtApiAl</TD>
<TD>__IRIX_AL__</TD>
<TD><TT>audio, pthread</TT></TD>
<TD><TT>CC -Wall -D__IRIX_AL__ -o probe probe.cpp RtAudio.cpp -laudio -lpthread</TT></TD>
</TR>
<TR>
<TD>Windows</TD>
<TD>Direct Sound</TD>
<TD>RtApiDs</TD>
<TD>__WINDOWS_DS__</TD>
<TD><TT>dsound.lib (ver. 5.0 or higher), multithreaded</TT></TD>
<TD><I>compiler specific</I></TD>
</TR>
<TR>
<TD>Windows</TD>
<TD>ASIO</TD>
<TD>RtApiAsio</TD>
<TD>__WINDOWS_ASIO__</TD>
<TD><I>various ASIO header and source files</I></TD>
<TD><I>compiler specific</I></TD>
</TR>
</TABLE>
<P>
The example compiler statements above could be used to compile the <TT>probe.cpp</TT> example file, assuming that <TT>probe.cpp</TT>, <TT>RtAudio.h</TT>, <tt>RtError.h</tt>, and <TT>RtAudio.cpp</TT> all exist in the same directory.
\section debug Debugging
If you are having problems getting RtAudio to run on your system, try passing the preprocessor definition <TT>__RTAUDIO_DEBUG__</TT> to the compiler (or uncomment the definition at the bottom of RtAudio.h). A variety of warning messages will be displayed which may help in determining the problem. Also try using the programs included in the <tt>test</tt> directory. The program <tt>info</tt> displays the queried capabilities of all hardware devices found.
\section apinotes API Notes
RtAudio is designed to provide a common API across the various supported operating systems and audio libraries. Despite that, some issues should be mentioned with regard to each.
\subsection linux Linux:
RtAudio for Linux was developed under Redhat distributions 7.0 - Fedora. Three different audio APIs are supported on Linux platforms: OSS, <A href="http://www.alsa-project.org/">ALSA</A>, and <A href="http://jackit.sourceforge.net/">Jack</A>. The OSS API has existed for at least 6 years and the Linux kernel is distributed with free versions of OSS audio drivers. Therefore, a generic Linux system is most likely to have OSS support (though the availability and quality of OSS drivers for new hardware is decreasing). The ALSA API, although relatively new, is now part of the Linux development kernel and offers significantly better functionality than the OSS API. RtAudio provides support for the 1.0 and higher versions of ALSA. Jack, which is still in development, is a low-latency audio server, written primarily for the GNU/Linux operating system. It can connect a number of different applications to an audio device, as well as allow them to share audio between themselves. Input/output latency on the order of 15 milliseconds can typically be achieved using any of the Linux APIs by fine-tuning the RtAudio buffer parameters (without kernel modifications). Latencies on the order of 5 milliseconds or less can be achieved using a low-latency kernel patch and increasing FIFO scheduling priority. The pthread library, which is used for callback functionality, is a standard component of all Linux distributions.
The ALSA library includes OSS emulation support. That means that you can run programs compiled for the OSS API even when using the ALSA drivers and library. It should be noted however that OSS emulation under ALSA is not perfect. Specifically, channel number queries seem to consistently produce invalid results. While OSS emulation is successful for the majority of RtAudio tests, it is recommended that the native ALSA implementation of RtAudio be used on systems which have ALSA drivers installed.
The ALSA implementation of RtAudio makes no use of the ALSA "plug" interface. All necessary data format conversions, channel compensation, de-interleaving, and byte-swapping is handled by internal RtAudio routines.
The Jack API is based on a callback scheme. RtAudio provides blocking functionality, in addition to callback functionality, within the context of that behavior. It should be noted, however, that the best performance is achieved when using RtAudio's callback functionality with the Jack API. At the moment, only one RtAudio instance can be connected to the Jack server. Because RtAudio does not provide a mechanism for allowing the user to specify particular channels (or ports) of a device, it simply opens the first <I>N</I> enumerated Jack ports for input/output.
\subsection macosx Macintosh OS X (CoreAudio):
The Apple CoreAudio API is based on a callback scheme. RtAudio provides blocking functionality, in addition to callback functionality, within the context of that behavior. CoreAudio is designed to use a separate callback procedure for each of its audio devices. A single RtAudio duplex stream using two different devices is supported, though it cannot be guaranteed to always behave correctly because we cannot synchronize these two callbacks. This same functionality might be achieved with better synchrony by creating separate instances of RtAudio for each device and making use of RtAudio blocking calls (i.e. RtAudio::tickStream()). The <I>numberOfBuffers</I> parameter to the RtAudio::openStream() function has no affect in this implementation.
It is not possible to have multiple instances of RtAudio accessing the same CoreAudio device.
\subsection irix Irix (SGI):
The Irix version of RtAudio was written and tested on an SGI Indy running Irix version 6.5.4 and the newer "al" audio library. RtAudio does not compile under Irix version 6.3, mainly because the C++ compiler is too old. Despite the relatively slow speed of the Indy, RtAudio was found to behave quite well and input/output latency was very good. No problems were found with respect to using the pthread library.
\subsection windowsds Windows (DirectSound):
In order to compile RtAudio under Windows for the DirectSound API, you must have the header and source files for DirectSound version 5.0 or higher. As far as I know, there is no DirectSoundCapture support for Windows NT. Audio output latency with DirectSound can be reasonably good (on the order of 20 milliseconds). On the other hand, input audio latency tends to be terrible (100 milliseconds or more). Further, DirectSound drivers tend to crash easily when experimenting with buffer parameters. On my system, I found it necessary to use values around nBuffers = 8 and bufferSize = 512 to avoid crashes. RtAudio was originally developed with Visual C++ version 6.0.
\subsection windowsasio Windows (ASIO):
The Steinberg ASIO audio API is based on a callback scheme. In addition, the API allows only a single device driver to be loaded and accessed at a time. ASIO device drivers must be supplied by audio hardware manufacturers, though ASIO emulation is possible on top of systems with DirectSound drivers. The <I>numberOfBuffers</I> parameter to the RtAudio::openStream() function has no affect in this implementation.
A number of ASIO source and header files are required for use with RtAudio. Specifically, an RtAudio project must include the following files: <TT>asio.h,cpp; asiodrivers.h,cpp; asiolist.h,cpp; asiodrvr.h; asiosys.h; ginclude.h; iasiodrv.h</TT>. The Visual C++ projects found in <TT>/tests/Windows/</TT> compile both ASIO and DirectSound support.
\section acknowledge Acknowledgements
The RtAudio API incorporates many of the concepts developed in the <A href="http://www.portaudio.com/">PortAudio</A> project by Phil Burk and Ross Bencina. Early development also incorporated ideas from Bill Schottstaedt's <A href="http://www-ccrma.stanford.edu/software/snd/sndlib/">sndlib</A>. The CCRMA <A href="http://www-ccrma.stanford.edu/groups/soundwire/">SoundWire group</A> provided valuable feedback during the API proposal stages.
The early 2.0 version of RtAudio was slowly developed over the course of many months while in residence at the <A href="http://www.iua.upf.es/">Institut Universitari de L'Audiovisual (IUA)</A> in Barcelona, Spain and the <A href="http://www.acoustics.hut.fi/">Laboratory of Acoustics and Audio Signal Processing</A> at the Helsinki University of Technology, Finland. Much subsequent development happened while working at the <A href="http://www-ccrma.stanford.edu/">Center for Computer Research in Music and Acoustics (CCRMA)</A> at <A href="http://www.stanford.edu/">Stanford University</A>. The most recent version of RtAudio was finished while working as an assistant professor of <a href="http://www.music.mcgill.ca/musictech/">Music Technology</a> at <a href="http://www.mcgill.ca/">McGill University</a>. This work was supported in part by the United States Air Force Office of Scientific Research (grant \#F49620-99-1-0293).
\section license License
RtAudio: a realtime audio i/o C++ classes<BR>
Copyright (c) 2001-2004 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.
*/

View File

@@ -0,0 +1,539 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtAudio.h</h1><div class="fragment"><pre>00001 <span class="comment">/************************************************************************/</span>
00038 <span class="comment">/************************************************************************/</span>
00039
00040 <span class="comment">// RtAudio: Version 3.0.1, 22 March 2004</span>
00041
00042 <span class="preprocessor">#ifndef __RTAUDIO_H</span>
00043 <span class="preprocessor"></span><span class="preprocessor">#define __RTAUDIO_H</span>
00044 <span class="preprocessor"></span>
00045 <span class="preprocessor">#include "RtError.h"</span>
00046 <span class="preprocessor">#include &lt;string&gt;</span>
00047 <span class="preprocessor">#include &lt;vector&gt;</span>
00048
00049 <span class="comment">// Operating system dependent thread functionality.</span>
00050 <span class="preprocessor">#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)</span>
00051 <span class="preprocessor"></span><span class="preprocessor"> #include &lt;windows.h&gt;</span>
00052 <span class="preprocessor"> #include &lt;process.h&gt;</span>
00053
00054 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> ThreadHandle;
00055 <span class="keyword">typedef</span> CRITICAL_SECTION StreamMutex;
00056
00057 <span class="preprocessor">#else // Various unix flavors with pthread support.</span>
00058 <span class="preprocessor"></span><span class="preprocessor"> #include &lt;pthread.h&gt;</span>
00059
00060 <span class="keyword">typedef</span> pthread_t ThreadHandle;
00061 <span class="keyword">typedef</span> pthread_mutex_t StreamMutex;
00062
00063 <span class="preprocessor">#endif</span>
00064 <span class="preprocessor"></span>
00065 <span class="comment">// This global structure type is used to pass callback information</span>
00066 <span class="comment">// between the private RtAudio stream structure and global callback</span>
00067 <span class="comment">// handling functions.</span>
00068 <span class="keyword">struct </span>CallbackInfo {
00069 <span class="keywordtype">void</span> *object; <span class="comment">// Used as a "this" pointer.</span>
00070 ThreadHandle thread;
00071 <span class="keywordtype">bool</span> usingCallback;
00072 <span class="keywordtype">void</span> *callback;
00073 <span class="keywordtype">void</span> *userData;
00074 <span class="keywordtype">void</span> *apiInfo; <span class="comment">// void pointer for API specific callback information</span>
00075
00076 <span class="comment">// Default constructor.</span>
00077 CallbackInfo()
00078 :object(0), usingCallback(false), callback(0),
00079 userData(0), apiInfo(0) {}
00080 };
00081
00082 <span class="comment">// Support for signed integers and floats. Audio data fed to/from</span>
00083 <span class="comment">// the tickStream() routine is assumed to ALWAYS be in host</span>
00084 <span class="comment">// byte order. The internal routines will automatically take care of</span>
00085 <span class="comment">// any necessary byte-swapping between the host format and the</span>
00086 <span class="comment">// soundcard. Thus, endian-ness is not a concern in the following</span>
00087 <span class="comment">// format definitions.</span>
00088 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> RtAudioFormat;
00089 <span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_SINT8 = 0x1;
00090 <span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_SINT16 = 0x2;
00091 <span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_SINT24 = 0x4;
00092 <span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_SINT32 = 0x8;
00093 <span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_FLOAT32 = 0x10;
00094 <span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_FLOAT64 = 0x20;
00096 <span class="keyword">typedef</span> int (*RtAudioCallback)(<span class="keywordtype">char</span> *buffer, <span class="keywordtype">int</span> bufferSize, <span class="keywordtype">void</span> *userData);
00097
<a name="l00099"></a><a class="code" href="structRtAudioDeviceInfo.html">00099</a> <span class="keyword">struct </span><a class="code" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> {
<a name="l00100"></a><a class="code" href="structRtAudioDeviceInfo.html#o0">00100</a> std::string <a class="code" href="structRtAudioDeviceInfo.html#o0">name</a>;
<a name="l00101"></a><a class="code" href="structRtAudioDeviceInfo.html#o1">00101</a> <span class="keywordtype">bool</span> <a class="code" href="structRtAudioDeviceInfo.html#o1">probed</a>;
<a name="l00102"></a><a class="code" href="structRtAudioDeviceInfo.html#o2">00102</a> <span class="keywordtype">int</span> <a class="code" href="structRtAudioDeviceInfo.html#o2">outputChannels</a>;
<a name="l00103"></a><a class="code" href="structRtAudioDeviceInfo.html#o3">00103</a> <span class="keywordtype">int</span> <a class="code" href="structRtAudioDeviceInfo.html#o3">inputChannels</a>;
<a name="l00104"></a><a class="code" href="structRtAudioDeviceInfo.html#o4">00104</a> <span class="keywordtype">int</span> <a class="code" href="structRtAudioDeviceInfo.html#o4">duplexChannels</a>;
<a name="l00105"></a><a class="code" href="structRtAudioDeviceInfo.html#o5">00105</a> <span class="keywordtype">bool</span> <a class="code" href="structRtAudioDeviceInfo.html#o5">isDefault</a>;
<a name="l00106"></a><a class="code" href="structRtAudioDeviceInfo.html#o6">00106</a> std::vector&lt;int&gt; <a class="code" href="structRtAudioDeviceInfo.html#o6">sampleRates</a>;
<a name="l00107"></a><a class="code" href="structRtAudioDeviceInfo.html#o7">00107</a> RtAudioFormat <a class="code" href="structRtAudioDeviceInfo.html#o7">nativeFormats</a>;
00109 <span class="comment">// Default constructor.</span>
00110 <a class="code" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a>()
00111 :<a class="code" href="structRtAudioDeviceInfo.html#o1">probed</a>(false), <a class="code" href="structRtAudioDeviceInfo.html#o2">outputChannels</a>(0), <a class="code" href="structRtAudioDeviceInfo.html#o3">inputChannels</a>(0),
00112 <a class="code" href="structRtAudioDeviceInfo.html#o4">duplexChannels</a>(0), <a class="code" href="structRtAudioDeviceInfo.html#o5">isDefault</a>(false), <a class="code" href="structRtAudioDeviceInfo.html#o7">nativeFormats</a>(0) {}
00113 };
00114
00115 <span class="comment">// **************************************************************** //</span>
00116 <span class="comment">//</span>
00117 <span class="comment">// RtApi class declaration.</span>
00118 <span class="comment">//</span>
00119 <span class="comment">// Note that RtApi is an abstract base class and cannot be</span>
00120 <span class="comment">// explicitly instantiated. The class RtAudio will create an</span>
00121 <span class="comment">// instance of an RtApi subclass (RtApiOss, RtApiAlsa,</span>
00122 <span class="comment">// RtApiJack, RtApiCore, RtApiAl, RtApiDs, or RtApiAsio).</span>
00123 <span class="comment">//</span>
00124 <span class="comment">// **************************************************************** //</span>
00125
00126 <span class="keyword">class </span>RtApi
00127 {
00128 <span class="keyword">public</span>:
00129
00130 RtApi();
00131 <span class="keyword">virtual</span> ~RtApi();
00132 <span class="keywordtype">void</span> openStream( <span class="keywordtype">int</span> outputDevice, <span class="keywordtype">int</span> outputChannels,
00133 <span class="keywordtype">int</span> inputDevice, <span class="keywordtype">int</span> inputChannels,
00134 RtAudioFormat format, <span class="keywordtype">int</span> sampleRate,
00135 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00136 <span class="keyword">virtual</span> <span class="keywordtype">void</span> setStreamCallback( RtAudioCallback callback, <span class="keywordtype">void</span> *userData ) = 0;
00137 <span class="keyword">virtual</span> <span class="keywordtype">void</span> cancelStreamCallback() = 0;
00138 <span class="keywordtype">int</span> getDeviceCount(<span class="keywordtype">void</span>);
00139 <a class="code" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> getDeviceInfo( <span class="keywordtype">int</span> device );
00140 <span class="keywordtype">char</span> * <span class="keyword">const</span> getStreamBuffer();
00141 <span class="keyword">virtual</span> <span class="keywordtype">void</span> tickStream() = 0;
00142 <span class="keyword">virtual</span> <span class="keywordtype">void</span> closeStream();
00143 <span class="keyword">virtual</span> <span class="keywordtype">void</span> startStream() = 0;
00144 <span class="keyword">virtual</span> <span class="keywordtype">void</span> stopStream() = 0;
00145 <span class="keyword">virtual</span> <span class="keywordtype">void</span> abortStream() = 0;
00146
00147 <span class="keyword">protected</span>:
00148
00149 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MAX_SAMPLE_RATES;
00150 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> SAMPLE_RATES[];
00151
00152 <span class="keyword">enum</span> { FAILURE, SUCCESS };
00153
00154 <span class="keyword">enum</span> StreamMode {
00155 OUTPUT,
00156 INPUT,
00157 DUPLEX,
00158 UNINITIALIZED = -75
00159 };
00160
00161 <span class="keyword">enum</span> StreamState {
00162 STREAM_STOPPED,
00163 STREAM_RUNNING
00164 };
00165
00166 <span class="comment">// A protected structure for audio streams.</span>
00167 <span class="keyword">struct </span>RtApiStream {
00168 <span class="keywordtype">int</span> device[2]; <span class="comment">// Playback and record, respectively.</span>
00169 <span class="keywordtype">void</span> *apiHandle; <span class="comment">// void pointer for API specific stream handle information</span>
00170 StreamMode mode; <span class="comment">// OUTPUT, INPUT, or DUPLEX.</span>
00171 StreamState state; <span class="comment">// STOPPED or RUNNING</span>
00172 <span class="keywordtype">char</span> *userBuffer;
00173 <span class="keywordtype">char</span> *deviceBuffer;
00174 <span class="keywordtype">bool</span> doConvertBuffer[2]; <span class="comment">// Playback and record, respectively.</span>
00175 <span class="keywordtype">bool</span> deInterleave[2]; <span class="comment">// Playback and record, respectively.</span>
00176 <span class="keywordtype">bool</span> doByteSwap[2]; <span class="comment">// Playback and record, respectively.</span>
00177 <span class="keywordtype">int</span> sampleRate;
00178 <span class="keywordtype">int</span> bufferSize;
00179 <span class="keywordtype">int</span> nBuffers;
00180 <span class="keywordtype">int</span> nUserChannels[2]; <span class="comment">// Playback and record, respectively.</span>
00181 <span class="keywordtype">int</span> nDeviceChannels[2]; <span class="comment">// Playback and record channels, respectively.</span>
00182 RtAudioFormat userFormat;
00183 RtAudioFormat deviceFormat[2]; <span class="comment">// Playback and record, respectively.</span>
00184 StreamMutex mutex;
00185 CallbackInfo callbackInfo;
00186
00187 RtApiStream()
00188 :apiHandle(0), userBuffer(0), deviceBuffer(0) {}
00189 <span class="comment">// mode(UNINITIALIZED), state(STREAM_STOPPED),</span>
00190 };
00191
00192 <span class="comment">// A protected device structure for audio devices.</span>
00193 <span class="keyword">struct </span>RtApiDevice {
00194 std::string name;
00195 <span class="keywordtype">bool</span> probed;
00196 <span class="keywordtype">void</span> *apiDeviceId; <span class="comment">// void pointer for API specific device information</span>
00197 <span class="keywordtype">int</span> maxOutputChannels;
00198 <span class="keywordtype">int</span> maxInputChannels;
00199 <span class="keywordtype">int</span> maxDuplexChannels;
00200 <span class="keywordtype">int</span> minOutputChannels;
00201 <span class="keywordtype">int</span> minInputChannels;
00202 <span class="keywordtype">int</span> minDuplexChannels;
00203 <span class="keywordtype">bool</span> hasDuplexSupport;
00204 <span class="keywordtype">bool</span> isDefault;
00205 std::vector&lt;int&gt; sampleRates;
00206 RtAudioFormat nativeFormats;
00208 <span class="comment">// Default constructor.</span>
00209 RtApiDevice()
00210 :probed(false), apiDeviceId(0), maxOutputChannels(0), maxInputChannels(0),
00211 maxDuplexChannels(0), minOutputChannels(0), minInputChannels(0),
00212 minDuplexChannels(0), isDefault(false), nativeFormats(0) {}
00213 };
00214
00215 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">short</span> Int16;
00216 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">int</span> Int32;
00217 <span class="keyword">typedef</span> <span class="keywordtype">float</span> Float32;
00218 <span class="keyword">typedef</span> <span class="keywordtype">double</span> Float64;
00219
00220 <span class="keywordtype">char</span> message_[256];
00221 <span class="keywordtype">int</span> nDevices_;
00222 std::vector&lt;RtApiDevice&gt; devices_;
00223 RtApiStream stream_;
00224
00229 <span class="keyword">virtual</span> <span class="keywordtype">void</span> initialize(<span class="keywordtype">void</span>) = 0;
00230
00239 <span class="keyword">virtual</span> <span class="keywordtype">void</span> probeDeviceInfo( RtApiDevice *info );
00240
00249 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">int</span> channels,
00250 <span class="keywordtype">int</span> sampleRate, RtAudioFormat format,
00251 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00252
00257 <span class="keyword">virtual</span> <span class="keywordtype">int</span> getDefaultInputDevice(<span class="keywordtype">void</span>);
00258
00263 <span class="keyword">virtual</span> <span class="keywordtype">int</span> getDefaultOutputDevice(<span class="keywordtype">void</span>);
00264
00266 <span class="keywordtype">void</span> clearDeviceInfo( RtApiDevice *info );
00267
00269 <span class="keywordtype">void</span> clearStreamInfo();
00270
00272 <span class="keywordtype">void</span> error( RtError::Type type );
00273
00278 <span class="keywordtype">void</span> verifyStream();
00279
00284 <span class="keywordtype">void</span> convertStreamBuffer( StreamMode mode );
00285
00287 <span class="keywordtype">void</span> byteSwapBuffer( <span class="keywordtype">char</span> *buffer, <span class="keywordtype">int</span> samples, RtAudioFormat format );
00288
00290 <span class="keywordtype">int</span> formatBytes( RtAudioFormat format );
00291 };
00292
00293
00294 <span class="comment">// **************************************************************** //</span>
00295 <span class="comment">//</span>
00296 <span class="comment">// RtAudio class declaration.</span>
00297 <span class="comment">//</span>
00298 <span class="comment">// RtAudio is a "controller" used to select an available audio i/o</span>
00299 <span class="comment">// interface. It presents a common API for the user to call but all</span>
00300 <span class="comment">// functionality is implemented by the class RtAudioApi and its</span>
00301 <span class="comment">// subclasses. RtAudio creates an instance of an RtAudioApi subclass</span>
00302 <span class="comment">// based on the user's API choice. If no choice is made, RtAudio</span>
00303 <span class="comment">// attempts to make a "logical" API selection.</span>
00304 <span class="comment">//</span>
00305 <span class="comment">// **************************************************************** //</span>
00306
<a name="l00307"></a><a class="code" href="classRtAudio.html">00307</a> <span class="keyword">class </span><a class="code" href="classRtAudio.html">RtAudio</a>
00308 {
00309 <span class="keyword">public</span>:
00310
<a name="l00312"></a><a class="code" href="classRtAudio.html#w8">00312</a> <span class="keyword">enum</span> <a class="code" href="classRtAudio.html#w8">RtAudioApi</a> {
00313 <a class="code" href="classRtAudio.html#w8w0">UNSPECIFIED</a>,
00314 <a class="code" href="classRtAudio.html#w8w1">LINUX_ALSA</a>,
00315 <a class="code" href="classRtAudio.html#w8w2">LINUX_OSS</a>,
00316 <a class="code" href="classRtAudio.html#w8w3">LINUX_JACK</a>,
00317 <a class="code" href="classRtAudio.html#w8w4">MACOSX_CORE</a>,
00318 <a class="code" href="classRtAudio.html#w8w5">IRIX_AL</a>,
00319 <a class="code" href="classRtAudio.html#w8w6">WINDOWS_ASIO</a>,
00320 <a class="code" href="classRtAudio.html#w8w7">WINDOWS_DS</a>
00321 };
00322
00324
00334 <a class="code" href="classRtAudio.html#a0">RtAudio</a>( RtAudioApi api=UNSPECIFIED );
00335
00337
00348 <a class="code" href="classRtAudio.html#a0">RtAudio</a>( <span class="keywordtype">int</span> outputDevice, <span class="keywordtype">int</span> outputChannels,
00349 <span class="keywordtype">int</span> inputDevice, <span class="keywordtype">int</span> inputChannels,
00350 RtAudioFormat format, <span class="keywordtype">int</span> sampleRate,
00351 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers, RtAudioApi api=UNSPECIFIED );
00352
00354
00358 <a class="code" href="classRtAudio.html#a2">~RtAudio</a>();
00359
00361
00387 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#a3">openStream</a>( <span class="keywordtype">int</span> outputDevice, <span class="keywordtype">int</span> outputChannels,
00388 <span class="keywordtype">int</span> inputDevice, <span class="keywordtype">int</span> inputChannels,
00389 RtAudioFormat format, <span class="keywordtype">int</span> sampleRate,
00390 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00391
00393
<a name="l00412"></a><a class="code" href="classRtAudio.html#a4">00412</a> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#a4">setStreamCallback</a>(RtAudioCallback callback, <span class="keywordtype">void</span> *userData) { rtapi_-&gt;setStreamCallback( callback, userData ); };
00413
00415
<a name="l00422"></a><a class="code" href="classRtAudio.html#a5">00422</a> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#a5">cancelStreamCallback</a>() { rtapi_-&gt;cancelStreamCallback(); };
00423
<a name="l00425"></a><a class="code" href="classRtAudio.html#a6">00425</a> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#a6">getDeviceCount</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> rtapi_-&gt;getDeviceCount(); };
00426
00428
<a name="l00436"></a><a class="code" href="classRtAudio.html#a7">00436</a> <a class="code" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> <a class="code" href="classRtAudio.html#a7">getDeviceInfo</a>(<span class="keywordtype">int</span> device) { <span class="keywordflow">return</span> rtapi_-&gt;getDeviceInfo( device ); };
00437
00439
<a name="l00444"></a><a class="code" href="classRtAudio.html#a8">00444</a> <span class="keywordtype">char</span> * <span class="keyword">const</span> <a class="code" href="classRtAudio.html#a8">getStreamBuffer</a>() { <span class="keywordflow">return</span> rtapi_-&gt;getStreamBuffer(); };
00445
00447
<a name="l00452"></a><a class="code" href="classRtAudio.html#a9">00452</a> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#a9">tickStream</a>() { rtapi_-&gt;tickStream(); };
00453
00455
<a name="l00459"></a><a class="code" href="classRtAudio.html#a10">00459</a> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#a10">closeStream</a>() { rtapi_-&gt;closeStream(); };
00460
00462
<a name="l00466"></a><a class="code" href="classRtAudio.html#a11">00466</a> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#a11">startStream</a>() { rtapi_-&gt;startStream(); };
00467
00469
<a name="l00473"></a><a class="code" href="classRtAudio.html#a12">00473</a> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#a12">stopStream</a>() { rtapi_-&gt;stopStream(); };
00474
00476
<a name="l00480"></a><a class="code" href="classRtAudio.html#a13">00480</a> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#a13">abortStream</a>() { rtapi_-&gt;abortStream(); };
00481
00482
00483 <span class="keyword">protected</span>:
00484
00485 <span class="keywordtype">void</span> initialize( RtAudioApi api );
00486
00487 RtApi *rtapi_;
00488 };
00489
00490
00491 <span class="comment">// RtApi Subclass prototypes.</span>
00492
00493 <span class="preprocessor">#if defined(__LINUX_ALSA__)</span>
00494 <span class="preprocessor"></span>
00495 <span class="keyword">class </span>RtApiAlsa: <span class="keyword">public</span> RtApi
00496 {
00497 <span class="keyword">public</span>:
00498
00499 RtApiAlsa();
00500 ~RtApiAlsa();
00501 <span class="keywordtype">void</span> tickStream();
00502 <span class="keywordtype">void</span> closeStream();
00503 <span class="keywordtype">void</span> startStream();
00504 <span class="keywordtype">void</span> stopStream();
00505 <span class="keywordtype">void</span> abortStream();
00506 <span class="keywordtype">int</span> streamWillBlock();
00507 <span class="keywordtype">void</span> setStreamCallback( RtAudioCallback callback, <span class="keywordtype">void</span> *userData );
00508 <span class="keywordtype">void</span> cancelStreamCallback();
00509
00510 <span class="keyword">private</span>:
00511
00512 <span class="keywordtype">void</span> initialize(<span class="keywordtype">void</span>);
00513 <span class="keywordtype">void</span> probeDeviceInfo( RtApiDevice *info );
00514 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">int</span> channels,
00515 <span class="keywordtype">int</span> sampleRate, RtAudioFormat format,
00516 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00517 };
00518
00519 <span class="preprocessor">#endif</span>
00520 <span class="preprocessor"></span>
00521 <span class="preprocessor">#if defined(__LINUX_JACK__)</span>
00522 <span class="preprocessor"></span>
00523 <span class="keyword">class </span>RtApiJack: <span class="keyword">public</span> RtApi
00524 {
00525 <span class="keyword">public</span>:
00526
00527 RtApiJack();
00528 ~RtApiJack();
00529 <span class="keywordtype">void</span> tickStream();
00530 <span class="keywordtype">void</span> closeStream();
00531 <span class="keywordtype">void</span> startStream();
00532 <span class="keywordtype">void</span> stopStream();
00533 <span class="keywordtype">void</span> abortStream();
00534 <span class="keywordtype">void</span> setStreamCallback( RtAudioCallback callback, <span class="keywordtype">void</span> *userData );
00535 <span class="keywordtype">void</span> cancelStreamCallback();
00536 <span class="comment">// This function is intended for internal use only. It must be</span>
00537 <span class="comment">// public because it is called by the internal callback handler,</span>
00538 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
00539 <span class="comment">// will most likely produce highly undesireable results!</span>
00540 <span class="keywordtype">void</span> callbackEvent( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> nframes );
00541
00542 <span class="keyword">private</span>:
00543
00544 <span class="keywordtype">void</span> initialize(<span class="keywordtype">void</span>);
00545 <span class="keywordtype">void</span> probeDeviceInfo( RtApiDevice *info );
00546 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">int</span> channels,
00547 <span class="keywordtype">int</span> sampleRate, RtAudioFormat format,
00548 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00549 };
00550
00551 <span class="preprocessor">#endif</span>
00552 <span class="preprocessor"></span>
00553 <span class="preprocessor">#if defined(__LINUX_OSS__)</span>
00554 <span class="preprocessor"></span>
00555 <span class="keyword">class </span>RtApiOss: <span class="keyword">public</span> RtApi
00556 {
00557 <span class="keyword">public</span>:
00558
00559 RtApiOss();
00560 ~RtApiOss();
00561 <span class="keywordtype">void</span> tickStream();
00562 <span class="keywordtype">void</span> closeStream();
00563 <span class="keywordtype">void</span> startStream();
00564 <span class="keywordtype">void</span> stopStream();
00565 <span class="keywordtype">void</span> abortStream();
00566 <span class="keywordtype">int</span> streamWillBlock();
00567 <span class="keywordtype">void</span> setStreamCallback( RtAudioCallback callback, <span class="keywordtype">void</span> *userData );
00568 <span class="keywordtype">void</span> cancelStreamCallback();
00569
00570 <span class="keyword">private</span>:
00571
00572 <span class="keywordtype">void</span> initialize(<span class="keywordtype">void</span>);
00573 <span class="keywordtype">void</span> probeDeviceInfo( RtApiDevice *info );
00574 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">int</span> channels,
00575 <span class="keywordtype">int</span> sampleRate, RtAudioFormat format,
00576 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00577 };
00578
00579 <span class="preprocessor">#endif</span>
00580 <span class="preprocessor"></span>
00581 <span class="preprocessor">#if defined(__MACOSX_CORE__)</span>
00582 <span class="preprocessor"></span>
00583 <span class="preprocessor">#include &lt;CoreAudio/AudioHardware.h&gt;</span>
00584
00585 <span class="keyword">class </span>RtApiCore: <span class="keyword">public</span> RtApi
00586 {
00587 <span class="keyword">public</span>:
00588
00589 RtApiCore();
00590 ~RtApiCore();
00591 <span class="keywordtype">int</span> getDefaultOutputDevice(<span class="keywordtype">void</span>);
00592 <span class="keywordtype">int</span> getDefaultInputDevice(<span class="keywordtype">void</span>);
00593 <span class="keywordtype">void</span> tickStream();
00594 <span class="keywordtype">void</span> closeStream();
00595 <span class="keywordtype">void</span> startStream();
00596 <span class="keywordtype">void</span> stopStream();
00597 <span class="keywordtype">void</span> abortStream();
00598 <span class="keywordtype">void</span> setStreamCallback( RtAudioCallback callback, <span class="keywordtype">void</span> *userData );
00599 <span class="keywordtype">void</span> cancelStreamCallback();
00600
00601 <span class="comment">// This function is intended for internal use only. It must be</span>
00602 <span class="comment">// public because it is called by the internal callback handler,</span>
00603 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
00604 <span class="comment">// will most likely produce highly undesireable results!</span>
00605 <span class="keywordtype">void</span> callbackEvent( AudioDeviceID deviceId, <span class="keywordtype">void</span> *inData, <span class="keywordtype">void</span> *outData );
00606
00607 <span class="keyword">private</span>:
00608
00609 <span class="keywordtype">void</span> initialize(<span class="keywordtype">void</span>);
00610 <span class="keywordtype">void</span> probeDeviceInfo( RtApiDevice *info );
00611 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">int</span> channels,
00612 <span class="keywordtype">int</span> sampleRate, RtAudioFormat format,
00613 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00614 };
00615
00616 <span class="preprocessor">#endif</span>
00617 <span class="preprocessor"></span>
00618 <span class="preprocessor">#if defined(__WINDOWS_DS__)</span>
00619 <span class="preprocessor"></span>
00620 <span class="keyword">class </span>RtApiDs: <span class="keyword">public</span> RtApi
00621 {
00622 <span class="keyword">public</span>:
00623
00624 RtApiDs();
00625 ~RtApiDs();
00626 <span class="keywordtype">int</span> getDefaultOutputDevice(<span class="keywordtype">void</span>);
00627 <span class="keywordtype">int</span> getDefaultInputDevice(<span class="keywordtype">void</span>);
00628 <span class="keywordtype">void</span> tickStream();
00629 <span class="keywordtype">void</span> closeStream();
00630 <span class="keywordtype">void</span> startStream();
00631 <span class="keywordtype">void</span> stopStream();
00632 <span class="keywordtype">void</span> abortStream();
00633 <span class="keywordtype">int</span> streamWillBlock();
00634 <span class="keywordtype">void</span> setStreamCallback( RtAudioCallback callback, <span class="keywordtype">void</span> *userData );
00635 <span class="keywordtype">void</span> cancelStreamCallback();
00636
00637 <span class="keyword">private</span>:
00638
00639 <span class="keywordtype">void</span> initialize(<span class="keywordtype">void</span>);
00640 <span class="keywordtype">void</span> probeDeviceInfo( RtApiDevice *info );
00641 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">int</span> channels,
00642 <span class="keywordtype">int</span> sampleRate, RtAudioFormat format,
00643 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00644 };
00645
00646 <span class="preprocessor">#endif</span>
00647 <span class="preprocessor"></span>
00648 <span class="preprocessor">#if defined(__WINDOWS_ASIO__)</span>
00649 <span class="preprocessor"></span>
00650 <span class="keyword">class </span>RtApiAsio: <span class="keyword">public</span> RtApi
00651 {
00652 <span class="keyword">public</span>:
00653
00654 RtApiAsio();
00655 ~RtApiAsio();
00656 <span class="keywordtype">void</span> tickStream();
00657 <span class="keywordtype">void</span> closeStream();
00658 <span class="keywordtype">void</span> startStream();
00659 <span class="keywordtype">void</span> stopStream();
00660 <span class="keywordtype">void</span> abortStream();
00661 <span class="keywordtype">void</span> setStreamCallback( RtAudioCallback callback, <span class="keywordtype">void</span> *userData );
00662 <span class="keywordtype">void</span> cancelStreamCallback();
00663
00664 <span class="comment">// This function is intended for internal use only. It must be</span>
00665 <span class="comment">// public because it is called by the internal callback handler,</span>
00666 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
00667 <span class="comment">// will most likely produce highly undesireable results!</span>
00668 <span class="keywordtype">void</span> callbackEvent( <span class="keywordtype">long</span> bufferIndex );
00669
00670 <span class="keyword">private</span>:
00671
00672 <span class="keywordtype">void</span> initialize(<span class="keywordtype">void</span>);
00673 <span class="keywordtype">void</span> probeDeviceInfo( RtApiDevice *info );
00674 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">int</span> channels,
00675 <span class="keywordtype">int</span> sampleRate, RtAudioFormat format,
00676 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00677 };
00678
00679 <span class="preprocessor">#endif</span>
00680 <span class="preprocessor"></span>
00681 <span class="preprocessor">#if defined(__IRIX_AL__)</span>
00682 <span class="preprocessor"></span>
00683 <span class="keyword">class </span>RtApiAl: <span class="keyword">public</span> RtApi
00684 {
00685 <span class="keyword">public</span>:
00686
00687 RtApiAl();
00688 ~RtApiAl();
00689 <span class="keywordtype">int</span> getDefaultOutputDevice(<span class="keywordtype">void</span>);
00690 <span class="keywordtype">int</span> getDefaultInputDevice(<span class="keywordtype">void</span>);
00691 <span class="keywordtype">void</span> tickStream();
00692 <span class="keywordtype">void</span> closeStream();
00693 <span class="keywordtype">void</span> startStream();
00694 <span class="keywordtype">void</span> stopStream();
00695 <span class="keywordtype">void</span> abortStream();
00696 <span class="keywordtype">int</span> streamWillBlock();
00697 <span class="keywordtype">void</span> setStreamCallback( RtAudioCallback callback, <span class="keywordtype">void</span> *userData );
00698 <span class="keywordtype">void</span> cancelStreamCallback();
00699
00700 <span class="keyword">private</span>:
00701
00702 <span class="keywordtype">void</span> initialize(<span class="keywordtype">void</span>);
00703 <span class="keywordtype">void</span> probeDeviceInfo( RtApiDevice *info );
00704 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">int</span> channels,
00705 <span class="keywordtype">int</span> sampleRate, RtAudioFormat format,
00706 <span class="keywordtype">int</span> *bufferSize, <span class="keywordtype">int</span> numberOfBuffers );
00707 };
00708
00709 <span class="preprocessor">#endif</span>
00710 <span class="preprocessor"></span>
00711 <span class="comment">// Define the following flag to have extra information spewed to stderr.</span>
00712 <span class="comment">//#define __RTAUDIO_DEBUG__</span>
00713
00714 <span class="preprocessor">#endif</span>
</pre></div><HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,64 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtError.h</h1><div class="fragment"><pre>00001 <span class="comment">/************************************************************************/</span>
00010 <span class="comment">/************************************************************************/</span>
00011
00012 <span class="preprocessor">#ifndef RTERROR_H</span>
00013 <span class="preprocessor"></span><span class="preprocessor">#define RTERROR_H</span>
00014 <span class="preprocessor"></span>
00015 <span class="preprocessor">#include &lt;iostream&gt;</span>
00016 <span class="preprocessor">#include &lt;string&gt;</span>
00017
<a name="l00018"></a><a class="code" href="classRtError.html">00018</a> <span class="keyword">class </span><a class="code" href="classRtError.html">RtError</a>
00019 {
00020 <span class="keyword">public</span>:
<a name="l00022"></a><a class="code" href="classRtError.html#w11">00022</a> <span class="keyword">enum</span> <a class="code" href="classRtError.html#w11">Type</a> {
00023 <a class="code" href="classRtError.html#w11w0">WARNING</a>,
00024 <a class="code" href="classRtError.html#w11w1">DEBUG_WARNING</a>,
00025 <a class="code" href="classRtError.html#w11w2">UNSPECIFIED</a>,
00026 <a class="code" href="classRtError.html#w11w3">NO_DEVICES_FOUND</a>,
00027 <a class="code" href="classRtError.html#w11w4">INVALID_DEVICE</a>,
00028 <a class="code" href="classRtError.html#w11w5">INVALID_STREAM</a>,
00029 <a class="code" href="classRtError.html#w11w6">MEMORY_ERROR</a>,
00030 <a class="code" href="classRtError.html#w11w7">INVALID_PARAMETER</a>,
00031 <a class="code" href="classRtError.html#w11w8">DRIVER_ERROR</a>,
00032 <a class="code" href="classRtError.html#w11w9">SYSTEM_ERROR</a>,
00033 <a class="code" href="classRtError.html#w11w10">THREAD_ERROR</a>
00034 };
00035
00036 <span class="keyword">protected</span>:
00037 std::string message_;
00038 <a class="code" href="classRtError.html#w11">Type</a> type_;
00039
00040 <span class="keyword">public</span>:
<a name="l00042"></a><a class="code" href="classRtError.html#a0">00042</a> <a class="code" href="classRtError.html#a0">RtError</a>(<span class="keyword">const</span> std::string&amp; message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type){}
00043
<a name="l00045"></a><a class="code" href="classRtError.html#a1">00045</a> <span class="keyword">virtual</span> <a class="code" href="classRtError.html#a1">~RtError</a>(<span class="keywordtype">void</span>) {};
00046
<a name="l00048"></a><a class="code" href="classRtError.html#a2">00048</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRtError.html#a2">printMessage</a>(<span class="keywordtype">void</span>) { std::cerr &lt;&lt; <span class="charliteral">'\n'</span> &lt;&lt; message_ &lt;&lt; <span class="stringliteral">"\n\n"</span>; }
00049
<a name="l00051"></a><a class="code" href="classRtError.html#a3">00051</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classRtError.html#w11">Type</a>&amp; <a class="code" href="classRtError.html#a3">getType</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> type_; }
00052
<a name="l00054"></a><a class="code" href="classRtError.html#a4">00054</a> <span class="keyword">virtual</span> <span class="keyword">const</span> std::string&amp; <a class="code" href="classRtError.html#a4">getMessage</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> message_; }
00055
<a name="l00057"></a><a class="code" href="classRtError.html#a5">00057</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classRtError.html#a5">getMessageString</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> message_.c_str(); }
00058 };
00059
00060 <span class="preprocessor">#endif</span>
</pre></div><HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,24 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtAudio Class List</h1>Here are the classes, structs, unions and interfaces with brief descriptions:<table>
<tr><td class="indexkey"><a class="el" href="classRtAudio.html">RtAudio</a></td><td class="indexvalue">Realtime audio i/o C++ classes </td></tr>
<tr><td class="indexkey"><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td class="indexvalue">The public device information structure for returning queried values </td></tr>
<tr><td class="indexkey"><a class="el" href="classRtError.html">RtError</a></td><td class="indexvalue">Exception handling class for <a class="el" href="classRtAudio.html">RtAudio</a> &amp; RtMidi </td></tr>
</table>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,43 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtAudio Member List</h1>This is the complete list of members for <a class="el" href="classRtAudio.html">RtAudio</a>, including all inherited members.<table>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a13">abortStream</a>()</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a5">cancelStreamCallback</a>()</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a10">closeStream</a>()</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a6">getDeviceCount</a>(void)</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a7">getDeviceInfo</a>(int device)</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a8">getStreamBuffer</a>()</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8w5">IRIX_AL</a> enum value</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8w1">LINUX_ALSA</a> enum value</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8w3">LINUX_JACK</a> enum value</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8w2">LINUX_OSS</a> enum value</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8w4">MACOSX_CORE</a> enum value</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a3">openStream</a>(int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers)</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a0">RtAudio</a>(RtAudioApi api=UNSPECIFIED)</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a1">RtAudio</a>(int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers, RtAudioApi api=UNSPECIFIED)</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8">RtAudioApi</a> enum name</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a4">setStreamCallback</a>(RtAudioCallback callback, void *userData)</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a11">startStream</a>()</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a12">stopStream</a>()</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a9">tickStream</a>()</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8w0">UNSPECIFIED</a> enum value</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8w6">WINDOWS_ASIO</a> enum value</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#w8w7">WINDOWS_DS</a> enum value</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtAudio.html#a2">~RtAudio</a>()</td><td><a class="el" href="classRtAudio.html">RtAudio</a></td><td></td></tr>
</table><HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,661 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtAudio Class Reference</h1>Realtime audio i/o C++ classes.
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="RtAudio_8h-source.html">RtAudio.h</a>&gt;</code>
<p>
<a href="classRtAudio-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>enum &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#w8">RtAudioApi</a> { <br>
&nbsp;&nbsp;<a class="el" href="classRtAudio.html#w8w0">UNSPECIFIED</a>,
<a class="el" href="classRtAudio.html#w8w1">LINUX_ALSA</a>,
<a class="el" href="classRtAudio.html#w8w2">LINUX_OSS</a>,
<a class="el" href="classRtAudio.html#w8w3">LINUX_JACK</a>,
<br>
&nbsp;&nbsp;<a class="el" href="classRtAudio.html#w8w4">MACOSX_CORE</a>,
<a class="el" href="classRtAudio.html#w8w5">IRIX_AL</a>,
<a class="el" href="classRtAudio.html#w8w6">WINDOWS_ASIO</a>,
<a class="el" href="classRtAudio.html#w8w7">WINDOWS_DS</a>
<br>
}</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Audio API specifier arguments. </em> <a href="#w8">More...</a><em><br><br></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a0">RtAudio</a> (<a class="el" href="classRtAudio.html#w8">RtAudioApi</a> api=UNSPECIFIED)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The default class constructor. </em> <a href="#a0"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a1">RtAudio</a> (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers, <a class="el" href="classRtAudio.html#w8">RtAudioApi</a> api=UNSPECIFIED)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A constructor which can be used to open a stream during instantiation. </em> <a href="#a1"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a2">~RtAudio</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The destructor. </em> <a href="#a2"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a3">openStream</a> (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method for opening a stream with the specified parameters. </em> <a href="#a3"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a4">setStreamCallback</a> (RtAudioCallback callback, void *userData)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method which sets a user-defined callback function for a given stream. </em> <a href="#a4"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a5">cancelStreamCallback</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method which cancels a callback process and function for the stream. </em> <a href="#a5"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a6" doxytag="RtAudio::getDeviceCount" ></a>
int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a6">getDeviceCount</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method which returns the number of audio devices found. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a7">getDeviceInfo</a> (int device)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return an <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> structure for a specified device number. </em> <a href="#a7"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>char *const &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a8">getStreamBuffer</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method which returns a pointer to the buffer for an open stream. </em> <a href="#a8"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a9">tickStream</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Public method used to trigger processing of input/output data for a stream. </em> <a href="#a9"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a10">closeStream</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Public method which closes a stream and frees any associated buffers. </em> <a href="#a10"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a11">startStream</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Public method which starts a stream. </em> <a href="#a11"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a12">stopStream</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Stop a stream, allowing any samples remaining in the queue to be played out and/or read in. </em> <a href="#a12"></a><em><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtAudio.html#a13">abortStream</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Stop a stream, discarding any samples remaining in the input/output queue. </em> <a href="#a13"></a><em><br><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Realtime audio i/o C++ classes.
<p>
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.<p>
RtAudio WWW site: <a href="http://music.mcgill.ca/~gary/rtaudio/">http://music.mcgill.ca/~gary/rtaudio/</a><p>
RtAudio: a realtime audio i/o C++ class Copyright (c) 2001-2004 Gary P. Scavone<p>
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:<p>
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.<p>
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.<p>
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.
<p>
<hr><h2>Member Enumeration Documentation</h2>
<a class="anchor" name="w8" doxytag="RtAudio::RtAudioApi" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> enum <a class="el" href="classRtAudio.html#w8">RtAudio::RtAudioApi</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Audio API specifier arguments.
<p>
<dl compact><dt><b>Enumeration values: </b></dt><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em><a class="anchor" name="w8w0" doxytag="UNSPECIFIED" ></a>UNSPECIFIED</em>&nbsp;</td><td>
Search for a working compiled API. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w8w1" doxytag="LINUX_ALSA" ></a>LINUX_ALSA</em>&nbsp;</td><td>
The Advanced Linux Sound Architecture API. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w8w2" doxytag="LINUX_OSS" ></a>LINUX_OSS</em>&nbsp;</td><td>
The Linux Open Sound System API. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w8w3" doxytag="LINUX_JACK" ></a>LINUX_JACK</em>&nbsp;</td><td>
The Linux Jack Low-Latency Audio Server API. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w8w4" doxytag="MACOSX_CORE" ></a>MACOSX_CORE</em>&nbsp;</td><td>
Macintosh OS-X Core Audio API. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w8w5" doxytag="IRIX_AL" ></a>IRIX_AL</em>&nbsp;</td><td>
The Irix Audio Library API. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w8w6" doxytag="WINDOWS_ASIO" ></a>WINDOWS_ASIO</em>&nbsp;</td><td>
The Steinberg Audio Stream I/O API. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w8w7" doxytag="WINDOWS_DS" ></a>WINDOWS_DS</em>&nbsp;</td><td>
The Microsoft Direct Sound API. </td></tr>
</table>
</dl>
</td>
</tr>
</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="a0" doxytag="RtAudio::RtAudio" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> RtAudio::RtAudio </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top"><a class="el" href="classRtAudio.html#w8">RtAudioApi</a>&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>api</em> = UNSPECIFIED </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
The default class constructor.
<p>
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 <a class="el" href="classRtError.html">RtError</a> error can be thrown if no devices are found or if a memory allocation error occurs.<p>
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). </td>
</tr>
</table>
<a class="anchor" name="a1" doxytag="RtAudio::RtAudio" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> RtAudio::RtAudio </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">int&nbsp;</td>
<td class="mdname" nowrap> <em>outputDevice</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>outputChannels</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>inputDevice</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>inputChannels</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>RtAudioFormat&nbsp;</td>
<td class="mdname" nowrap> <em>format</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>sampleRate</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int *&nbsp;</td>
<td class="mdname" nowrap> <em>bufferSize</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>numberOfBuffers</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap><a class="el" href="classRtAudio.html#w8">RtAudioApi</a>&nbsp;</td>
<td class="mdname" nowrap> <em>api</em> = UNSPECIFIED</td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
A constructor which can be used to open a stream during instantiation.
<p>
The specified output and/or input device identifiers correspond to those enumerated via the <a class="el" href="classRtAudio.html#a7">getDeviceInfo()</a> 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 <a class="el" href="classRtError.html">RtError</a> can be thrown if no devices are found for the given parameters, if a memory allocation error occurs, or if a driver error occurs. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="classRtAudio.html#a3">openStream()</a> </dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="a2" doxytag="RtAudio::~RtAudio" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> RtAudio::~<a class="el" href="classRtAudio.html">RtAudio</a> </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
The destructor.
<p>
Stops and closes an open stream and devices and deallocates buffer and structure memory. </td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="a3" doxytag="RtAudio::openStream" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void RtAudio::openStream </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">int&nbsp;</td>
<td class="mdname" nowrap> <em>outputDevice</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>outputChannels</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>inputDevice</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>inputChannels</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>RtAudioFormat&nbsp;</td>
<td class="mdname" nowrap> <em>format</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>sampleRate</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int *&nbsp;</td>
<td class="mdname" nowrap> <em>bufferSize</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int&nbsp;</td>
<td class="mdname" nowrap> <em>numberOfBuffers</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
A public method for opening a stream with the specified parameters.
<p>
An <a class="el" href="classRtError.html">RtError</a> is thrown if a stream cannot be opened.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign=top><em>outputDevice:</em>&nbsp;</td><td>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 <a class="el" href="classRtAudio.html#a7">getDeviceInfo()</a> method. </td></tr>
<tr><td valign=top><em>outputChannels:</em>&nbsp;</td><td>The desired number of output channels. If equal to zero, the outputDevice identifier is ignored. </td></tr>
<tr><td valign=top><em>inputDevice:</em>&nbsp;</td><td>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 <a class="el" href="classRtAudio.html#a7">getDeviceInfo()</a> method. </td></tr>
<tr><td valign=top><em>inputChannels:</em>&nbsp;</td><td>The desired number of input channels. If equal to zero, the inputDevice identifier is ignored. </td></tr>
<tr><td valign=top><em>format:</em>&nbsp;</td><td>An RtAudioFormat specifying the desired sample data format. </td></tr>
<tr><td valign=top><em>sampleRate:</em>&nbsp;</td><td>The desired sample rate (sample frames per second). </td></tr>
<tr><td valign=top><em>*bufferSize:</em>&nbsp;</td><td>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. </td></tr>
<tr><td valign=top><em>numberOfBuffers:</em>&nbsp;</td><td>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. </td></tr>
</table>
</dl>
</td>
</tr>
</table>
<a class="anchor" name="a4" doxytag="RtAudio::setStreamCallback" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void RtAudio::setStreamCallback </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">RtAudioCallback&nbsp;</td>
<td class="mdname" nowrap> <em>callback</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>void *&nbsp;</td>
<td class="mdname" nowrap> <em>userData</em></td>
</tr>
<tr>
<td></td>
<td class="md">)&nbsp;</td>
<td class="md" colspan="2"><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
A public method which sets a user-defined callback function for a given stream.
<p>
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 <a class="el" href="classRtAudio.html#a11">startStream()</a> and <a class="el" href="classRtAudio.html#a12">stopStream()</a> methods, respectively). The callback process remains active for the duration of the stream and is automatically shutdown when the stream is closed (via the <a class="el" href="classRtAudio.html#a10">closeStream()</a> method or by object destruction). The callback process can also be shutdown and the user function de-referenced through an explicit call to the <a class="el" href="classRtAudio.html#a5">cancelStreamCallback()</a> 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 <a class="el" href="classRtAudio.html#a4">setStreamCallback()</a> and <a class="el" href="classRtAudio.html#a5">cancelStreamCallback()</a> methods (the blocking <a class="el" href="classRtAudio.html#a9">tickStream()</a> method can be used before a callback is set and/or after a callback is cancelled). An <a class="el" href="classRtError.html">RtError</a> will be thrown if called when no stream is open or a thread errors occurs. </td>
</tr>
</table>
<a class="anchor" name="a5" doxytag="RtAudio::cancelStreamCallback" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void RtAudio::cancelStreamCallback </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
A public method which cancels a callback process and function for the stream.
<p>
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 <a class="el" href="classRtAudio.html#a4">setStreamCallback()</a> method. An <a class="el" href="classRtError.html">RtError</a> will be thrown if called when no stream is open. </td>
</tr>
</table>
<a class="anchor" name="a7" doxytag="RtAudio::getDeviceInfo" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> RtAudio::getDeviceInfo </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="md" nowrap valign="top">int&nbsp;</td>
<td class="mdname1" valign="top" nowrap> <em>device</em> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Return an <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> structure for a specified device number.
<p>
Any device integer between 1 and <a class="el" href="classRtAudio.html#a6">getDeviceCount()</a> 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 <a class="el" href="classRtError.html">RtError</a> will be thrown for an invalid device argument. </td>
</tr>
</table>
<a class="anchor" name="a8" doxytag="RtAudio::getStreamBuffer" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> char* const RtAudio::getStreamBuffer </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
A public method which returns a pointer to the buffer for an open stream.
<p>
The user should fill and/or read the buffer data in interleaved format and then call the <a class="el" href="classRtAudio.html#a9">tickStream()</a> method. An <a class="el" href="classRtError.html">RtError</a> will be thrown if called when no stream is open. </td>
</tr>
</table>
<a class="anchor" name="a9" doxytag="RtAudio::tickStream" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void RtAudio::tickStream </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Public method used to trigger processing of input/output data for a stream.
<p>
This method blocks until all buffer data is read/written. An <a class="el" href="classRtError.html">RtError</a> will be thrown if a driver error occurs or if called when no stream is open. </td>
</tr>
</table>
<a class="anchor" name="a10" doxytag="RtAudio::closeStream" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void RtAudio::closeStream </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Public method which closes a stream and frees any associated buffers.
<p>
If a stream is not open, this method issues a warning and returns (an <a class="el" href="classRtError.html">RtError</a> is not thrown). </td>
</tr>
</table>
<a class="anchor" name="a11" doxytag="RtAudio::startStream" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void RtAudio::startStream </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Public method which starts a stream.
<p>
An <a class="el" href="classRtError.html">RtError</a> will be thrown if a driver error occurs or if called when no stream is open. </td>
</tr>
</table>
<a class="anchor" name="a12" doxytag="RtAudio::stopStream" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void RtAudio::stopStream </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.
<p>
An <a class="el" href="classRtError.html">RtError</a> will be thrown if a driver error occurs or if called when no stream is open. </td>
</tr>
</table>
<a class="anchor" name="a13" doxytag="RtAudio::abortStream" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void RtAudio::abortStream </td>
<td class="md" valign="top">(&nbsp;</td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">&nbsp;)&nbsp;</td>
<td class="md" nowrap><code> [inline]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Stop a stream, discarding any samples remaining in the input/output queue.
<p>
An <a class="el" href="classRtError.html">RtError</a> will be thrown if a driver error occurs or if called when no stream is open. </td>
</tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="RtAudio_8h-source.html">RtAudio.h</a></ul>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,38 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtError Member List</h1>This is the complete list of members for <a class="el" href="classRtError.html">RtError</a>, including all inherited members.<table>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w1">DEBUG_WARNING</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w8">DRIVER_ERROR</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#a4">getMessage</a>(void)</td><td><a class="el" href="classRtError.html">RtError</a></td><td><code> [inline, virtual]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#a5">getMessageString</a>(void)</td><td><a class="el" href="classRtError.html">RtError</a></td><td><code> [inline, virtual]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#a3">getType</a>(void)</td><td><a class="el" href="classRtError.html">RtError</a></td><td><code> [inline, virtual]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w4">INVALID_DEVICE</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w7">INVALID_PARAMETER</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w5">INVALID_STREAM</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w6">MEMORY_ERROR</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w3">NO_DEVICES_FOUND</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#a2">printMessage</a>(void)</td><td><a class="el" href="classRtError.html">RtError</a></td><td><code> [inline, virtual]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#a0">RtError</a>(const std::string &amp;message, Type type=RtError::UNSPECIFIED)</td><td><a class="el" href="classRtError.html">RtError</a></td><td><code> [inline]</code></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w9">SYSTEM_ERROR</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w10">THREAD_ERROR</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11">Type</a> enum name</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w2">UNSPECIFIED</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#w11w0">WARNING</a> enum value</td><td><a class="el" href="classRtError.html">RtError</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="classRtError.html#a1">~RtError</a>(void)</td><td><a class="el" href="classRtError.html">RtError</a></td><td><code> [inline, virtual]</code></td></tr>
</table><HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,129 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtError Class Reference</h1>Exception handling class for <a class="el" href="classRtAudio.html">RtAudio</a> &amp; RtMidi.
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="RtError_8h-source.html">RtError.h</a>&gt;</code>
<p>
<a href="classRtError-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>enum &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtError.html#w11">Type</a> { <br>
&nbsp;&nbsp;<a class="el" href="classRtError.html#w11w0">WARNING</a>,
<a class="el" href="classRtError.html#w11w1">DEBUG_WARNING</a>,
<a class="el" href="classRtError.html#w11w2">UNSPECIFIED</a>,
<a class="el" href="classRtError.html#w11w3">NO_DEVICES_FOUND</a>,
<br>
&nbsp;&nbsp;<a class="el" href="classRtError.html#w11w4">INVALID_DEVICE</a>,
<a class="el" href="classRtError.html#w11w5">INVALID_STREAM</a>,
<a class="el" href="classRtError.html#w11w6">MEMORY_ERROR</a>,
<a class="el" href="classRtError.html#w11w7">INVALID_PARAMETER</a>,
<br>
&nbsp;&nbsp;<a class="el" href="classRtError.html#w11w8">DRIVER_ERROR</a>,
<a class="el" href="classRtError.html#w11w9">SYSTEM_ERROR</a>,
<a class="el" href="classRtError.html#w11w10">THREAD_ERROR</a>
<br>
}</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Defined RtError types. </em> <a href="#w11">More...</a><em><br><br></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a0" doxytag="RtError::RtError" ></a>
&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtError.html#a0">RtError</a> (const std::string &amp;message, <a class="el" href="classRtError.html#w11">Type</a> type=RtError::UNSPECIFIED)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The constructor. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a1" doxytag="RtError::~RtError" ></a>
virtual&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtError.html#a1">~RtError</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The destructor. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a2" doxytag="RtError::printMessage" ></a>
virtual void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtError.html#a2">printMessage</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Prints thrown error message to stderr. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a3" doxytag="RtError::getType" ></a>
virtual const <a class="el" href="classRtError.html#w11">Type</a> &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtError.html#a3">getType</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the thrown error message type. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a4" doxytag="RtError::getMessage" ></a>
virtual const std::string &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtError.html#a4">getMessage</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the thrown error message string. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="a5" doxytag="RtError::getMessageString" ></a>
virtual const char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classRtError.html#a5">getMessageString</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the thrown error message as a C string. <br><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Exception handling class for <a class="el" href="classRtAudio.html">RtAudio</a> &amp; RtMidi.
<p>
The RtError class is quite simple but it does allow errors to be "caught" by <a class="el" href="classRtError.html#w11">RtError::Type</a>. See the <a class="el" href="classRtAudio.html">RtAudio</a> and RtMidi documentation to know which methods can throw an RtError.
<p>
<hr><h2>Member Enumeration Documentation</h2>
<a class="anchor" name="w11" doxytag="RtError::Type" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> enum <a class="el" href="classRtError.html#w11">RtError::Type</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Defined RtError types.
<p>
<dl compact><dt><b>Enumeration values: </b></dt><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em><a class="anchor" name="w11w0" doxytag="WARNING" ></a>WARNING</em>&nbsp;</td><td>
A non-critical error. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w1" doxytag="DEBUG_WARNING" ></a>DEBUG_WARNING</em>&nbsp;</td><td>
A non-critical error which might be useful for debugging. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w2" doxytag="UNSPECIFIED" ></a>UNSPECIFIED</em>&nbsp;</td><td>
The default, unspecified error type. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w3" doxytag="NO_DEVICES_FOUND" ></a>NO_DEVICES_FOUND</em>&nbsp;</td><td>
No devices found on system. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w4" doxytag="INVALID_DEVICE" ></a>INVALID_DEVICE</em>&nbsp;</td><td>
An invalid device ID was specified. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w5" doxytag="INVALID_STREAM" ></a>INVALID_STREAM</em>&nbsp;</td><td>
An invalid stream ID was specified. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w6" doxytag="MEMORY_ERROR" ></a>MEMORY_ERROR</em>&nbsp;</td><td>
An error occured during memory allocation. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w7" doxytag="INVALID_PARAMETER" ></a>INVALID_PARAMETER</em>&nbsp;</td><td>
An invalid parameter was specified to a function. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w8" doxytag="DRIVER_ERROR" ></a>DRIVER_ERROR</em>&nbsp;</td><td>
A system driver error occured. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w9" doxytag="SYSTEM_ERROR" ></a>SYSTEM_ERROR</em>&nbsp;</td><td>
A system error occured. </td></tr>
<tr><td valign=top><em><a class="anchor" name="w11w10" doxytag="THREAD_ERROR" ></a>THREAD_ERROR</em>&nbsp;</td><td>
A thread error occured. </td></tr>
</table>
</dl>
</td>
</tr>
</table>
<hr>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="RtError_8h-source.html">RtError.h</a></ul>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,169 @@
H1 {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
H2 {
font-family: Geneva, Arial, Helvetica, sans-serif;
}
CAPTION { font-weight: bold }
DIV.qindex { width: 100%;
background-color: #eeeeff;
border: 4px solid #eeeeff;
text-align: center;
margin-bottom: 2px
}
A.qindex { text-decoration: none; font-weight: bold; color: #0000ee }
A.qindex:visited { text-decoration: none; font-weight: bold; color: #0000ee }
A.qindex:hover { text-decoration: none; background-color: #ddddff }
A.qindexHL { text-decoration: none; font-weight: bold;
background-color: #6666cc;
color: #ffffff
}
A.qindexHL:hover { text-decoration: none; background-color: #6666cc; color: #ffffff }
A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff }
A.el { text-decoration: none; font-weight: bold }
A.elRef { font-weight: bold }
A.code { text-decoration: none; font-weight: normal; color: #4444ee }
A.codeRef { font-weight: normal; color: #4444ee }
A:hover { text-decoration: none; background-color: #f2f2ff }
DL.el { margin-left: -1cm }
DIV.fragment {
width: 98%;
border: 1px solid #CCCCCC;
background-color: #f5f5f5;
padding-left: 4px;
margin: 4px;
}
DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
TD.md { background-color: #f2f2ff; font-weight: bold; }
TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }
TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }
DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
BODY {
background: white;
color: black;
margin-right: 20px;
margin-left: 20px;
}
TD.indexkey {
background-color: #eeeeff;
font-weight: bold;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px
}
TD.indexvalue {
background-color: #eeeeff;
font-style: italic;
padding-right : 10px;
padding-top : 2px;
padding-left : 10px;
padding-bottom : 2px;
margin-left : 0px;
margin-right : 0px;
margin-top : 2px;
margin-bottom : 2px
}
TR.memlist {
background-color: #f0f0f0;
}
P.formulaDsp { text-align: center; }
IMG.formulaDsp { }
IMG.formulaInl { vertical-align: middle; }
SPAN.keyword { color: #008000 }
SPAN.keywordtype { color: #604020 }
SPAN.keywordflow { color: #e08000 }
SPAN.comment { color: #800000 }
SPAN.preprocessor { color: #806020 }
SPAN.stringliteral { color: #002080 }
SPAN.charliteral { color: #008080 }
.mdTable {
border: 1px solid #868686;
background-color: #f2f2ff;
}
.mdRow {
padding: 8px 20px;
}
.mdescLeft {
font-size: smaller;
font-family: Arial, Helvetica, sans-serif;
background-color: #FAFAFA;
padding-left: 8px;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
}
.mdescRight {
font-size: smaller;
font-family: Arial, Helvetica, sans-serif;
font-style: italic;
background-color: #FAFAFA;
padding-left: 4px;
border-top: 1px none #E0E0E0;
border-right: 1px none #E0E0E0;
border-bottom: 1px none #E0E0E0;
border-left: 1px none #E0E0E0;
margin: 0px;
padding-bottom: 0px;
padding-right: 8px;
}
.memItemLeft {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.memItemRight {
padding: 1px 0px 0px 8px;
margin: 4px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-top-color: #E0E0E0;
border-right-color: #E0E0E0;
border-bottom-color: #E0E0E0;
border-left-color: #E0E0E0;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
background-color: #FAFAFA;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
}
.search { color: #0000ee;
font-weight: bold;
}
FORM.search {
margin-bottom: 0px;
margin-top: 0px;
}
INPUT.search { font-size: 75%;
color: #000080;
font-weight: normal;
background-color: #eeeeff;
}
TD.tiny { font-size: 75%;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,23 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtAudio File List</h1>Here is a list of all documented files with brief descriptions:<table>
<tr><td class="indexkey"><b>RtAudio.h</b> <a href="RtAudio_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><b>RtError.h</b> <a href="RtError_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr>
</table>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,104 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<div class="qindex"><a class="qindexHL" href="functions.html">All</a> | <a class="qindex" href="functions_func.html">Functions</a> | <a class="qindex" href="functions_vars.html">Variables</a> | <a class="qindex" href="functions_enum.html">Enumerations</a> | <a class="qindex" href="functions_eval.html">Enumeration&nbsp;values</a></div>
<div class="qindex"><a class="qindex" href="#index_a">a</a> | <a class="qindex" href="#index_c">c</a> | <a class="qindex" href="#index_d">d</a> | <a class="qindex" href="#index_g">g</a> | <a class="qindex" href="#index_i">i</a> | <a class="qindex" href="#index_l">l</a> | <a class="qindex" href="#index_m">m</a> | <a class="qindex" href="#index_n">n</a> | <a class="qindex" href="#index_o">o</a> | <a class="qindex" href="#index_p">p</a> | <a class="qindex" href="#index_r">r</a> | <a class="qindex" href="#index_s">s</a> | <a class="qindex" href="#index_t">t</a> | <a class="qindex" href="#index_u">u</a> | <a class="qindex" href="#index_w">w</a> | <a class="qindex" href="#index_~">~</a></div>
<p>
<p>
Here is a list of all documented class members with links to the class documentation for each member:<h3><a class="anchor" name="index_a">- a -</a></h3><ul>
<li>abortStream()
: <a class="el" href="classRtAudio.html#a13">RtAudio</a></ul>
<h3><a class="anchor" name="index_c">- c -</a></h3><ul>
<li>cancelStreamCallback()
: <a class="el" href="classRtAudio.html#a5">RtAudio</a><li>closeStream()
: <a class="el" href="classRtAudio.html#a10">RtAudio</a></ul>
<h3><a class="anchor" name="index_d">- d -</a></h3><ul>
<li>DEBUG_WARNING
: <a class="el" href="classRtError.html#w11w1">RtError</a><li>DRIVER_ERROR
: <a class="el" href="classRtError.html#w11w8">RtError</a><li>duplexChannels
: <a class="el" href="structRtAudioDeviceInfo.html#o4">RtAudioDeviceInfo</a></ul>
<h3><a class="anchor" name="index_g">- g -</a></h3><ul>
<li>getDeviceCount()
: <a class="el" href="classRtAudio.html#a6">RtAudio</a><li>getDeviceInfo()
: <a class="el" href="classRtAudio.html#a7">RtAudio</a><li>getMessage()
: <a class="el" href="classRtError.html#a4">RtError</a><li>getMessageString()
: <a class="el" href="classRtError.html#a5">RtError</a><li>getStreamBuffer()
: <a class="el" href="classRtAudio.html#a8">RtAudio</a><li>getType()
: <a class="el" href="classRtError.html#a3">RtError</a></ul>
<h3><a class="anchor" name="index_i">- i -</a></h3><ul>
<li>inputChannels
: <a class="el" href="structRtAudioDeviceInfo.html#o3">RtAudioDeviceInfo</a><li>INVALID_DEVICE
: <a class="el" href="classRtError.html#w11w4">RtError</a><li>INVALID_PARAMETER
: <a class="el" href="classRtError.html#w11w7">RtError</a><li>INVALID_STREAM
: <a class="el" href="classRtError.html#w11w5">RtError</a><li>IRIX_AL
: <a class="el" href="classRtAudio.html#w8w5">RtAudio</a><li>isDefault
: <a class="el" href="structRtAudioDeviceInfo.html#o5">RtAudioDeviceInfo</a></ul>
<h3><a class="anchor" name="index_l">- l -</a></h3><ul>
<li>LINUX_ALSA
: <a class="el" href="classRtAudio.html#w8w1">RtAudio</a><li>LINUX_JACK
: <a class="el" href="classRtAudio.html#w8w3">RtAudio</a><li>LINUX_OSS
: <a class="el" href="classRtAudio.html#w8w2">RtAudio</a></ul>
<h3><a class="anchor" name="index_m">- m -</a></h3><ul>
<li>MACOSX_CORE
: <a class="el" href="classRtAudio.html#w8w4">RtAudio</a><li>MEMORY_ERROR
: <a class="el" href="classRtError.html#w11w6">RtError</a></ul>
<h3><a class="anchor" name="index_n">- n -</a></h3><ul>
<li>name
: <a class="el" href="structRtAudioDeviceInfo.html#o0">RtAudioDeviceInfo</a><li>nativeFormats
: <a class="el" href="structRtAudioDeviceInfo.html#o7">RtAudioDeviceInfo</a><li>NO_DEVICES_FOUND
: <a class="el" href="classRtError.html#w11w3">RtError</a></ul>
<h3><a class="anchor" name="index_o">- o -</a></h3><ul>
<li>openStream()
: <a class="el" href="classRtAudio.html#a3">RtAudio</a><li>outputChannels
: <a class="el" href="structRtAudioDeviceInfo.html#o2">RtAudioDeviceInfo</a></ul>
<h3><a class="anchor" name="index_p">- p -</a></h3><ul>
<li>printMessage()
: <a class="el" href="classRtError.html#a2">RtError</a><li>probed
: <a class="el" href="structRtAudioDeviceInfo.html#o1">RtAudioDeviceInfo</a></ul>
<h3><a class="anchor" name="index_r">- r -</a></h3><ul>
<li>RtAudio()
: <a class="el" href="classRtAudio.html#a1">RtAudio</a><li>RtAudioApi
: <a class="el" href="classRtAudio.html#w8">RtAudio</a><li>RtError()
: <a class="el" href="classRtError.html#a0">RtError</a></ul>
<h3><a class="anchor" name="index_s">- s -</a></h3><ul>
<li>sampleRates
: <a class="el" href="structRtAudioDeviceInfo.html#o6">RtAudioDeviceInfo</a><li>setStreamCallback()
: <a class="el" href="classRtAudio.html#a4">RtAudio</a><li>startStream()
: <a class="el" href="classRtAudio.html#a11">RtAudio</a><li>stopStream()
: <a class="el" href="classRtAudio.html#a12">RtAudio</a><li>SYSTEM_ERROR
: <a class="el" href="classRtError.html#w11w9">RtError</a></ul>
<h3><a class="anchor" name="index_t">- t -</a></h3><ul>
<li>THREAD_ERROR
: <a class="el" href="classRtError.html#w11w10">RtError</a><li>tickStream()
: <a class="el" href="classRtAudio.html#a9">RtAudio</a><li>Type
: <a class="el" href="classRtError.html#w11">RtError</a></ul>
<h3><a class="anchor" name="index_u">- u -</a></h3><ul>
<li>UNSPECIFIED
: <a class="el" href="classRtError.html#w11w2">RtError</a>, <a class="el" href="classRtAudio.html#w8w0">RtAudio</a></ul>
<h3><a class="anchor" name="index_w">- w -</a></h3><ul>
<li>WARNING
: <a class="el" href="classRtError.html#w11w0">RtError</a><li>WINDOWS_ASIO
: <a class="el" href="classRtAudio.html#w8w6">RtAudio</a><li>WINDOWS_DS
: <a class="el" href="classRtAudio.html#w8w7">RtAudio</a></ul>
<h3><a class="anchor" name="index_~">- ~ -</a></h3><ul>
<li>~RtAudio()
: <a class="el" href="classRtAudio.html#a2">RtAudio</a><li>~RtError()
: <a class="el" href="classRtError.html#a1">RtError</a></ul>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,26 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<div class="qindex"><a class="qindex" href="functions.html">All</a> | <a class="qindex" href="functions_func.html">Functions</a> | <a class="qindex" href="functions_vars.html">Variables</a> | <a class="qindexHL" href="functions_enum.html">Enumerations</a> | <a class="qindex" href="functions_eval.html">Enumeration&nbsp;values</a></div>
<p>
<ul>
<li>RtAudioApi
: <a class="el" href="classRtAudio.html#w8">RtAudio</a><li>Type
: <a class="el" href="classRtError.html#w11">RtError</a></ul>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,42 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<div class="qindex"><a class="qindex" href="functions.html">All</a> | <a class="qindex" href="functions_func.html">Functions</a> | <a class="qindex" href="functions_vars.html">Variables</a> | <a class="qindex" href="functions_enum.html">Enumerations</a> | <a class="qindexHL" href="functions_eval.html">Enumeration&nbsp;values</a></div>
<p>
<ul>
<li>DEBUG_WARNING
: <a class="el" href="classRtError.html#w11w1">RtError</a><li>DRIVER_ERROR
: <a class="el" href="classRtError.html#w11w8">RtError</a><li>INVALID_DEVICE
: <a class="el" href="classRtError.html#w11w4">RtError</a><li>INVALID_PARAMETER
: <a class="el" href="classRtError.html#w11w7">RtError</a><li>INVALID_STREAM
: <a class="el" href="classRtError.html#w11w5">RtError</a><li>IRIX_AL
: <a class="el" href="classRtAudio.html#w8w5">RtAudio</a><li>LINUX_ALSA
: <a class="el" href="classRtAudio.html#w8w1">RtAudio</a><li>LINUX_JACK
: <a class="el" href="classRtAudio.html#w8w3">RtAudio</a><li>LINUX_OSS
: <a class="el" href="classRtAudio.html#w8w2">RtAudio</a><li>MACOSX_CORE
: <a class="el" href="classRtAudio.html#w8w4">RtAudio</a><li>MEMORY_ERROR
: <a class="el" href="classRtError.html#w11w6">RtError</a><li>NO_DEVICES_FOUND
: <a class="el" href="classRtError.html#w11w3">RtError</a><li>SYSTEM_ERROR
: <a class="el" href="classRtError.html#w11w9">RtError</a><li>THREAD_ERROR
: <a class="el" href="classRtError.html#w11w10">RtError</a><li>UNSPECIFIED
: <a class="el" href="classRtError.html#w11w2">RtError</a>, <a class="el" href="classRtAudio.html#w8w0">RtAudio</a><li>WARNING
: <a class="el" href="classRtError.html#w11w0">RtError</a><li>WINDOWS_ASIO
: <a class="el" href="classRtAudio.html#w8w6">RtAudio</a><li>WINDOWS_DS
: <a class="el" href="classRtAudio.html#w8w7">RtAudio</a></ul>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,43 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<div class="qindex"><a class="qindex" href="functions.html">All</a> | <a class="qindexHL" href="functions_func.html">Functions</a> | <a class="qindex" href="functions_vars.html">Variables</a> | <a class="qindex" href="functions_enum.html">Enumerations</a> | <a class="qindex" href="functions_eval.html">Enumeration&nbsp;values</a></div>
<p>
<ul>
<li>abortStream()
: <a class="el" href="classRtAudio.html#a13">RtAudio</a><li>cancelStreamCallback()
: <a class="el" href="classRtAudio.html#a5">RtAudio</a><li>closeStream()
: <a class="el" href="classRtAudio.html#a10">RtAudio</a><li>getDeviceCount()
: <a class="el" href="classRtAudio.html#a6">RtAudio</a><li>getDeviceInfo()
: <a class="el" href="classRtAudio.html#a7">RtAudio</a><li>getMessage()
: <a class="el" href="classRtError.html#a4">RtError</a><li>getMessageString()
: <a class="el" href="classRtError.html#a5">RtError</a><li>getStreamBuffer()
: <a class="el" href="classRtAudio.html#a8">RtAudio</a><li>getType()
: <a class="el" href="classRtError.html#a3">RtError</a><li>openStream()
: <a class="el" href="classRtAudio.html#a3">RtAudio</a><li>printMessage()
: <a class="el" href="classRtError.html#a2">RtError</a><li>RtAudio()
: <a class="el" href="classRtAudio.html#a1">RtAudio</a><li>RtError()
: <a class="el" href="classRtError.html#a0">RtError</a><li>setStreamCallback()
: <a class="el" href="classRtAudio.html#a4">RtAudio</a><li>startStream()
: <a class="el" href="classRtAudio.html#a11">RtAudio</a><li>stopStream()
: <a class="el" href="classRtAudio.html#a12">RtAudio</a><li>tickStream()
: <a class="el" href="classRtAudio.html#a9">RtAudio</a><li>~RtAudio()
: <a class="el" href="classRtAudio.html#a2">RtAudio</a><li>~RtError()
: <a class="el" href="classRtError.html#a1">RtError</a></ul>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,32 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<div class="qindex"><a class="qindex" href="functions.html">All</a> | <a class="qindex" href="functions_func.html">Functions</a> | <a class="qindexHL" href="functions_vars.html">Variables</a> | <a class="qindex" href="functions_enum.html">Enumerations</a> | <a class="qindex" href="functions_eval.html">Enumeration&nbsp;values</a></div>
<p>
<ul>
<li>duplexChannels
: <a class="el" href="structRtAudioDeviceInfo.html#o4">RtAudioDeviceInfo</a><li>inputChannels
: <a class="el" href="structRtAudioDeviceInfo.html#o3">RtAudioDeviceInfo</a><li>isDefault
: <a class="el" href="structRtAudioDeviceInfo.html#o5">RtAudioDeviceInfo</a><li>name
: <a class="el" href="structRtAudioDeviceInfo.html#o0">RtAudioDeviceInfo</a><li>nativeFormats
: <a class="el" href="structRtAudioDeviceInfo.html#o7">RtAudioDeviceInfo</a><li>outputChannels
: <a class="el" href="structRtAudioDeviceInfo.html#o2">RtAudioDeviceInfo</a><li>probed
: <a class="el" href="structRtAudioDeviceInfo.html#o1">RtAudioDeviceInfo</a><li>sampleRates
: <a class="el" href="structRtAudioDeviceInfo.html#o6">RtAudioDeviceInfo</a></ul>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,573 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>The <a class="el" href="classRtAudio.html">RtAudio</a> Tutorial </h1>
<p>
<center><a class="el" href="index.html#intro">Introduction</a> &nbsp;&nbsp; <a class="el" href="index.html#changes">What's New (Version 3.0)</a> &nbsp;&nbsp;<a class="el" href="index.html#download">Download</a> &nbsp;&nbsp; <a class="el" href="index.html#start">Getting Started</a> &nbsp;&nbsp; <a class="el" href="index.html#error">Error Handling</a> &nbsp;&nbsp; <a class="el" href="index.html#probing">Probing Device Capabilities</a> &nbsp;&nbsp; <a class="el" href="index.html#settings">Device Settings</a> &nbsp;&nbsp; <a class="el" href="index.html#playbackb">Playback (blocking functionality)</a> &nbsp;&nbsp; <a class="el" href="index.html#playbackc">Playback (callback functionality)</a> &nbsp;&nbsp; <a class="el" href="index.html#recording">Recording</a> &nbsp;&nbsp; <a class="el" href="index.html#duplex">Duplex Mode</a> &nbsp;&nbsp; <a class="el" href="index.html#multi">Using Simultaneous Multiple APIs</a> &nbsp;&nbsp; <a class="el" href="index.html#methods">Summary of Methods</a> &nbsp;&nbsp; <a class="el" href="index.html#compiling">Compiling</a> &nbsp;&nbsp; <a class="el" href="index.html#debug">Debugging</a> &nbsp;&nbsp; <a class="el" href="index.html#apinotes">API Notes</a> &nbsp;&nbsp; <a class="el" href="index.html#acknowledge">Acknowledgements</a> &nbsp;&nbsp; <a class="el" href="index.html#license">License</a></center><h2><a class="anchor" name="intro">
Introduction</a></h2>
<a class="el" href="classRtAudio.html">RtAudio</a> is a set of C++ classes which provide a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA, JACK, and OSS), Macintosh OS X, SGI, and Windows (DirectSound and ASIO) operating systems. <a class="el" href="classRtAudio.html">RtAudio</a> significantly simplifies the process of interacting with computer audio hardware. It was designed with the following goals:<p>
<ul>
<li>
object oriented C++ design </li>
<li>
simple, common API across all supported platforms </li>
<li>
only two header files and one source file for easy inclusion in programming projects </li>
<li>
allow simultaneous multi-api support </li>
<li>
blocking functionality </li>
<li>
callback functionality </li>
<li>
extensive audio device parameter control </li>
<li>
audio device capability probing </li>
<li>
automatic internal conversion for data format, channel number compensation, de-interleaving, and byte-swapping </li>
</ul>
<p>
<a class="el" href="classRtAudio.html">RtAudio</a> 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 <a class="el" href="classRtAudio.html">RtAudio</a> instance. See the <a class="el" href="index.html#apinotes">API Notes</a> section for information specific to each of the supported audio APIs.<p>
The <a class="el" href="classRtAudio.html">RtAudio</a> 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.<h2><a class="anchor" name="changes">
What's New (Version 3.0)</a></h2>
<a class="el" href="classRtAudio.html">RtAudio</a> now allows simultaneous multi-api support. For example, you can compile <a class="el" href="classRtAudio.html">RtAudio</a> 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 <a class="el" href="classRtAudio.html">RtAudio</a> is now a "controller" which creates an instance of an RtApi subclass based on the user's API choice via an optional <a class="el" href="classRtAudio.html#w8">RtAudio::RtAudioApi</a> instantiation argument. If no API is specified, <a class="el" href="classRtAudio.html">RtAudio</a> attempts to make a "logical" API selection.<p>
Support for the JACK low-latency audio server has been added with this version of <a class="el" href="classRtAudio.html">RtAudio</a>. It is necessary to have the JACK server running before creating an instance of <a class="el" href="classRtAudio.html">RtAudio</a>.<p>
Several API changes have been made in version 3.0 of <a class="el" href="classRtAudio.html">RtAudio</a> 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 <a class="el" href="classRtAudio.html">RtAudio</a> 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).<p>
The <a class="el" href="classRtAudio.html#a7">RtAudio::getDeviceInfo()</a> function was modified to return a globally defined <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> 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 <a class="el" href="RtAudio_8h.html">RtAudio.h</a>. These changes were made for clarity and to better conform with standard C++ programming practices.<p>
The <a class="el" href="classRtError.html">RtError</a> class declaration and definition have been extracted to a separate file (<a class="el" href="RtError_8h.html">RtError.h</a>). This was done in preparation for a new release of the RtMidi class (planned for Summer 2004).<h2><a class="anchor" name="download">
Download</a></h2>
Latest Release (22 March 2004): <a href="http://music.mcgill.ca/~gary/rtaudio/release/rtaudio-3.0.1.tar.gz">Version 3.0.1 (200 kB tar/gzipped)</a><h2><a class="anchor" name="start">
Getting Started</a></h2>
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, <a class="el" href="classRtAudio.html">RtAudio</a> attempts to select the most "logical" available API).<p>
The first thing that must be done when using <a class="el" href="classRtAudio.html">RtAudio</a> 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. <a class="el" href="classRtAudio.html">RtAudio</a> 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:<p>
<div class="fragment"><pre><span class="preprocessor">#include "RtAudio.h"</span>
<span class="keywordtype">int</span> main()
{
<a class="code" href="classRtAudio.html">RtAudio</a> *audio;
<span class="comment">// Default RtAudio constructor</span>
<span class="keywordflow">try</span> {
audio = <span class="keyword">new</span> <a class="code" href="classRtAudio.html">RtAudio</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
<span class="comment">// Handle the exception here</span>
error.printMessage();
}
<span class="comment">// Clean up</span>
<span class="keyword">delete</span> audio;
}
</pre></div><p>
Obviously, this example doesn't demonstrate any of the real functionality of <a class="el" href="classRtAudio.html">RtAudio</a>. However, all uses of <a class="el" href="classRtAudio.html">RtAudio</a> must begin with a constructor (either default or overloaded varieties) and must end with class destruction. Further, it is necessary that all class methods which can throw a C++ exception be called within a try/catch block.<h2><a class="anchor" name="error">
Error Handling</a></h2>
<a class="el" href="classRtAudio.html">RtAudio</a> uses a C++ exception handler called <a class="el" href="classRtError.html">RtError</a>, which is declared and defined in <a class="el" href="RtError_8h.html">RtError.h</a>. The <a class="el" href="classRtError.html">RtError</a> class is quite simple but it does allow errors to be "caught" by <a class="el" href="classRtError.html#w11">RtError::Type</a>. Almost all <a class="el" href="classRtAudio.html">RtAudio</a> methods can "throw" an <a class="el" href="classRtError.html">RtError</a>, most typically if a driver error occurs or a stream function is called when no stream is open. There are a number of cases within <a class="el" href="classRtAudio.html">RtAudio</a> where warning messages may be displayed but an exception is not thrown. There is a protected <a class="el" href="classRtAudio.html">RtAudio</a> method, error(), which can be modified to globally control how these messages are handled and reported. By default, error messages are not automatically displayed in <a class="el" href="classRtAudio.html">RtAudio</a> unless the preprocessor definition __RTAUDIO_DEBUG__ is defined. Messages associated with caught exceptions can be displayed with, for example, the <a class="el" href="classRtError.html#a2">RtError::printMessage()</a> function.<h2><a class="anchor" name="probing">
Probing Device Capabilities</a></h2>
A programmer may wish to query the available audio device capabilities before deciding which to use. The following example outlines how this can be done.<p>
<div class="fragment"><pre><span class="comment">// probe.cpp</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include "RtAudio.h"</span>
<span class="keywordtype">int</span> main()
{
<a class="code" href="classRtAudio.html">RtAudio</a> *audio;
<span class="comment">// Default RtAudio constructor</span>
<span class="keywordflow">try</span> {
audio = <span class="keyword">new</span> <a class="code" href="classRtAudio.html">RtAudio</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
exit(EXIT_FAILURE);
}
<span class="comment">// Determine the number of devices available</span>
<span class="keywordtype">int</span> devices = audio-&gt;<a class="code" href="classRtAudio.html#a6">getDeviceCount</a>();
<span class="comment">// Scan through devices for various capabilities</span>
<a class="code" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> info;
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=1; i&lt;=devices; i++) {
<span class="keywordflow">try</span> {
info = audio-&gt;<a class="code" href="classRtAudio.html#a7">getDeviceInfo</a>(i);
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
<span class="keywordflow">break</span>;
}
<span class="comment">// Print, for example, the maximum number of output channels for each device</span>
std::cout &lt;&lt; <span class="stringliteral">"device = "</span> &lt;&lt; i;
std::cout &lt;&lt; <span class="stringliteral">": maximum output channels = "</span> &lt;&lt; info.<a class="code" href="structRtAudioDeviceInfo.html#o2">outputChannels</a> &lt;&lt; <span class="stringliteral">"\n"</span>;
}
<span class="comment">// Clean up</span>
<span class="keyword">delete</span> audio;
<span class="keywordflow">return</span> 0;
}
</pre></div><p>
The <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> structure is defined in <a class="el" href="RtAudio_8h.html">RtAudio.h</a> and provides a variety of information useful in assessing the capabilities of a device:<p>
<div class="fragment"><pre> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a>{
std::string <a class="code" href="structRtAudioDeviceInfo.html#o0">name</a>; <span class="comment">// Character string device identifier.</span>
<span class="keywordtype">bool</span> <a class="code" href="structRtAudioDeviceInfo.html#o1">probed</a>; <span class="comment">// true if the device capabilities were successfully probed.</span>
<span class="keywordtype">int</span> <a class="code" href="structRtAudioDeviceInfo.html#o2">outputChannels</a>; <span class="comment">// Maximum output channels supported by device.</span>
<span class="keywordtype">int</span> <a class="code" href="structRtAudioDeviceInfo.html#o3">inputChannels</a>; <span class="comment">// Maximum input channels supported by device.</span>
<span class="keywordtype">int</span> <a class="code" href="structRtAudioDeviceInfo.html#o4">duplexChannels</a>; <span class="comment">// Maximum simultaneous input/output channels supported by device.</span>
<span class="keywordtype">bool</span> <a class="code" href="structRtAudioDeviceInfo.html#o5">isDefault</a>; <span class="comment">// true if this is the default output or input device.</span>
std::vector&lt;int&gt; <a class="code" href="structRtAudioDeviceInfo.html#o6">sampleRates</a>; <span class="comment">// Supported sample rates.</span>
RtAudioFormat <a class="code" href="structRtAudioDeviceInfo.html#o7">nativeFormats</a>; <span class="comment">// Bit mask of supported data formats.</span>
};
</pre></div><p>
The following data formats are defined and fully supported by <a class="el" href="classRtAudio.html">RtAudio</a>:<p>
<div class="fragment"><pre> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> RtAudioFormat;
<span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_SINT8; <span class="comment">// Signed 8-bit integer</span>
<span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_SINT16; <span class="comment">// Signed 16-bit integer</span>
<span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_SINT24; <span class="comment">// Signed 24-bit integer (upper 3 bytes of 32-bit signed integer.)</span>
<span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_SINT32; <span class="comment">// Signed 32-bit integer</span>
<span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_FLOAT32; <span class="comment">// 32-bit float normalized between +/- 1.0</span>
<span class="keyword">static</span> <span class="keyword">const</span> RtAudioFormat RTAUDIO_FLOAT64; <span class="comment">// 64-bit double normalized between +/- 1.0</span>
</pre></div><p>
The <em>nativeFormats</em> member of the <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> structure is a bit mask of the above formats which are natively supported by the device. However, <a class="el" href="classRtAudio.html">RtAudio</a> will automatically provide format conversion if a particular format is not natively supported. When the <em>probed</em> member of the <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> structure is false, the remaining structure members are undefined and the device is probably unuseable.<p>
While some audio devices may require a minimum channel value greater than one, <a class="el" href="classRtAudio.html">RtAudio</a> will provide automatic channel number compensation when the number of channels set by the user is less than that required by the device. Channel compensation is <em>NOT</em> possible when the number of channels set by the user is greater than that supported by the device.<p>
It should be noted that the capabilities reported by a device driver or underlying audio API are not always accurate and/or may be dependent on a combination of device settings. For this reason, <a class="el" href="classRtAudio.html">RtAudio</a> does not typically rely on the queried values when attempting to open a stream.<h2><a class="anchor" name="settings">
Device Settings</a></h2>
The next step in using <a class="el" href="classRtAudio.html">RtAudio</a> is to open a stream with particular device and parameter settings.<p>
<div class="fragment"><pre><span class="preprocessor">#include "RtAudio.h"</span>
<span class="keywordtype">int</span> main()
{
<span class="keywordtype">int</span> channels = 2;
<span class="keywordtype">int</span> sampleRate = 44100;
<span class="keywordtype">int</span> bufferSize = 256; <span class="comment">// 256 sample frames</span>
<span class="keywordtype">int</span> nBuffers = 4; <span class="comment">// number of internal buffers used by device</span>
<span class="keywordtype">int</span> device = 0; <span class="comment">// 0 indicates the default or first available device</span>
<a class="code" href="classRtAudio.html">RtAudio</a> *audio;
<span class="comment">// Instantiate RtAudio and open a stream within a try/catch block</span>
<span class="keywordflow">try</span> {
audio = <span class="keyword">new</span> <a class="code" href="classRtAudio.html">RtAudio</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
exit(EXIT_FAILURE);
}
<span class="keywordflow">try</span> {
audio-&gt;<a class="code" href="classRtAudio.html#a3">openStream</a>(device, channels, 0, 0, RTAUDIO_FLOAT32,
sampleRate, &amp;bufferSize, nBuffers);
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
<span class="comment">// Perhaps try other parameters?</span>
}
<span class="comment">// Clean up</span>
<span class="keyword">delete</span> audio;
<span class="keywordflow">return</span> 0;
}
</pre></div><p>
The <a class="el" href="classRtAudio.html#a3">RtAudio::openStream()</a> method attempts to open a stream with a specified set of parameter values. In this case, we attempt to open a two channel playback stream with the default output device, 32-bit floating point data, a sample rate of 44100 Hz, a frame rate of 256 sample frames per read/write, and 4 internal device buffers. When device = 0, <a class="el" href="classRtAudio.html">RtAudio</a> first attempts to open the default audio device with the given parameters. If that attempt fails, <a class="el" href="classRtAudio.html">RtAudio</a> searches through the remaining available devices in an effort to find a device which will meet the given parameters. If all attempts are unsuccessful, an <a class="el" href="classRtError.html">RtError</a> is thrown. When a non-zero device value is specified, an attempt is made to open that device <em>ONLY</em> (device = 1 specifies the first identified device, as reported by <a class="el" href="classRtAudio.html#a7">RtAudio::getDeviceInfo()</a>).<p>
<a class="el" href="classRtAudio.html">RtAudio</a> provides four signed integer and two floating point data formats which can be specified using the RtAudioFormat parameter values mentioned earlier. If the opened device does not natively support the given format, <a class="el" href="classRtAudio.html">RtAudio</a> will automatically perform the necessary data format conversion.<p>
The <em>bufferSize</em> parameter specifies the desired number of sample frames which will be written to and/or read from a device per write/read operation. The <em>nBuffers</em> parameter is used in setting the underlying device buffer parameters. Both the <em>bufferSize</em> and <em>nBuffers</em> parameters can be used to control stream latency though there is no guarantee that the passed values will be those used by a device (the <em>nBuffers</em> parameter is ignored when using the OS X CoreAudio, Linux Jack, and the Windows ASIO APIs). In general, lower values for both parameters will produce less latency but perhaps less robust performance. Both parameters can be specified with values of zero, in which case the smallest allowable values will be used. The <em>bufferSize</em> parameter is passed as a pointer and the actual value used by the stream is set during the device setup procedure. <em>bufferSize</em> values should be a power of two. Optimal and allowable buffer values tend to vary between systems and devices. Check the <a class="el" href="index.html#apinotes">API Notes</a> section for general guidelines.<p>
As noted earlier, the device capabilities reported by a driver or underlying audio API are not always accurate and/or may be dependent on a combination of device settings. Because of this, <a class="el" href="classRtAudio.html">RtAudio</a> does not attempt to query a device's capabilities or use previously reported values when opening a device. Instead, <a class="el" href="classRtAudio.html">RtAudio</a> simply attempts to set the given parameters on a specified device and then checks whether the setup is successful or not.<h2><a class="anchor" name="playbackb">
Playback (blocking functionality)</a></h2>
Once the device is open for playback, there are only a few final steps necessary for realtime audio output. We'll first provide an example (blocking functionality) and then discuss the details.<p>
<div class="fragment"><pre><span class="comment">// playback.cpp</span>
<span class="preprocessor">#include "RtAudio.h"</span>
<span class="keywordtype">int</span> main()
{
<span class="keywordtype">int</span> count;
<span class="keywordtype">int</span> channels = 2;
<span class="keywordtype">int</span> sampleRate = 44100;
<span class="keywordtype">int</span> bufferSize = 256; <span class="comment">// 256 sample frames</span>
<span class="keywordtype">int</span> nBuffers = 4; <span class="comment">// number of internal buffers used by device</span>
<span class="keywordtype">float</span> *buffer;
<span class="keywordtype">int</span> device = 0; <span class="comment">// 0 indicates the default or first available device</span>
<a class="code" href="classRtAudio.html">RtAudio</a> *audio;
<span class="comment">// Open a stream during RtAudio instantiation</span>
<span class="keywordflow">try</span> {
audio = <span class="keyword">new</span> <a class="code" href="classRtAudio.html">RtAudio</a>(device, channels, 0, 0, RTAUDIO_FLOAT32,
sampleRate, &amp;bufferSize, nBuffers);
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
exit(EXIT_FAILURE);
}
<span class="keywordflow">try</span> {
<span class="comment">// Get a pointer to the stream buffer</span>
buffer = (<span class="keywordtype">float</span> *) audio-&gt;<a class="code" href="classRtAudio.html#a8">getStreamBuffer</a>();
<span class="comment">// Start the stream</span>
audio-&gt;<a class="code" href="classRtAudio.html#a11">startStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
<span class="keywordflow">goto</span> cleanup;
}
<span class="comment">// An example loop which runs for 40000 sample frames</span>
count = 0;
<span class="keywordflow">while</span> (count &lt; 40000) {
<span class="comment">// Generate your samples and fill the buffer with bufferSize sample frames of data</span>
...
<span class="comment">// Trigger the output of the data buffer</span>
<span class="keywordflow">try</span> {
audio-&gt;<a class="code" href="classRtAudio.html#a9">tickStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
<span class="keywordflow">goto</span> cleanup;
}
count += bufferSize;
}
<span class="keywordflow">try</span> {
<span class="comment">// Stop and close the stream</span>
audio-&gt;<a class="code" href="classRtAudio.html#a12">stopStream</a>();
audio-&gt;<a class="code" href="classRtAudio.html#a10">closeStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
}
cleanup:
<span class="keyword">delete</span> audio;
<span class="keywordflow">return</span> 0;
}
</pre></div><p>
The first thing to notice in this example is that we attempt to open a stream during class instantiation with an overloaded constructor. This constructor simply combines the functionality of the default constructor, used earlier, and the <a class="el" href="classRtAudio.html#a3">RtAudio::openStream()</a> method. Again, we have specified a device value of 0, indicating that the default or first available device meeting the given parameters should be used. An attempt is made to open the stream with the specified <em>bufferSize</em> value. However, it is possible that the device will not accept this value, in which case the closest allowable size is used and returned via the pointer value. The constructor can fail if no available devices are found, or a memory allocation or device driver error occurs. Note that you should not call the <a class="el" href="classRtAudio.html">RtAudio</a> destructor if an exception is thrown during instantiation.<p>
Assuming the constructor is successful, it is necessary to get a pointer to the buffer, provided by <a class="el" href="classRtAudio.html">RtAudio</a>, for use in feeding data to/from the opened stream. Note that the user should <em>NOT</em> attempt to deallocate the stream buffer memory ... memory management for the stream buffer will be automatically controlled by <a class="el" href="classRtAudio.html">RtAudio</a>. After starting the stream with <a class="el" href="classRtAudio.html#a11">RtAudio::startStream()</a>, one simply fills that buffer, which is of length equal to the returned <em>bufferSize</em> value, with interleaved audio data (in the specified format) for playback. Finally, a call to the <a class="el" href="classRtAudio.html#a9">RtAudio::tickStream()</a> routine triggers a blocking write call for the stream.<p>
In general, one should call the <a class="el" href="classRtAudio.html#a12">RtAudio::stopStream()</a> and <a class="el" href="classRtAudio.html#a10">RtAudio::closeStream()</a> methods after finishing with a stream. However, both methods will implicitly be called during object destruction if necessary.<h2><a class="anchor" name="playbackc">
Playback (callback functionality)</a></h2>
The primary difference in using <a class="el" href="classRtAudio.html">RtAudio</a> with callback functionality involves the creation of a user-defined callback function. Here is an example which produces a sawtooth waveform for playback.<p>
<div class="fragment"><pre><span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include "RtAudio.h"</span>
<span class="comment">// Two-channel sawtooth wave generator.</span>
<span class="keywordtype">int</span> sawtooth(<span class="keywordtype">char</span> *buffer, <span class="keywordtype">int</span> bufferSize, <span class="keywordtype">void</span> *data)
{
<span class="keywordtype">int</span> i, j;
<span class="keywordtype">double</span> *my_buffer = (<span class="keywordtype">double</span> *) buffer;
<span class="keywordtype">double</span> *my_data = (<span class="keywordtype">double</span> *) data;
<span class="comment">// Write interleaved audio data.</span>
<span class="keywordflow">for</span> (i=0; i&lt;bufferSize; i++) {
<span class="keywordflow">for</span> (j=0; j&lt;2; j++) {
*my_buffer++ = my_data[j];
my_data[j] += 0.005 * (j+1+(j*0.1));
<span class="keywordflow">if</span> (my_data[j] &gt;= 1.0) my_data[j] -= 2.0;
}
}
<span class="keywordflow">return</span> 0;
}
<span class="keywordtype">int</span> main()
{
<span class="keywordtype">int</span> channels = 2;
<span class="keywordtype">int</span> sampleRate = 44100;
<span class="keywordtype">int</span> bufferSize = 256; <span class="comment">// 256 sample frames</span>
<span class="keywordtype">int</span> nBuffers = 4; <span class="comment">// number of internal buffers used by device</span>
<span class="keywordtype">int</span> device = 0; <span class="comment">// 0 indicates the default or first available device</span>
<span class="keywordtype">double</span> data[2];
<span class="keywordtype">char</span> input;
<a class="code" href="classRtAudio.html">RtAudio</a> *audio;
<span class="comment">// Open a stream during RtAudio instantiation</span>
<span class="keywordflow">try</span> {
audio = <span class="keyword">new</span> <a class="code" href="classRtAudio.html">RtAudio</a>(device, channels, 0, 0, RTAUDIO_FLOAT64,
sampleRate, &amp;bufferSize, nBuffers);
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
exit(EXIT_FAILURE);
}
<span class="keywordflow">try</span> {
<span class="comment">// Set the stream callback function</span>
audio-&gt;<a class="code" href="classRtAudio.html#a4">setStreamCallback</a>(&amp;sawtooth, (<span class="keywordtype">void</span> *)data);
<span class="comment">// Start the stream</span>
audio-&gt;<a class="code" href="classRtAudio.html#a11">startStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
<span class="keywordflow">goto</span> cleanup;
}
std::cout &lt;&lt; <span class="stringliteral">"\nPlaying ... press &lt;enter&gt; to quit.\n"</span>;
std::cin.get(input);
<span class="keywordflow">try</span> {
<span class="comment">// Stop and close the stream</span>
audio-&gt;<a class="code" href="classRtAudio.html#a12">stopStream</a>();
audio-&gt;<a class="code" href="classRtAudio.html#a10">closeStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
}
cleanup:
<span class="keyword">delete</span> audio;
<span class="keywordflow">return</span> 0;
}
</pre></div><p>
After opening the device in exactly the same way as the previous example (except with a data format change), we must set our callback function for the stream using <a class="el" href="classRtAudio.html#a4">RtAudio::setStreamCallback()</a>. When the underlying audio API uses blocking calls (OSS, ALSA, SGI, and Windows DirectSound), this method will spawn a new process (or thread) which automatically calls the callback function when more data is needed. Callback-based audio APIs (OS X CoreAudio Linux Jack, and ASIO) implement their own event notification schemes. Note that the callback function is called only when the stream is "running" (between calls to the <a class="el" href="classRtAudio.html#a11">RtAudio::startStream()</a> and <a class="el" href="classRtAudio.html#a12">RtAudio::stopStream()</a> methods). The last argument to <a class="el" href="classRtAudio.html#a4">RtAudio::setStreamCallback()</a> is a pointer to arbitrary data that you wish to access from within your callback function.<p>
In this example, we stop the stream with an explicit call to <a class="el" href="classRtAudio.html#a12">RtAudio::stopStream()</a>. When using callback functionality, it is also possible to stop a stream by returning a non-zero value from the callback function.<p>
Once set with <a class="el" href="classRtAudio.html#a4">RtAudio::setStreamCallback</a>, the callback process exists for the life of the stream (until the stream is closed with <a class="el" href="classRtAudio.html#a10">RtAudio::closeStream()</a> or the <a class="el" href="classRtAudio.html">RtAudio</a> instance is deleted). It is possible to disassociate a callback function and cancel its process for an open stream using the <a class="el" href="classRtAudio.html#a5">RtAudio::cancelStreamCallback()</a> method. The stream can then be used with blocking functionality or a new callback can be associated with it.<h2><a class="anchor" name="recording">
Recording</a></h2>
Using <a class="el" href="classRtAudio.html">RtAudio</a> for audio input is almost identical to the way it is used for playback. Here's the blocking playback example rewritten for recording:<p>
<div class="fragment"><pre><span class="comment">// record.cpp</span>
<span class="preprocessor">#include "RtAudio.h"</span>
<span class="keywordtype">int</span> main()
{
<span class="keywordtype">int</span> count;
<span class="keywordtype">int</span> channels = 2;
<span class="keywordtype">int</span> sampleRate = 44100;
<span class="keywordtype">int</span> bufferSize = 256; <span class="comment">// 256 sample frames</span>
<span class="keywordtype">int</span> nBuffers = 4; <span class="comment">// number of internal buffers used by device</span>
<span class="keywordtype">float</span> *buffer;
<span class="keywordtype">int</span> device = 0; <span class="comment">// 0 indicates the default or first available device</span>
<a class="code" href="classRtAudio.html">RtAudio</a> *audio;
<span class="comment">// Instantiate RtAudio and open a stream.</span>
<span class="keywordflow">try</span> {
audio = <span class="keyword">new</span> <a class="code" href="classRtAudio.html">RtAudio</a>(&amp;stream, 0, 0, device, channels,
RTAUDIO_FLOAT32, sampleRate, &amp;bufferSize, nBuffers);
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
exit(EXIT_FAILURE);
}
<span class="keywordflow">try</span> {
<span class="comment">// Get a pointer to the stream buffer</span>
buffer = (<span class="keywordtype">float</span> *) audio-&gt;<a class="code" href="classRtAudio.html#a8">getStreamBuffer</a>();
<span class="comment">// Start the stream</span>
audio-&gt;<a class="code" href="classRtAudio.html#a11">startStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
<span class="keywordflow">goto</span> cleanup;
}
<span class="comment">// An example loop which runs for about 40000 sample frames</span>
count = 0;
<span class="keywordflow">while</span> (count &lt; 40000) {
<span class="comment">// Read a buffer of data</span>
<span class="keywordflow">try</span> {
audio-&gt;<a class="code" href="classRtAudio.html#a9">tickStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
<span class="keywordflow">goto</span> cleanup;
}
<span class="comment">// Process the input samples (bufferSize sample frames) that were read</span>
...
count += bufferSize;
}
<span class="keywordflow">try</span> {
<span class="comment">// Stop the stream</span>
audio-&gt;<a class="code" href="classRtAudio.html#a12">stopStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
}
cleanup:
<span class="keyword">delete</span> audio;
<span class="keywordflow">return</span> 0;
}
</pre></div><p>
In this example, the stream was opened for recording with a non-zero <em>inputChannels</em> value. The only other difference between this example and that for playback involves the order of data processing in the loop, where it is necessary to first read a buffer of input data before manipulating it.<h2><a class="anchor" name="duplex">
Duplex Mode</a></h2>
Finally, it is easy to use <a class="el" href="classRtAudio.html">RtAudio</a> for simultaneous audio input/output, or duplex operation. In this example, we use a callback function and simply scale the input data before sending it back to the output.<p>
<div class="fragment"><pre><span class="comment">// duplex.cpp</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include "RtAudio.h"</span>
<span class="comment">// Pass-through function.</span>
<span class="keywordtype">int</span> scale(<span class="keywordtype">char</span> *buffer, <span class="keywordtype">int</span> bufferSize, <span class="keywordtype">void</span> *)
{
<span class="comment">// Note: do nothing here for pass through.</span>
<span class="keywordtype">double</span> *my_buffer = (<span class="keywordtype">double</span> *) buffer;
<span class="comment">// Scale input data for output.</span>
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;bufferSize; i++) {
<span class="comment">// Do for two channels.</span>
*my_buffer++ *= 0.5;
*my_buffer++ *= 0.5;
}
<span class="keywordflow">return</span> 0;
}
<span class="keywordtype">int</span> main()
{
<span class="keywordtype">int</span> channels = 2;
<span class="keywordtype">int</span> sampleRate = 44100;
<span class="keywordtype">int</span> bufferSize = 256; <span class="comment">// 256 sample frames</span>
<span class="keywordtype">int</span> nBuffers = 4; <span class="comment">// number of internal buffers used by device</span>
<span class="keywordtype">int</span> device = 0; <span class="comment">// 0 indicates the default or first available device</span>
<span class="keywordtype">char</span> input;
<a class="code" href="classRtAudio.html">RtAudio</a> *audio;
<span class="comment">// Open a stream during RtAudio instantiation</span>
<span class="keywordflow">try</span> {
audio = <span class="keyword">new</span> <a class="code" href="classRtAudio.html">RtAudio</a>(device, channels, device, channels, RTAUDIO_FLOAT64,
sampleRate, &amp;bufferSize, nBuffers);
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
exit(EXIT_FAILURE);
}
<span class="keywordflow">try</span> {
<span class="comment">// Set the stream callback function</span>
audio-&gt;<a class="code" href="classRtAudio.html#a4">setStreamCallback</a>(&amp;scale, NULL);
<span class="comment">// Start the stream</span>
audio-&gt;<a class="code" href="classRtAudio.html#a11">startStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
<span class="keywordflow">goto</span> cleanup;
}
std::cout &lt;&lt; <span class="stringliteral">"\nRunning duplex ... press &lt;enter&gt; to quit.\n"</span>;
std::cin.get(input);
<span class="keywordflow">try</span> {
<span class="comment">// Stop and close the stream</span>
audio-&gt;<a class="code" href="classRtAudio.html#a12">stopStream</a>();
audio-&gt;<a class="code" href="classRtAudio.html#a10">closeStream</a>();
}
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
error.printMessage();
}
cleanup:
<span class="keyword">delete</span> audio;
<span class="keywordflow">return</span> 0;
}
</pre></div><p>
When an <a class="el" href="classRtAudio.html">RtAudio</a> stream is running in duplex mode (nonzero input <em>AND</em> output channels), the audio write (playback) operation always occurs before the audio read (record) operation. This sequence allows the use of a single buffer to store both output and input data.<p>
As we see with this example, the write-read sequence of operations does not preclude the use of <a class="el" href="classRtAudio.html">RtAudio</a> in situations where input data is first processed and then output through a duplex stream. When the stream buffer is first allocated, it is initialized with zeros, which produces no audible result when output to the device. In this example, anything recorded by the audio stream input will be scaled and played out during the next round of audio processing.<p>
Note that duplex operation can also be achieved by opening one output stream instance and one input stream instance using the same or different devices. However, there may be timing problems when attempting to use two different devices, due to possible device clock variations, unless a common external "sync" is provided. This becomes even more difficult to achieve using two separate callback streams because it is not possible to <em>explicitly</em> control the calling order of the callback functions.<h2><a class="anchor" name="multi">
Using Simultaneous Multiple APIs</a></h2>
Because support for each audio API is encapsulated in a specific RtApi subclass, it is possible to compile and instantiate multiple API-specific subclasses on a given operating system. For example, one can compile both the RtApiDs and RtApiAsio classes on Windows operating systems by providing the appropriate preprocessor definitions, include files, and libraries for each. In a run-time situation, one might first attempt to determine whether any ASIO device drivers exist. This can be done by specifying the api argument <a class="el" href="classRtAudio.html#w8w6">RtAudio::WINDOWS_ASIO</a> when attempting to create an instance of <a class="el" href="classRtAudio.html">RtAudio</a>. If an <a class="el" href="classRtError.html">RtError</a> is thrown (indicating no available drivers), then an instance of <a class="el" href="classRtAudio.html">RtAudio</a> with the api argument <a class="el" href="classRtAudio.html#w8w7">RtAudio::WINDOWS_DS</a> can be created. Alternately, if no api argument is specified, <a class="el" href="classRtAudio.html">RtAudio</a> will first look for ASIO drivers and then DirectSound drivers (on Linux systems, the default API search order is Jack, Alsa, and finally OSS). In theory, it should also be possible to have separate instances of <a class="el" href="classRtAudio.html">RtAudio</a> open at the same time with different underlying audio API support, though this has not been tested. It is difficult to know how well different audio APIs can simultaneously coexist on a given operating system. In particular, it is most unlikely that the same device could be simultaneously controlled with two different audio APIs.<h2><a class="anchor" name="methods">
Summary of Methods</a></h2>
The following is a short summary of public methods (not including constructors and the destructor) provided by <a class="el" href="classRtAudio.html">RtAudio</a>:<p>
<ul>
<li>
<a class="el" href="classRtAudio.html#a3">RtAudio::openStream()</a>: opens a stream with the specified parameters. </li>
<li>
<a class="el" href="classRtAudio.html#a4">RtAudio::setStreamCallback()</a>: sets a user-defined callback function for the stream. </li>
<li>
<a class="el" href="classRtAudio.html#a5">RtAudio::cancelStreamCallback()</a>: cancels a callback process and function for the stream. </li>
<li>
<a class="el" href="classRtAudio.html#a6">RtAudio::getDeviceCount()</a>: returns the number of audio devices available. </li>
<li>
<a class="el" href="classRtAudio.html#a7">RtAudio::getDeviceInfo()</a>: returns an <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> structure for a specified device. </li>
<li>
<a class="el" href="classRtAudio.html#a8">RtAudio::getStreamBuffer()</a>: returns a pointer to the stream buffer. </li>
<li>
<a class="el" href="classRtAudio.html#a9">RtAudio::tickStream()</a>: triggers processing of input/output data for the stream (blocking). </li>
<li>
<a class="el" href="classRtAudio.html#a10">RtAudio::closeStream()</a>: closes the stream (implicitly called during object destruction). </li>
<li>
<a class="el" href="classRtAudio.html#a11">RtAudio::startStream()</a>: (re)starts the stream, typically after it has been stopped with either stopStream() or abortStream() or after first opening the stream. </li>
<li>
<a class="el" href="classRtAudio.html#a12">RtAudio::stopStream()</a>: stops the stream, allowing any remaining samples in the queue to be played out and/or read in. This does not implicitly call <a class="el" href="classRtAudio.html#a10">RtAudio::closeStream()</a>. </li>
<li>
<a class="el" href="classRtAudio.html#a13">RtAudio::abortStream()</a>: stops the stream, discarding any remaining samples in the queue. This does not implicitly call closeStream(). </li>
</ul>
<h2><a class="anchor" name="compiling">
Compiling</a></h2>
In order to compile <a class="el" href="classRtAudio.html">RtAudio</a> for a specific OS and audio API, it is necessary to supply the appropriate preprocessor definition and library within the compiler statement: <p>
<table border="2" cols="5" width="100%" cellspacing="3" cellpadding="3">
<tr bgcolor="beige">
<td width="5%"><b>OS:</b> </td><td width="5%"><b>Audio API:</b> </td><td width="5%"><b>C++ Class:</b> </td><td width="5%"><b>Preprocessor Definition:</b> </td><td width="5%"><b>Library or Framework:</b> </td><td><b>Example Compiler Statement:</b> </td></tr>
<tr>
<td>Linux </td><td>ALSA </td><td>RtApiAlsa </td><td>__LINUX_ALSA__ </td><td><code>asound, pthread</code> </td><td><code>g++ -Wall -D__LINUX_ALSA__ -o probe probe.cpp RtAudio.cpp -lasound -lpthread</code> </td></tr>
<tr>
<td>Linux </td><td>Jack Audio Server </td><td>RtApiJack </td><td>__LINUX_JACK__ </td><td><code>jack, pthread</code> </td><td><code>g++ -Wall -D__LINUX_JACK__ -o probe probe.cpp RtAudio.cpp `pkg-config --cflags --libs jack` -lpthread</code> </td></tr>
<tr>
<td>Linux </td><td>OSS </td><td>RtApiOss </td><td>__LINUX_OSS__ </td><td><code>pthread</code> </td><td><code>g++ -Wall -D__LINUX_OSS__ -o probe probe.cpp RtAudio.cpp -lpthread</code> </td></tr>
<tr>
<td>Macintosh OS X </td><td>CoreAudio </td><td>RtApiCore </td><td>__MACOSX_CORE__ </td><td><code>pthread, stdc++, CoreAudio</code> </td><td><code>g++ -Wall -D__MACOSX_CORE__ -o probe probe.cpp RtAudio.cpp -framework CoreAudio -lpthread</code> </td></tr>
<tr>
<td>Irix </td><td>AL </td><td>RtApiAl </td><td>__IRIX_AL__ </td><td><code>audio, pthread</code> </td><td><code>CC -Wall -D__IRIX_AL__ -o probe probe.cpp RtAudio.cpp -laudio -lpthread</code> </td></tr>
<tr>
<td>Windows </td><td>Direct Sound </td><td>RtApiDs </td><td>__WINDOWS_DS__ </td><td><code>dsound.lib (ver. 5.0 or higher), multithreaded</code> </td><td><em>compiler specific</em> </td></tr>
<tr>
<td>Windows </td><td>ASIO </td><td>RtApiAsio </td><td>__WINDOWS_ASIO__ </td><td><em>various ASIO header and source files</em> </td><td><em>compiler specific</em> </td></tr>
</table>
<p>
The example compiler statements above could be used to compile the <code>probe.cpp</code> example file, assuming that <code>probe.cpp</code>, <code><a class="el" href="RtAudio_8h.html">RtAudio.h</a></code>, <code><a class="el" href="RtError_8h.html">RtError.h</a></code>, and <code>RtAudio.cpp</code> all exist in the same directory.<h2><a class="anchor" name="debug">
Debugging</a></h2>
If you are having problems getting <a class="el" href="classRtAudio.html">RtAudio</a> to run on your system, try passing the preprocessor definition <code>__RTAUDIO_DEBUG__</code> to the compiler (or uncomment the definition at the bottom of <a class="el" href="RtAudio_8h.html">RtAudio.h</a>). A variety of warning messages will be displayed which may help in determining the problem. Also try using the programs included in the <code>test</code> directory. The program <code>info</code> displays the queried capabilities of all hardware devices found.<h2><a class="anchor" name="apinotes">
API Notes</a></h2>
<a class="el" href="classRtAudio.html">RtAudio</a> is designed to provide a common API across the various supported operating systems and audio libraries. Despite that, some issues should be mentioned with regard to each.<h3><a class="anchor" name="linux">
Linux:</a></h3>
<a class="el" href="classRtAudio.html">RtAudio</a> for Linux was developed under Redhat distributions 7.0 - Fedora. Three different audio APIs are supported on Linux platforms: OSS, <a href="http://www.alsa-project.org/">ALSA</a>, and <a href="http://jackit.sourceforge.net/">Jack</a>. The OSS API has existed for at least 6 years and the Linux kernel is distributed with free versions of OSS audio drivers. Therefore, a generic Linux system is most likely to have OSS support (though the availability and quality of OSS drivers for new hardware is decreasing). The ALSA API, although relatively new, is now part of the Linux development kernel and offers significantly better functionality than the OSS API. <a class="el" href="classRtAudio.html">RtAudio</a> provides support for the 1.0 and higher versions of ALSA. Jack, which is still in development, is a low-latency audio server, written primarily for the GNU/Linux operating system. It can connect a number of different applications to an audio device, as well as allow them to share audio between themselves. Input/output latency on the order of 15 milliseconds can typically be achieved using any of the Linux APIs by fine-tuning the <a class="el" href="classRtAudio.html">RtAudio</a> buffer parameters (without kernel modifications). Latencies on the order of 5 milliseconds or less can be achieved using a low-latency kernel patch and increasing FIFO scheduling priority. The pthread library, which is used for callback functionality, is a standard component of all Linux distributions.<p>
The ALSA library includes OSS emulation support. That means that you can run programs compiled for the OSS API even when using the ALSA drivers and library. It should be noted however that OSS emulation under ALSA is not perfect. Specifically, channel number queries seem to consistently produce invalid results. While OSS emulation is successful for the majority of <a class="el" href="classRtAudio.html">RtAudio</a> tests, it is recommended that the native ALSA implementation of <a class="el" href="classRtAudio.html">RtAudio</a> be used on systems which have ALSA drivers installed.<p>
The ALSA implementation of <a class="el" href="classRtAudio.html">RtAudio</a> makes no use of the ALSA "plug" interface. All necessary data format conversions, channel compensation, de-interleaving, and byte-swapping is handled by internal <a class="el" href="classRtAudio.html">RtAudio</a> routines.<p>
The Jack API is based on a callback scheme. <a class="el" href="classRtAudio.html">RtAudio</a> provides blocking functionality, in addition to callback functionality, within the context of that behavior. It should be noted, however, that the best performance is achieved when using RtAudio's callback functionality with the Jack API. At the moment, only one <a class="el" href="classRtAudio.html">RtAudio</a> instance can be connected to the Jack server. Because <a class="el" href="classRtAudio.html">RtAudio</a> does not provide a mechanism for allowing the user to specify particular channels (or ports) of a device, it simply opens the first <em>N</em> enumerated Jack ports for input/output.<h3><a class="anchor" name="macosx">
Macintosh OS X (CoreAudio):</a></h3>
The Apple CoreAudio API is based on a callback scheme. <a class="el" href="classRtAudio.html">RtAudio</a> provides blocking functionality, in addition to callback functionality, within the context of that behavior. CoreAudio is designed to use a separate callback procedure for each of its audio devices. A single <a class="el" href="classRtAudio.html">RtAudio</a> duplex stream using two different devices is supported, though it cannot be guaranteed to always behave correctly because we cannot synchronize these two callbacks. This same functionality might be achieved with better synchrony by creating separate instances of <a class="el" href="classRtAudio.html">RtAudio</a> for each device and making use of <a class="el" href="classRtAudio.html">RtAudio</a> blocking calls (i.e. <a class="el" href="classRtAudio.html#a9">RtAudio::tickStream()</a>). The <em>numberOfBuffers</em> parameter to the <a class="el" href="classRtAudio.html#a3">RtAudio::openStream()</a> function has no affect in this implementation.<p>
It is not possible to have multiple instances of <a class="el" href="classRtAudio.html">RtAudio</a> accessing the same CoreAudio device.<h3><a class="anchor" name="irix">
Irix (SGI):</a></h3>
The Irix version of <a class="el" href="classRtAudio.html">RtAudio</a> was written and tested on an SGI Indy running Irix version 6.5.4 and the newer "al" audio library. <a class="el" href="classRtAudio.html">RtAudio</a> does not compile under Irix version 6.3, mainly because the C++ compiler is too old. Despite the relatively slow speed of the Indy, <a class="el" href="classRtAudio.html">RtAudio</a> was found to behave quite well and input/output latency was very good. No problems were found with respect to using the pthread library.<h3><a class="anchor" name="windowsds">
Windows (DirectSound):</a></h3>
In order to compile <a class="el" href="classRtAudio.html">RtAudio</a> under Windows for the DirectSound API, you must have the header and source files for DirectSound version 5.0 or higher. As far as I know, there is no DirectSoundCapture support for Windows NT. Audio output latency with DirectSound can be reasonably good (on the order of 20 milliseconds). On the other hand, input audio latency tends to be terrible (100 milliseconds or more). Further, DirectSound drivers tend to crash easily when experimenting with buffer parameters. On my system, I found it necessary to use values around nBuffers = 8 and bufferSize = 512 to avoid crashes. <a class="el" href="classRtAudio.html">RtAudio</a> was originally developed with Visual C++ version 6.0.<h3><a class="anchor" name="windowsasio">
Windows (ASIO):</a></h3>
The Steinberg ASIO audio API is based on a callback scheme. In addition, the API allows only a single device driver to be loaded and accessed at a time. ASIO device drivers must be supplied by audio hardware manufacturers, though ASIO emulation is possible on top of systems with DirectSound drivers. The <em>numberOfBuffers</em> parameter to the <a class="el" href="classRtAudio.html#a3">RtAudio::openStream()</a> function has no affect in this implementation.<p>
A number of ASIO source and header files are required for use with <a class="el" href="classRtAudio.html">RtAudio</a>. Specifically, an <a class="el" href="classRtAudio.html">RtAudio</a> project must include the following files: <code>asio.h,cpp; asiodrivers.h,cpp; asiolist.h,cpp; asiodrvr.h; asiosys.h; ginclude.h; iasiodrv.h</code>. The Visual C++ projects found in <code>/tests/Windows/</code> compile both ASIO and DirectSound support.<h2><a class="anchor" name="acknowledge">
Acknowledgements</a></h2>
The <a class="el" href="classRtAudio.html">RtAudio</a> API incorporates many of the concepts developed in the <a href="http://www.portaudio.com/">PortAudio</a> project by Phil Burk and Ross Bencina. Early development also incorporated ideas from Bill Schottstaedt's <a href="http://www-ccrma.stanford.edu/software/snd/sndlib/">sndlib</a>. The CCRMA <a href="http://www-ccrma.stanford.edu/groups/soundwire/">SoundWire group</a> provided valuable feedback during the API proposal stages.<p>
The early 2.0 version of <a class="el" href="classRtAudio.html">RtAudio</a> was slowly developed over the course of many months while in residence at the <a href="http://www.iua.upf.es/">Institut Universitari de L'Audiovisual (IUA)</a> in Barcelona, Spain and the <a href="http://www.acoustics.hut.fi/">Laboratory of Acoustics and Audio Signal Processing</a> at the Helsinki University of Technology, Finland. Much subsequent development happened while working at the <a href="http://www-ccrma.stanford.edu/">Center for Computer Research in Music and Acoustics (CCRMA)</a> at <a href="http://www.stanford.edu/">Stanford University</a>. The most recent version of <a class="el" href="classRtAudio.html">RtAudio</a> was finished while working as an assistant professor of <a href="http://www.music.mcgill.ca/musictech/">Music Technology</a> at <a href="http://www.mcgill.ca/">McGill University</a>. This work was supported in part by the United States Air Force Office of Scientific Research (grant #F49620-99-1-0293).<h2><a class="anchor" name="license">
License</a></h2>
<a class="el" href="classRtAudio.html">RtAudio</a>: a realtime audio i/o C++ classes<br>
Copyright (c) 2001-2004 Gary P. Scavone<p>
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:<p>
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.<p>
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.<p>
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. <HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,28 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtAudioDeviceInfo Member List</h1>This is the complete list of members for <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a>, including all inherited members.<table>
<tr class="memlist"><td><a class="el" href="structRtAudioDeviceInfo.html#o4">duplexChannels</a></td><td><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="structRtAudioDeviceInfo.html#o3">inputChannels</a></td><td><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="structRtAudioDeviceInfo.html#o5">isDefault</a></td><td><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="structRtAudioDeviceInfo.html#o0">name</a></td><td><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="structRtAudioDeviceInfo.html#o7">nativeFormats</a></td><td><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="structRtAudioDeviceInfo.html#o2">outputChannels</a></td><td><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="structRtAudioDeviceInfo.html#o1">probed</a></td><td><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td></td></tr>
<tr class="memlist"><td><a class="el" href="structRtAudioDeviceInfo.html#o6">sampleRates</a></td><td><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a></td><td></td></tr>
</table><HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

View File

@@ -0,0 +1,226 @@
<HTML>
<HEAD>
<TITLE>The RtAudio Tutorial</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<h1>RtAudioDeviceInfo Struct Reference</h1>The public device information structure for returning queried values.
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="RtAudio_8h-source.html">RtAudio.h</a>&gt;</code>
<p>
<a href="structRtAudioDeviceInfo-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>std::string&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structRtAudioDeviceInfo.html#o0">name</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structRtAudioDeviceInfo.html#o1">probed</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structRtAudioDeviceInfo.html#o2">outputChannels</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structRtAudioDeviceInfo.html#o3">inputChannels</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structRtAudioDeviceInfo.html#o4">duplexChannels</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structRtAudioDeviceInfo.html#o5">isDefault</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector&lt; int &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structRtAudioDeviceInfo.html#o6">sampleRates</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>RtAudioFormat&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="structRtAudioDeviceInfo.html#o7">nativeFormats</a></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The public device information structure for returning queried values.
<p>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="o0" doxytag="RtAudioDeviceInfo::name" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> std::string <a class="el" href="structRtAudioDeviceInfo.html#o0">RtAudioDeviceInfo::name</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Character string device identifier. </td>
</tr>
</table>
<a class="anchor" name="o1" doxytag="RtAudioDeviceInfo::probed" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> bool <a class="el" href="structRtAudioDeviceInfo.html#o1">RtAudioDeviceInfo::probed</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
true if the device capabilities were successfully probed. </td>
</tr>
</table>
<a class="anchor" name="o2" doxytag="RtAudioDeviceInfo::outputChannels" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int <a class="el" href="structRtAudioDeviceInfo.html#o2">RtAudioDeviceInfo::outputChannels</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Maximum output channels supported by device. </td>
</tr>
</table>
<a class="anchor" name="o3" doxytag="RtAudioDeviceInfo::inputChannels" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int <a class="el" href="structRtAudioDeviceInfo.html#o3">RtAudioDeviceInfo::inputChannels</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Maximum input channels supported by device. </td>
</tr>
</table>
<a class="anchor" name="o4" doxytag="RtAudioDeviceInfo::duplexChannels" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int <a class="el" href="structRtAudioDeviceInfo.html#o4">RtAudioDeviceInfo::duplexChannels</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Maximum simultaneous input/output channels supported by device. </td>
</tr>
</table>
<a class="anchor" name="o5" doxytag="RtAudioDeviceInfo::isDefault" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> bool <a class="el" href="structRtAudioDeviceInfo.html#o5">RtAudioDeviceInfo::isDefault</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
true if this is the default output or input device. </td>
</tr>
</table>
<a class="anchor" name="o6" doxytag="RtAudioDeviceInfo::sampleRates" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> std::vector&lt;int&gt; <a class="el" href="structRtAudioDeviceInfo.html#o6">RtAudioDeviceInfo::sampleRates</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Supported sample rates (queried from list of standard rates). </td>
</tr>
</table>
<a class="anchor" name="o7" doxytag="RtAudioDeviceInfo::nativeFormats" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> RtAudioFormat <a class="el" href="structRtAudioDeviceInfo.html#o7">RtAudioDeviceInfo::nativeFormats</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Bit mask of supported data formats. </td>
</tr>
</table>
<hr>The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="RtAudio_8h-source.html">RtAudio.h</a></ul>
<HR>
<table><tr><td><img src="../images/mcgill.gif" width=165></td>
<td>&copy;2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
</table>
</BODY>
</HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -0,0 +1,35 @@
RtAudio - a set of C++ classes which provide a common API for realtime audio input/output across Linux (native ALSA, JACK, and OSS), SGI, Macintosh OS X (CoreAudio), and Windows (DirectSound and ASIO) operating systems.
By Gary P. Scavone, 2001-2004.
v3.0.1: (22 March 2004)
- bug fix in Windows DirectSound support for cards with output only
v3.0: (11 March 2004)
- added Linux Jack audio server support
- new multi-api support by subclassing all apis and making rtaudio a controller class
- added over/underload check to Mac OS X support
- new scheme for blocking functionality in callback-based apis (CoreAudio, ASIO, and JACK)
- removed multiple stream support (all stream indentifier arguments removed)
- various style and name changes to conform with standard C++ practice
v2.1.1: (24 October 2002)
- bug fix in duplex for Mac OS X and Windows ASIO code
- duplex example change in tutorial
v2.1: (7 October 2002)
- added Mac OS X CoreAudio support
- added Windows ASIO support
- API change to getDeviceInfo(): device argument must be an integer between 1 - getDeviceCount().
- "configure" support added for unix systems
- adopted MIT-like license
- various internal structural changes and bug fixes
v2.01: (27 April 2002)
- Windows destructor bug fix when no devices available
- RtAudioError class renamed to RtError
- Preprocessor definitions changed slightly (i.e. __LINUX_OSS_ to __LINUX_OSS__) to conform with new Synthesis ToolKit distribution
v2.0: (22 January 2002)
- first release of new independent class