Browse Source

Merge 2.0.1 into releases

tags/2.0.1
Stephen Sinclair 11 years ago
parent
commit
a1bbe4d94d
29 changed files with 5614 additions and 5601 deletions
  1. +40
    -12
      README
  2. +5001
    -4997
      RtAudio.cpp
  3. +434
    -430
      RtAudio.h
  4. +13
    -0
      doc/Release.txt
  5. +6
    -6
      doc/doxygen/Doxyfile
  6. +1
    -1
      doc/doxygen/footer.html
  7. +0
    -0
      doc/doxygen/header.html
  8. +50
    -48
      doc/doxygen/tutorial.txt
  9. +0
    -0
      doc/images/ccrma.gif
  10. BIN
      doc/manual.pdf
  11. +3
    -3
      tests/Makefile
  12. +3
    -6
      tests/call_inout.cpp
  13. +5
    -5
      tests/call_inout.dsp
  14. +3
    -6
      tests/call_saw.cpp
  15. +5
    -5
      tests/call_saw.dsp
  16. +6
    -12
      tests/call_twostreams.cpp
  17. +5
    -5
      tests/call_twostreams.dsp
  18. +4
    -8
      tests/in_out.cpp
  19. +2
    -2
      tests/in_out.dsp
  20. +2
    -2
      tests/info.cpp
  21. +2
    -2
      tests/info.dsp
  22. +4
    -8
      tests/play_raw.cpp
  23. +2
    -2
      tests/play_raw.dsp
  24. +4
    -8
      tests/play_saw.cpp
  25. +2
    -2
      tests/play_saw.dsp
  26. +4
    -9
      tests/record_raw.cpp
  27. +2
    -2
      tests/record_raw.dsp
  28. +9
    -18
      tests/twostreams.cpp
  29. +2
    -2
      tests/twostreams.dsp

+ 40
- 12
README View File

@@ -1,12 +1,40 @@

This is the parent directory of the RtAudio distribution. Here is a quick description of what is contained here:

RtAudio.h - class header
RtAudio.cpp - class source
rtaudio.dsw - Visual C++ 6.0 workspace file

Directories:

tests - various test programs and Visual C++ 6.0 project files
doc - complete documentation in a variety of formats (see doc/html/index.html)

RtAudio - a C++ class which provides a common API for realtime audio input/output across Linux (native ALSA and OSS), SGI, and Windows operating systems.
By Gary P. Scavone, 2002.
This distribution of the Synthesis ToolKit in C++ (STK) contains the following:
doc: RtAudio documentation
tests: example RtAudio programs
OVERVIEW:
RtAudio is a C++ class which provides a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA and OSS), SGI, and Windows operating systems. RtAudio significantly simplifies the process of interacting with computer audio hardware. It was designed with the following goals:
- object oriented C++ design
- simple, common API across all supported platforms
- single independent header and source file for easy inclusion in programming projects (no libraries!)
- blocking functionality
- callback functionality
- extensive audio device parameter control
- audio device capability probing
- automatic internal conversion for data format, channel number compensation, de-interleaving, and byte-swapping
- control over multiple audio streams and devices with a single instance
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. Multiple streams can run at the same time and, when allowed by the underlying audio API, a single device can serve multiple streams.
The RtAudio API provides both blocking (synchronous) and callback (asyncronous) 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.
LEGAL AND ETHICAL:
This software was designed and created to be made publicly available for free, primarily for academic purposes, so if you use it, pass it on with this documentation, and for free.
If you make a million dollars with it, give me some. If you make compositions with it, put me in the program notes.
FURTHER READING:
For complete documentation on RtAudio, see the doc directory of the distribution or surf to http://www-ccrma.stanford.edu/~gary/rtaudio/.

+ 5001
- 4997
RtAudio.cpp
File diff suppressed because it is too large
View File


+ 434
- 430
RtAudio.h View File

@@ -1,430 +1,434 @@
/******************************************/
/*
RtAudio - realtime sound I/O C++ class
Version 2.0 by Gary P. Scavone, 2001-2002.
*/
/******************************************/

#if !defined(__RtAudio_h)
#define __RtAudio_h

#include <map>

#if defined(__LINUX_ALSA_)
#include <alsa/asoundlib.h>
#include <pthread.h>
#include <unistd.h>

typedef snd_pcm_t *AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;

#elif defined(__LINUX_OSS_)
#include <pthread.h>
#include <unistd.h>

typedef int AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;

#elif defined(__WINDOWS_DS_)
#include <windows.h>
#include <process.h>

// The following struct is used to hold the extra variables
// specific to the DirectSound implementation.
typedef struct {
void * object;
void * buffer;
UINT bufferPointer;
} AUDIO_HANDLE;

typedef LPGUID DEVICE_ID;
typedef unsigned long THREAD_HANDLE;
typedef CRITICAL_SECTION MUTEX;

#elif defined(__IRIX_AL_)
#include <dmedia/audio.h>
#include <pthread.h>
#include <unistd.h>

typedef ALport AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;

#endif


// *************************************************** //
//
// RtAudioError class declaration.
//
// *************************************************** //

class RtAudioError
{
public:
enum TYPE {
WARNING,
DEBUG_WARNING,
UNSPECIFIED,
NO_DEVICES_FOUND,
INVALID_DEVICE,
INVALID_STREAM,
MEMORY_ERROR,
INVALID_PARAMETER,
DRIVER_ERROR,
SYSTEM_ERROR,
THREAD_ERROR
};

protected:
char error_message[256];
TYPE type;

public:
//! The constructor.
RtAudioError(const char *p, TYPE tipe = RtAudioError::UNSPECIFIED);

//! The destructor.
virtual ~RtAudioError(void);

//! Prints "thrown" error message to stdout.
virtual void printMessage(void);

//! Returns the "thrown" error message TYPE.
virtual const TYPE& getType(void) { return type; }

//! Returns the "thrown" error message string.
virtual const char *getMessage(void) { return error_message; }
};


// *************************************************** //
//
// RtAudio class declaration.
//
// *************************************************** //

class RtAudio
{
public:

// Support for signed integers and floats. Audio data fed to/from
// the tickStream() routine is assumed to ALWAYS be in host
// byte order. The internal routines will automatically take care of
// any necessary byte-swapping between the host format and the
// soundcard. Thus, endian-ness is not a concern in the following
// format definitions.
typedef unsigned long RTAUDIO_FORMAT;
static const RTAUDIO_FORMAT RTAUDIO_SINT8;
static const RTAUDIO_FORMAT RTAUDIO_SINT16;
static const RTAUDIO_FORMAT RTAUDIO_SINT24; /*!< Upper 3 bytes of 32-bit integer. */
static const RTAUDIO_FORMAT RTAUDIO_SINT32;
static const RTAUDIO_FORMAT RTAUDIO_FLOAT32; /*!< Normalized between plus/minus 1.0. */
static const RTAUDIO_FORMAT RTAUDIO_FLOAT64; /*!< Normalized between plus/minus 1.0. */

//static const int MAX_SAMPLE_RATES = 14;
enum { MAX_SAMPLE_RATES = 14 };

typedef int (*RTAUDIO_CALLBACK)(char *buffer, int bufferSize, void *userData);

typedef struct {
char name[128];
DEVICE_ID id[2]; /*!< No value reported by getDeviceInfo(). */
bool probed; /*!< true if the device capabilities were successfully probed. */
int maxOutputChannels;
int maxInputChannels;
int maxDuplexChannels;
int minOutputChannels;
int minInputChannels;
int minDuplexChannels;
bool hasDuplexSupport; /*!< true if device supports duplex mode. */
int nSampleRates; /*!< Number of discrete rates or -1 if range supported. */
int sampleRates[MAX_SAMPLE_RATES]; /*!< Supported rates or (min, max) if range. */
RTAUDIO_FORMAT nativeFormats; /*!< Bit mask of supported data formats. */
} RTAUDIO_DEVICE;

//! The default constructor.
/*!
Probes the system to make sure at least one audio
input/output device is available and determines
the api-specific identifier for each device found.
An RtAudioError error can be thrown if no devices are
found or if a memory allocation error occurs.
*/
RtAudio();

//! A constructor which can be used to open a stream during instantiation.
/*!
The specified output and/or input device identifiers correspond
to those enumerated via the getDeviceInfo() method. If device =
0, the default or first available devices meeting the given
parameters is selected. If an output or input channel value is
zero, the corresponding device value is ignored. When a stream is
successfully opened, its identifier is returned via the "streamID"
pointer. An RtAudioError can be thrown if no devices are found
for the given parameters, if a memory allocation error occurs, or
if a driver error occurs. \sa openStream()
*/
RtAudio(int *streamID,
int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RTAUDIO_FORMAT format, int sampleRate,
int *bufferSize, int numberOfBuffers);

//! The destructor.
/*!
Stops and closes any open streams and devices and deallocates
buffer and structure memory.
*/
~RtAudio();

//! A public method for opening a stream with the specified parameters.
/*!
If successful, the opened stream ID is returned. Otherwise, an
RtAudioError is thrown.

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

//! A public method which sets a user-defined callback function for a given stream.
/*!
This method assigns a callback function to a specific,
previously opened stream for non-blocking stream functionality. A
separate process is initiated, though the user function is called
only when the stream is "running" (between calls to the
startStream() and stopStream() methods, respectively). The
callback process remains active for the duration of the stream and
is automatically shutdown when the stream is closed (via the
closeStream() method or by object destruction). The callback
process can also be shutdown and the user function de-referenced
through an explicit call to the cancelStreamCallback() method.
Note that a single stream can use only blocking or callback
functionality at the same time, though it is possible to alternate
modes on the same stream through the use of the
setStreamCallback() and cancelStreamCallback() methods (the
blocking tickStream() method can be used before a callback is set
and/or after a callback is cancelled). An RtAudioError will be
thrown for an invalid device argument.
*/
void setStreamCallback(int streamID, RTAUDIO_CALLBACK callback, void *userData);

//! A public method which cancels a callback process and function for a given stream.
/*!
This method shuts down a callback process and de-references the
user function for a specific stream. Callback functionality can
subsequently be restarted on the stream via the
setStreamCallback() method. An RtAudioError will be thrown for an
invalid device argument.
*/
void cancelStreamCallback(int streamID);

//! A public method which returns the number of audio devices found.
int getDeviceCount(void);

//! Fill a user-supplied RTAUDIO_DEVICE structure for a specified device.
/*!
Any device between 0 and getDeviceCount()-1 is valid. If a
device is busy or otherwise unavailable, the structure member
"probed" has a value of "false". The system default input and
output devices are referenced by device identifier = 0. On
systems which allow dynamic default device settings, the default
devices are not identified by name (specific device enumerations
are assigned device identifiers > 0). An RtAudioError will be
thrown for an invalid device argument.
*/
void getDeviceInfo(int device, RTAUDIO_DEVICE *info);

//! A public method which returns a pointer to the buffer for an open stream.
/*!
The user should fill and/or read the buffer data in interleaved format
and then call the tickStream() method. An RtAudioError will be
thrown for an invalid stream identifier.
*/
char * const getStreamBuffer(int streamID);

//! Public method used to trigger processing of input/output data for a stream.
/*!
This method blocks until all buffer data is read/written. An
RtAudioError will be thrown for an invalid stream identifier or if
a driver error occurs.
*/
void tickStream(int streamID);

//! Public method which closes a stream and frees any associated buffers.
/*!
If an invalid stream identifier is specified, this method
issues a warning and returns (an RtAudioError is not thrown).
*/
void closeStream(int streamID);

//! Public method which starts a stream.
/*!
An RtAudioError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void startStream(int streamID);

//! Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.
/*!
An RtAudioError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void stopStream(int streamID);

//! Stop a stream, discarding any samples remaining in the input/output queue.
/*!
An RtAudioError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void abortStream(int streamID);

//! Queries a stream to determine whether a call to the tickStream() method will block.
/*!
A return value of 0 indicates that the stream will NOT block. A positive
return value indicates the number of sample frames that cannot yet be
processed without blocking.
*/
int streamWillBlock(int streamID);

protected:

private:

static const unsigned int SAMPLE_RATES[MAX_SAMPLE_RATES];

enum { FAILURE, SUCCESS };

enum STREAM_MODE {
PLAYBACK,
RECORD,
DUPLEX,
UNINITIALIZED = -75
};

enum STREAM_STATE {
STREAM_STOPPED,
STREAM_RUNNING
};

typedef struct {
int device[2]; // Playback and record, respectively.
STREAM_MODE mode; // PLAYBACK, RECORD, or DUPLEX.
AUDIO_HANDLE handle[2]; // Playback and record handles, respectively.
STREAM_STATE state; // STOPPED or RUNNING
char *userBuffer;
char *deviceBuffer;
bool doConvertBuffer[2]; // Playback and record, respectively.
bool deInterleave[2]; // Playback and record, respectively.
bool doByteSwap[2]; // Playback and record, respectively.
int sampleRate;
int bufferSize;
int nBuffers;
int nUserChannels[2]; // Playback and record, respectively.
int nDeviceChannels[2]; // Playback and record channels, respectively.
RTAUDIO_FORMAT userFormat;
RTAUDIO_FORMAT deviceFormat[2]; // Playback and record, respectively.
bool usingCallback;
THREAD_HANDLE thread;
MUTEX mutex;
RTAUDIO_CALLBACK callback;
void *userData;
} RTAUDIO_STREAM;

typedef signed short INT16;
typedef signed int INT32;
typedef float FLOAT32;
typedef double FLOAT64;

char message[256];
int nDevices;
RTAUDIO_DEVICE *devices;

std::map<int, void *> streams;

//! Private error method to allow global control over error handling.
void error(RtAudioError::TYPE type);

/*!
Private method to count the system audio devices, allocate the
RTAUDIO_DEVICE structures, and probe the device capabilities.
*/
void initialize(void);

//! Private method to clear an RTAUDIO_DEVICE structure.
void clearDeviceInfo(RTAUDIO_DEVICE *info);

/*!
Private method which attempts to fill an RTAUDIO_DEVICE
structure for a given device. If an error is encountered during
the probe, a "warning" message is reported and the value of
"probed" remains false (no exception is thrown). A successful
probe is indicated by probed = true.
*/
void probeDeviceInfo(RTAUDIO_DEVICE *info);

/*!
Private method which attempts to open a device with the given parameters.
If an error is encountered during the probe, a "warning" message is
reported and FAILURE is returned (no exception is thrown). A
successful probe is indicated by a return value of SUCCESS.
*/
bool probeDeviceOpen(int device, RTAUDIO_STREAM *stream,
STREAM_MODE mode, int channels,
int sampleRate, RTAUDIO_FORMAT format,
int *bufferSize, int numberOfBuffers);

/*!
Private common method used to check validity of a user-passed
stream ID. When the ID is valid, this method returns a pointer to
an RTAUDIO_STREAM structure (in the form of a void pointer).
Otherwise, an "invalid identifier" exception is thrown.
*/
void *verifyStream(int streamID);

/*!
Private method used to perform format, channel number, and/or interleaving
conversions between the user and device buffers.
*/
void convertStreamBuffer(RTAUDIO_STREAM *stream, STREAM_MODE mode);

//! Private method used to perform byte-swapping on buffers.
void byteSwapBuffer(char *buffer, int samples, RTAUDIO_FORMAT format);

//! Private method which returns the number of bytes for a given format.
int formatBytes(RTAUDIO_FORMAT format);
};

// Uncomment the following definition to have extra information spewed to stderr.
//#define RTAUDIO_DEBUG

#endif
/******************************************/
/*
RtAudio - realtime sound I/O C++ class
by Gary P. Scavone, 2001-2002.
*/
/******************************************/
#if !defined(__RTAUDIO_H)
#define __RTAUDIO_H
#include <map>
#if defined(__LINUX_ALSA__)
#include <alsa/asoundlib.h>
#include <pthread.h>
#include <unistd.h>
#define THREAD_TYPE
typedef snd_pcm_t *AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;
#elif defined(__LINUX_OSS__)
#include <pthread.h>
#include <unistd.h>
#define THREAD_TYPE
typedef int AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;
#elif defined(__WINDOWS_DS__)
#include <windows.h>
#include <process.h>
// The following struct is used to hold the extra variables
// specific to the DirectSound implementation.
typedef struct {
void * object;
void * buffer;
UINT bufferPointer;
} AUDIO_HANDLE;
#define THREAD_TYPE __stdcall
typedef LPGUID DEVICE_ID;
typedef unsigned long THREAD_HANDLE;
typedef CRITICAL_SECTION MUTEX;
#elif defined(__IRIX_AL__)
#include <dmedia/audio.h>
#include <pthread.h>
#include <unistd.h>
#define THREAD_TYPE
typedef ALport AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;
#endif
// *************************************************** //
//
// RtError class declaration.
//
// *************************************************** //
class RtError
{
public:
enum TYPE {
WARNING,
DEBUG_WARNING,
UNSPECIFIED,
NO_DEVICES_FOUND,
INVALID_DEVICE,
INVALID_STREAM,
MEMORY_ERROR,
INVALID_PARAMETER,
DRIVER_ERROR,
SYSTEM_ERROR,
THREAD_ERROR
};
protected:
char error_message[256];
TYPE type;
public:
//! The constructor.
RtError(const char *p, TYPE tipe = RtError::UNSPECIFIED);
//! The destructor.
virtual ~RtError(void);
//! Prints "thrown" error message to stdout.
virtual void printMessage(void);
//! Returns the "thrown" error message TYPE.
virtual const TYPE& getType(void) { return type; }
//! Returns the "thrown" error message string.
virtual const char *getMessage(void) { return error_message; }
};
// *************************************************** //
//
// RtAudio class declaration.
//
// *************************************************** //
class RtAudio
{
public:
// Support for signed integers and floats. Audio data fed to/from
// the tickStream() routine is assumed to ALWAYS be in host
// byte order. The internal routines will automatically take care of
// any necessary byte-swapping between the host format and the
// soundcard. Thus, endian-ness is not a concern in the following
// format definitions.
typedef unsigned long RTAUDIO_FORMAT;
static const RTAUDIO_FORMAT RTAUDIO_SINT8;
static const RTAUDIO_FORMAT RTAUDIO_SINT16;
static const RTAUDIO_FORMAT RTAUDIO_SINT24; /*!< Upper 3 bytes of 32-bit integer. */
static const RTAUDIO_FORMAT RTAUDIO_SINT32;
static const RTAUDIO_FORMAT RTAUDIO_FLOAT32; /*!< Normalized between plus/minus 1.0. */
static const RTAUDIO_FORMAT RTAUDIO_FLOAT64; /*!< Normalized between plus/minus 1.0. */
//static const int MAX_SAMPLE_RATES = 14;
enum { MAX_SAMPLE_RATES = 14 };
typedef int (*RTAUDIO_CALLBACK)(char *buffer, int bufferSize, void *userData);
typedef struct {
char name[128];
DEVICE_ID id[2]; /*!< No value reported by getDeviceInfo(). */
bool probed; /*!< true if the device capabilities were successfully probed. */
int maxOutputChannels;
int maxInputChannels;
int maxDuplexChannels;
int minOutputChannels;
int minInputChannels;
int minDuplexChannels;
bool hasDuplexSupport; /*!< true if device supports duplex mode. */
int nSampleRates; /*!< Number of discrete rates or -1 if range supported. */
int sampleRates[MAX_SAMPLE_RATES]; /*!< Supported rates or (min, max) if range. */
RTAUDIO_FORMAT nativeFormats; /*!< Bit mask of supported data formats. */
} RTAUDIO_DEVICE;
//! The default constructor.
/*!
Probes the system to make sure at least one audio
input/output device is available and determines
the api-specific identifier for each device found.
An RtError error can be thrown if no devices are
found or if a memory allocation error occurs.
*/
RtAudio();
//! A constructor which can be used to open a stream during instantiation.
/*!
The specified output and/or input device identifiers correspond
to those enumerated via the getDeviceInfo() method. If device =
0, the default or first available devices meeting the given
parameters is selected. If an output or input channel value is
zero, the corresponding device value is ignored. When a stream is
successfully opened, its identifier is returned via the "streamId"
pointer. An RtError can be thrown if no devices are found
for the given parameters, if a memory allocation error occurs, or
if a driver error occurs. \sa openStream()
*/
RtAudio(int *streamId,
int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RTAUDIO_FORMAT format, int sampleRate,
int *bufferSize, int numberOfBuffers);
//! The destructor.
/*!
Stops and closes any open streams and devices and deallocates
buffer and structure memory.
*/
~RtAudio();
//! A public method for opening a stream with the specified parameters.
/*!
If successful, the opened stream ID is returned. Otherwise, an
RtError is thrown.
\param outputDevice: If equal to 0, the default or first device
found meeting the given parameters is opened. Otherwise, the
device number should correspond to one of those enumerated via
the getDeviceInfo() method.
\param outputChannels: The desired number of output channels. If
equal to zero, the outputDevice identifier is ignored.
\param inputDevice: If equal to 0, the default or first device
found meeting the given parameters is opened. Otherwise, the
device number should correspond to one of those enumerated via
the getDeviceInfo() method.
\param inputChannels: The desired number of input channels. If
equal to zero, the inputDevice identifier is ignored.
\param format: An RTAUDIO_FORMAT specifying the desired sample data format.
\param sampleRate: The desired sample rate (sample frames per second).
\param *bufferSize: A pointer value indicating the desired internal buffer
size in sample frames. The actual value used by the device is
returned via the same pointer. A value of zero can be specified,
in which case the lowest allowable value is determined.
\param numberOfBuffers: A value which can be used to help control device
latency. More buffers typically result in more robust performance,
though at a cost of greater latency. A value of zero can be
specified, in which case the lowest allowable value is used.
*/
int openStream(int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RTAUDIO_FORMAT format, int sampleRate,
int *bufferSize, int numberOfBuffers);
//! A public method which sets a user-defined callback function for a given stream.
/*!
This method assigns a callback function to a specific,
previously opened stream for non-blocking stream functionality. A
separate process is initiated, though the user function is called
only when the stream is "running" (between calls to the
startStream() and stopStream() methods, respectively). The
callback process remains active for the duration of the stream and
is automatically shutdown when the stream is closed (via the
closeStream() method or by object destruction). The callback
process can also be shutdown and the user function de-referenced
through an explicit call to the cancelStreamCallback() method.
Note that a single stream can use only blocking or callback
functionality at the same time, though it is possible to alternate
modes on the same stream through the use of the
setStreamCallback() and cancelStreamCallback() methods (the
blocking tickStream() method can be used before a callback is set
and/or after a callback is cancelled). An RtError will be
thrown for an invalid device argument.
*/
void setStreamCallback(int streamId, RTAUDIO_CALLBACK callback, void *userData);
//! A public method which cancels a callback process and function for a given stream.
/*!
This method shuts down a callback process and de-references the
user function for a specific stream. Callback functionality can
subsequently be restarted on the stream via the
setStreamCallback() method. An RtError will be thrown for an
invalid device argument.
*/
void cancelStreamCallback(int streamId);
//! A public method which returns the number of audio devices found.
int getDeviceCount(void);
//! Fill a user-supplied RTAUDIO_DEVICE structure for a specified device.
/*!
Any device between 0 and getDeviceCount()-1 is valid. If a
device is busy or otherwise unavailable, the structure member
"probed" has a value of "false". The system default input and
output devices are referenced by device identifier = 0. On
systems which allow dynamic default device settings, the default
devices are not identified by name (specific device enumerations
are assigned device identifiers > 0). An RtError will be
thrown for an invalid device argument.
*/
void getDeviceInfo(int device, RTAUDIO_DEVICE *info);
//! A public method which returns a pointer to the buffer for an open stream.
/*!
The user should fill and/or read the buffer data in interleaved format
and then call the tickStream() method. An RtError will be
thrown for an invalid stream identifier.
*/
char * const getStreamBuffer(int streamId);
//! Public method used to trigger processing of input/output data for a stream.
/*!
This method blocks until all buffer data is read/written. An
RtError will be thrown for an invalid stream identifier or if
a driver error occurs.
*/
void tickStream(int streamId);
//! Public method which closes a stream and frees any associated buffers.
/*!
If an invalid stream identifier is specified, this method
issues a warning and returns (an RtError is not thrown).
*/
void closeStream(int streamId);
//! Public method which starts a stream.
/*!
An RtError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void startStream(int streamId);
//! Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.
/*!
An RtError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void stopStream(int streamId);
//! Stop a stream, discarding any samples remaining in the input/output queue.
/*!
An RtError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void abortStream(int streamId);
//! Queries a stream to determine whether a call to the tickStream() method will block.
/*!
A return value of 0 indicates that the stream will NOT block. A positive
return value indicates the number of sample frames that cannot yet be
processed without blocking.
*/
int streamWillBlock(int streamId);
protected:
private:
static const unsigned int SAMPLE_RATES[MAX_SAMPLE_RATES];
enum { FAILURE, SUCCESS };
enum STREAM_MODE {
PLAYBACK,
RECORD,
DUPLEX,
UNINITIALIZED = -75
};
enum STREAM_STATE {
STREAM_STOPPED,
STREAM_RUNNING
};
typedef struct {
int device[2]; // Playback and record, respectively.
STREAM_MODE mode; // PLAYBACK, RECORD, or DUPLEX.
AUDIO_HANDLE handle[2]; // Playback and record handles, respectively.
STREAM_STATE state; // STOPPED or RUNNING
char *userBuffer;
char *deviceBuffer;
bool doConvertBuffer[2]; // Playback and record, respectively.
bool deInterleave[2]; // Playback and record, respectively.
bool doByteSwap[2]; // Playback and record, respectively.
int sampleRate;
int bufferSize;
int nBuffers;
int nUserChannels[2]; // Playback and record, respectively.
int nDeviceChannels[2]; // Playback and record channels, respectively.
RTAUDIO_FORMAT userFormat;
RTAUDIO_FORMAT deviceFormat[2]; // Playback and record, respectively.
bool usingCallback;
THREAD_HANDLE thread;
MUTEX mutex;
RTAUDIO_CALLBACK callback;
void *userData;
} RTAUDIO_STREAM;
typedef signed short INT16;
typedef signed int INT32;
typedef float FLOAT32;
typedef double FLOAT64;
char message[256];
int nDevices;
RTAUDIO_DEVICE *devices;
std::map<int, void *> streams;
//! Private error method to allow global control over error handling.
void error(RtError::TYPE type);
/*!
Private method to count the system audio devices, allocate the
RTAUDIO_DEVICE structures, and probe the device capabilities.
*/
void initialize(void);
//! Private method to clear an RTAUDIO_DEVICE structure.
void clearDeviceInfo(RTAUDIO_DEVICE *info);
/*!
Private method which attempts to fill an RTAUDIO_DEVICE
structure for a given device. If an error is encountered during
the probe, a "warning" message is reported and the value of
"probed" remains false (no exception is thrown). A successful
probe is indicated by probed = true.
*/
void probeDeviceInfo(RTAUDIO_DEVICE *info);
/*!
Private method which attempts to open a device with the given parameters.
If an error is encountered during the probe, a "warning" message is
reported and FAILURE is returned (no exception is thrown). A
successful probe is indicated by a return value of SUCCESS.
*/
bool probeDeviceOpen(int device, RTAUDIO_STREAM *stream,
STREAM_MODE mode, int channels,
int sampleRate, RTAUDIO_FORMAT format,
int *bufferSize, int numberOfBuffers);
/*!
Private common method used to check validity of a user-passed
stream ID. When the ID is valid, this method returns a pointer to
an RTAUDIO_STREAM structure (in the form of a void pointer).
Otherwise, an "invalid identifier" exception is thrown.
*/
void *verifyStream(int streamId);
/*!
Private method used to perform format, channel number, and/or interleaving
conversions between the user and device buffers.
*/
void convertStreamBuffer(RTAUDIO_STREAM *stream, STREAM_MODE mode);
//! Private method used to perform byte-swapping on buffers.
void byteSwapBuffer(char *buffer, int samples, RTAUDIO_FORMAT format);
//! Private method which returns the number of bytes for a given format.
int formatBytes(RTAUDIO_FORMAT format);
};
// Uncomment the following definition to have extra information spewed to stderr.
//#define RTAUDIO_DEBUG
#endif

+ 13
- 0
doc/Release.txt View File

@@ -0,0 +1,13 @@
RtAudio - a C++ class which provides a common API for realtime audio input/output across Linux (native ALSA and OSS), SGI, and Windows operating systems.
By Gary P. Scavone, 2002.
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

doc/Doxyfile → doc/doxygen/Doxyfile View File

@@ -51,7 +51,7 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = tutorial.txt ../RtAudio.h
INPUT = tutorial.txt ../../RtAudio.h
FILE_PATTERNS =
RECURSIVE = NO
EXCLUDE =
@@ -71,7 +71,7 @@ IGNORE_PREFIX =
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_OUTPUT = ../html
HTML_HEADER = header.html
HTML_FOOTER = footer.html
HTML_STYLESHEET =
@@ -90,16 +90,16 @@ TREEVIEW_WIDTH = 250
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
PAPER_TYPE = letter
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = YES
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
@@ -107,7 +107,7 @@ RTF_STYLESHEET_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = YES
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
#---------------------------------------------------------------------------

doc/footer.html → doc/doxygen/footer.html View File

@@ -1,6 +1,6 @@
<HR>
<table><tr><td><img src="../ccrma.gif">
<table><tr><td><img src="../images/ccrma.gif">
<td>&copy;2001-2002 CCRMA, Stanford University. All Rights Reserved.<br>
Maintained by Gary P. Scavone, <a href="mailto:gary@ccrma.stanford.edu">gary@ccrma.stanford.edu</a><P>
</table>

doc/header.html → doc/doxygen/header.html View File


doc/tutorial.txt → doc/doxygen/tutorial.txt View File

@@ -2,9 +2,19 @@
<BODY BGCOLOR="white">
<CENTER>
\ref intro &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 methods &nbsp;&nbsp; \ref compiling &nbsp;&nbsp; \ref osnotes &nbsp;&nbsp; \ref acknowledge
</CENTER>
- \ref intro
- \ref start
- \ref error
- \ref probing
- \ref settings
- \ref playbackb
- \ref playbackc
- \ref recording
- \ref duplex
- \ref methods
- \ref compiling
- \ref osnotes
- \ref acknowledge
\section intro Introduction
@@ -24,11 +34,7 @@ RtAudio is a C++ class which provides a common API (Application Programming Inte
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. Multiple streams can run at the same time and, when allowed by the underlying audio API, a single device can serve multiple streams.
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 download Download
Latest Release (22 January 2002): <A href="release/rtaudio-2.0.tgz">Version 2.0 (111 kB tar/gzipped)</A>
The RtAudio API provides both blocking (synchronous) and callback (asyncronous) 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 start Getting Started
@@ -46,7 +52,7 @@ int main()
try {
audio = new RtAudio();
}
catch (RtAudioError &error) {
catch (RtError &error) {
// Handle the exception here
}
@@ -60,7 +66,7 @@ Obviously, this example doesn't demonstrate any of the real functionality of RtA
\section error Error Handling
RtAudio uses a C++ exception handler called RtAudioError, which is declared and defined within the RtAudio class files. The RtAudioError class is quite simple but it does allow errors to be "caught" by RtAudioError::TYPE. Almost all RtAudio methods can "throw" an RtAudioError, most typically if an invalid stream identifier is supplied to a method or a driver error occurs. There are a number of cases within RtAudio where warning messages may be displayed but an exception is not thrown. There is a private RtAudio method, error(), which can be modified to globally control how these messages are handled and reported.
RtAudio uses a C++ exception handler called RtError, which is declared and defined within the RtAudio class files. 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 an invalid stream identifier is supplied to a method or a driver error occurs. There are a number of cases within RtAudio where warning messages may be displayed but an exception is not thrown. There is a private RtAudio method, error(), which can be modified to globally control how these messages are handled and reported.
\section probing Probing Device Capabilities
@@ -71,7 +77,7 @@ A programmer may wish to query the available audio device capabilities before de
// probe.cpp
#include <iostream.h>
#include <iostream>
#include "RtAudio.h"
int main()
@@ -82,7 +88,7 @@ int main()
try {
audio = new RtAudio();
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
@@ -97,14 +103,14 @@ int main()
try {
audio->getDeviceInfo(i, &info);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
break;
}
// Print, for example, the maximum number of output channels for each device
cout << "device = " << i;
cout << ": maximum output channels = " << info.maxOutputChannels << endl;
cout << ": maximum output channels = " << info.maxOutputChannels << "\n";
}
// Clean up
@@ -146,7 +152,7 @@ The following data formats are defined and fully supported by RtAudio:
static const RTAUDIO_FORMAT RTAUDIO_FLOAT64; // 64-bit double
\endcode
The <I>nativeFormats</I> member of the RtAudio::RTAUDIO_DEVICE 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 RTAUDIO_DEVICE structure is false, the remaining structure members are likely unknown and the device is probably unusable.
The <I>nativeFormats</I> member of the RtAudio::RTAUDIO_DEVICE 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 RTAUDIO_DEVICE structure is false, the remaining structure members are likely unknown and the device is probably unuseable.
In general, the user need not be concerned with the minimum channel values reported in the RTAUDIO_DEVICE structure. While some audio devices may require a minimum channel value > 1, 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.
@@ -177,7 +183,7 @@ int main()
stream = audio->openStream(device, channels, 0, 0, RtAudio::RTAUDIO_FLOAT32,
sample_rate, &buffer_size, n_buffers);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
@@ -189,12 +195,10 @@ int main()
}
\endcode
The RtAudio::openStream() method attempts to open a stream with a specified set of parameter values. When successful, a stream identifier is returned. In this case, we attempt to open a playback stream on device 0 with two channels, 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, an attempt is made to find a device or set of devices which will meet the given parameters. If all attempts are unsuccessful, an RtAudioError is thrown. When a non-zero device value is specified, an attempt is made to open that device only.
The RtAudio::openStream() method attempts to open a stream with a specified set of parameter values. When successful, a stream identifier is returned. In this case, we attempt to open a playback stream on device 0 with two channels, 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, an attempt is made to find a device or set of devices 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 only.
RtAudio provides four signed integer and two floating point data formats which can be specified using the RtAudio::RTAUDIO_FORMAT parameter values mentioned earlier. If the opened device does not natively support the given format, RtAudio will automatically perform the necessary data format conversion.
Buffer sizes in RtAudio are <I>ALWAYS</I> given in sample frame units. For example, if you open an output stream with 4 channels and set <I>bufferSize</I> to 512, you will have to write 2048 samples of data to the output buffer within your callback or between calls to RtAudio::tickStream(). In this case, a single sample frame of data contains 4 samples of data.
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. 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 osnotes 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.
@@ -226,7 +230,7 @@ int main()
audio = new RtAudio(&stream, device, channels, 0, 0, RtAudio::RTAUDIO_FLOAT32,
sample_rate, &buffer_size, n_buffers);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
@@ -238,7 +242,7 @@ int main()
// Start the stream
audio->startStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
@@ -253,7 +257,7 @@ int main()
try {
audio->tickStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
@@ -266,7 +270,7 @@ int main()
audio->stopStream(stream);
audio->closeStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
}
@@ -290,7 +294,7 @@ The primary difference in using RtAudio with callback functionality involves the
\code
#include <iostream.h>
#include <iostream>
#include "RtAudio.h"
// Two-channel sawtooth wave generator.
@@ -330,7 +334,7 @@ int main()
audio = new RtAudio(&stream, device, channels, 0, 0, RtAudio::RTAUDIO_FLOAT64,
sample_rate, &buffer_size, n_buffers);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
@@ -342,7 +346,7 @@ int main()
// Start the stream
audio->startStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
@@ -355,7 +359,7 @@ int main()
audio->stopStream(stream);
audio->closeStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
}
@@ -399,7 +403,7 @@ int main()
audio = new RtAudio(&stream, 0, 0, device, channels,
RtAudio::RTAUDIO_FLOAT32, sample_rate, &buffer_size, n_buffers);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
@@ -411,7 +415,7 @@ int main()
// Start the stream
audio->startStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
@@ -424,7 +428,7 @@ int main()
try {
audio->tickStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
@@ -439,7 +443,7 @@ int main()
// Stop the stream
audio->stopStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
}
@@ -460,7 +464,7 @@ Finally, it is easy to use RtAudio for simultaneous audio input/output, or duple
\code
// duplex.cpp
#include <iostream.h>
#include <iostream>
#include "RtAudio.h"
// Pass-through function.
@@ -487,7 +491,7 @@ int main()
audio = new RtAudio(&stream, device, channels, device, channels, RtAudio::RTAUDIO_FLOAT64,
sample_rate, &buffer_size, n_buffers);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
exit(EXIT_FAILURE);
}
@@ -499,7 +503,7 @@ int main()
// Start the stream
audio->startStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
goto cleanup;
}
@@ -512,7 +516,7 @@ int main()
audio->stopStream(stream);
audio->closeStream(stream);
}
catch (RtAudioError &error) {
catch (RtError &error) {
error.printMessage();
}
@@ -566,28 +570,28 @@ In order to compile RtAudio for a specific OS and audio API, it is necessary to
<TR>
<TD>Linux</TD>
<TD>ALSA</TD>
<TD>__LINUX_ALSA_</TD>
<TD>__LINUX_ALSA__</TD>
<TD><TT>libasound, libpthread</TT></TD>
<TD><TT>g++ -Wall -D__LINUX_ALSA_ -o probe probe.cpp RtAudio.cpp -lasound -lpthread</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>OSS</TD>
<TD>__LINUX_OSS_</TD>
<TD>__LINUX_OSS__</TD>
<TD><TT>libpthread</TT></TD>
<TD><TT>g++ -Wall -D__LINUX_OSS_ -o probe probe.cpp RtAudio.cpp -lpthread</TT></TD>
<TD><TT>g++ -Wall -D__LINUX_OSS__ -o probe probe.cpp RtAudio.cpp -lpthread</TT></TD>
</TR>
<TR>
<TD>Irix</TD>
<TD>AL</TD>
<TD>__IRIX_AL_</TD>
<TD>__IRIX_AL__</TD>
<TD><TT>libaudio, libpthread</TT></TD>
<TD><TT>CC -Wall -D__IRIX_AL_ -o probe probe.cpp RtAudio.cpp -laudio -lpthread</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>__WINDOWS_DS_</TD>
<TD>__WINDOWS_DS__</TD>
<TD><TT>dsound.lib (ver. 5.0 or higher), multithreaded</TT></TD>
<TD><I>compiler specific</I></TD>
</TR>
@@ -602,7 +606,7 @@ RtAudio is designed to provide a common API across the various supported operati
\subsection linux Linux:
RtAudio for Linux was developed under Redhat distributions 7.0 - 7.2. Two different audio APIs are supported on Linux platforms: OSS and <A href="http://www.alsa-project.org/">ALSA</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. The ALSA API is relatively new and at this time is not part of the Linux kernel distribution. Work is in progress to make ALSA part of the 2.5 development kernel series. Despite that, the ALSA API offers significantly better functionality than the OSS API. RtAudio provides support for the 0.9 and higher versions of ALSA. Input/output latency on the order of 15-20 milliseconds can typically be achieved under both OSS or ALSA 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.
RtAudio for Linux was developed under Redhat distributions 7.0 - 7.2. Two different audio APIs are supported on Linux platforms: OSS and <A href="http://www.alsa-project.org/">ALSA</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. 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 0.9 and higher versions of ALSA. Input/output latency on the order of 15 milliseconds can typically be achieved under both OSS or ALSA 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.
@@ -610,19 +614,17 @@ The ALSA implementation of RtAudio makes no use of the ALSA "plug" interface. A
\subsection irix Irix (SGI):
The Irix version of RtAudio was written and tested on an SGI Indy running Irix version 6.5 and the newer "al" audio library. RtAudio does not compile under Irix version 6.3 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.
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 windows Windows:
RtAudio under Windows is written using the DirectSound API. In order to compile RtAudio under Windows, you must have the header and source files for DirectSound version 0.5 or higher. As far as I know, you cannot compile RtAudio for Windows NT because there is not sufficient DirectSound support. 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 crashing my system. RtAudio was developed with Visual C++ version 6.0. I was forced in several instances to modify code in order to get it to compile under the non-standard version of C++ that Microsoft so unprofessionally implemented. We can only hope that the developers of Visual C++ 7.0 will have time to read the C++ standard.
RtAudio under Windows is written using the DirectSound API. In order to compile RtAudio under Windows, 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 (in which case, you cannot use RtAudio). 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 crashing my system. RtAudio was developed with Visual C++ version 6.0. I was forced in several instances to modify code in order to get it to compile under the non-standard version of C++ that Microsoft so unprofessionally implemented. We can only hope that the developers of Visual C++ 7.0 will have time to read the C++ standard.
\section acknowledge Acknowledgments
\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.
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, the <A href="http://www.acoustics.hut.fi/">Laboratory of Acoustics and Audio Signal Processing</A> at the Helsinki University of Technology, Finland, and 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>. This work was supported in part by the United States Air Force Office of Scientific Research (grant \#F49620-99-1-0293).
These documentation files were generated using <A href="http://www.doxygen.org/">doxygen</A> by Dimitri van Heesch.
*/

doc/ccrma.gif → doc/images/ccrma.gif View File


BIN
doc/manual.pdf View File


+ 3
- 3
tests/Makefile View File

@@ -5,16 +5,16 @@ RM = /bin/rm

ifeq ($(OS),Linux) # These are for Linux
INSTR = info play_saw record_raw in_out play_raw twostreams call_saw call_inout call_twostreams
CC = g++ -Wall -D__LINUX_OSS_# -g -pg -O3
CC = g++ -Wall -D__LINUX_OSS__# -g -pg -O3
LIBRARY = -lpthread
# CC = g++ -g -Wall -D__LINUX_ALSA_ # -g -pg -O3
# CC = g++ -g -Wall -D__LINUX_ALSA__ # -g -pg -O3
# LIBRARY = -lpthread -lasound
INCLUDE = -I../
endif

ifeq ($(OS),IRIX) # These are for SGI
INSTR = info play_saw record_raw in_out play_raw twostreams call_saw call_inout call_twostreams
CC = CC -D__IRIX_AL_ # -g -fullwarn -D__SGI_CC__ -O2
CC = CC -D__IRIX_AL__ # -g -fullwarn -D__SGI_CC__ -O2
LIBRARY = -laudio -lpthread
INCLUDE = -I../
endif


+ 3
- 6
tests/call_inout.cpp View File

@@ -68,8 +68,7 @@ int main(int argc, char *argv[])
audio = new RtAudio(&stream, device, chans, device, chans,
FORMAT, fs, &buffer_size, 8);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
exit(EXIT_FAILURE);
}

@@ -77,8 +76,7 @@ int main(int argc, char *argv[])
audio->setStreamCallback(stream, &inout, NULL);
audio->startStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -88,8 +86,7 @@ int main(int argc, char *argv[])
try {
audio->stopStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
}

cleanup:


+ 5
- 5
tests/call_inout.dsp View File

@@ -42,14 +42,14 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "call_inout - Win32 Debug"
@@ -65,15 +65,15 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF


+ 3
- 6
tests/call_saw.cpp View File

@@ -92,8 +92,7 @@ int main(int argc, char *argv[])
audio = new RtAudio(&stream, device, chans, 0, 0,
FORMAT, fs, &buffer_size, 4);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
exit(EXIT_FAILURE);
}

@@ -103,8 +102,7 @@ int main(int argc, char *argv[])
audio->setStreamCallback(stream, &saw, (void *)data);
audio->startStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -115,8 +113,7 @@ int main(int argc, char *argv[])
try {
audio->stopStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
}

cleanup:


+ 5
- 5
tests/call_saw.dsp View File

@@ -42,14 +42,14 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "call_saw - Win32 Debug"
@@ -65,15 +65,15 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF


+ 6
- 12
tests/call_twostreams.cpp View File

@@ -92,8 +92,7 @@ int main(int argc, char *argv[])
try {
audio = new RtAudio();
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
exit(EXIT_FAILURE);
}

@@ -103,8 +102,7 @@ int main(int argc, char *argv[])
stream2 = audio->openStream(device, chans, 0, 0,
FORMAT, fs, &buffer_size, 8);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -115,8 +113,7 @@ int main(int argc, char *argv[])
audio->startStream(stream1);
audio->startStream(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -128,8 +125,7 @@ int main(int argc, char *argv[])
audio->stopStream(stream1);
audio->stopStream(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -140,8 +136,7 @@ int main(int argc, char *argv[])
audio->startStream(stream1);
audio->startStream(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -152,8 +147,7 @@ int main(int argc, char *argv[])
audio->stopStream(stream1);
audio->stopStream(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
}

cleanup:


+ 5
- 5
tests/call_twostreams.dsp View File

@@ -42,14 +42,14 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "call_twostreams - Win32 Debug"
@@ -65,15 +65,15 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF


+ 4
- 8
tests/in_out.cpp View File

@@ -65,8 +65,7 @@ int main(int argc, char *argv[])
audio = new RtAudio(&stream, device, chans, device, chans,
FORMAT, fs, &buffer_size, 8);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
exit(EXIT_FAILURE);
}

@@ -76,8 +75,7 @@ int main(int argc, char *argv[])
buffer = (MY_TYPE *) audio->getStreamBuffer(stream);
audio->startStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -87,8 +85,7 @@ int main(int argc, char *argv[])
try {
audio->tickStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}
counter += buffer_size;
@@ -97,8 +94,7 @@ int main(int argc, char *argv[])
try {
audio->stopStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
}

cleanup:


+ 2
- 2
tests/in_out.dsp View File

@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe


+ 2
- 2
tests/info.cpp View File

@@ -17,7 +17,7 @@ int main(int argc, char *argv[])
try {
audio = new RtAudio();
}
catch (RtAudioError &m) {
catch (RtError &m) {
m.printMessage();
exit(EXIT_FAILURE);
}
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
try {
audio->getDeviceInfo(i, &my_info);
}
catch (RtAudioError &m) {
catch (RtError &m) {
m.printMessage();
break;
}


+ 2
- 2
tests/info.dsp View File

@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe


+ 4
- 8
tests/play_raw.cpp View File

@@ -79,8 +79,7 @@ int main(int argc, char *argv[])
audio = new RtAudio(&stream, device, chans, 0, 0,
FORMAT, fs, &buffer_size, 2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
fclose(fd);
exit(EXIT_FAILURE);
}
@@ -89,8 +88,7 @@ int main(int argc, char *argv[])
buffer = (MY_TYPE *) audio->getStreamBuffer(stream);
audio->startStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -101,8 +99,7 @@ int main(int argc, char *argv[])
try {
audio->tickStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}
}
@@ -115,8 +112,7 @@ int main(int argc, char *argv[])
try {
audio->stopStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
}

cleanup:


+ 2
- 2
tests/play_raw.dsp View File

@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe


+ 4
- 8
tests/play_saw.cpp View File

@@ -73,8 +73,7 @@ int main(int argc, char *argv[])
audio = new RtAudio(&stream, device, chans, 0, 0,
FORMAT, fs, &buffer_size, 4);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
exit(EXIT_FAILURE);
}

@@ -85,8 +84,7 @@ int main(int argc, char *argv[])
buffer = (MY_TYPE *) audio->getStreamBuffer(stream);
audio->startStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -104,8 +102,7 @@ int main(int argc, char *argv[])
//cout << "frames until no block = " << audio->streamWillBlock(stream) << endl;
audio->tickStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -115,8 +112,7 @@ int main(int argc, char *argv[])
try {
audio->stopStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
}

cleanup:


+ 2
- 2
tests/play_saw.dsp View File

@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe


+ 4
- 9
tests/record_raw.cpp View File

@@ -11,7 +11,6 @@

#include "RtAudio.h"
#include <stdio.h>
#include <iostream.h>

/*
typedef char MY_TYPE;
@@ -66,8 +65,7 @@ int main(int argc, char *argv[])
audio = new RtAudio(&stream, 0, 0, device, chans,
FORMAT, fs, &buffer_size, 8);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
exit(EXIT_FAILURE);
}

@@ -78,8 +76,7 @@ int main(int argc, char *argv[])
buffer = (MY_TYPE *) audio->getStreamBuffer(stream);
audio->startStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -89,8 +86,7 @@ int main(int argc, char *argv[])
try {
audio->tickStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -101,8 +97,7 @@ int main(int argc, char *argv[])
try {
audio->stopStream(stream);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
}

cleanup:


+ 2
- 2
tests/record_raw.dsp View File

@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe


+ 9
- 18
tests/twostreams.cpp View File

@@ -77,8 +77,7 @@ int main(int argc, char *argv[])
try {
audio = new RtAudio();
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
exit(EXIT_FAILURE);
}

@@ -90,8 +89,7 @@ int main(int argc, char *argv[])
buffer1 = (MY_TYPE *) audio->getStreamBuffer(stream1);
buffer2 = (MY_TYPE *) audio->getStreamBuffer(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -101,8 +99,7 @@ int main(int argc, char *argv[])
try {
audio->startStream(stream1);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -119,8 +116,7 @@ int main(int argc, char *argv[])
try {
audio->tickStream(stream1);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -132,8 +128,7 @@ int main(int argc, char *argv[])
audio->stopStream(stream1);
audio->startStream(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -146,8 +141,7 @@ int main(int argc, char *argv[])
try {
audio->tickStream(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -163,8 +157,7 @@ int main(int argc, char *argv[])
audio->startStream(stream1);
audio->startStream(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -177,8 +170,7 @@ int main(int argc, char *argv[])
memcpy(buffer1, buffer2, sizeof(MY_TYPE) * chans * buffer_size);
audio->tickStream(stream1);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
goto cleanup;
}

@@ -190,8 +182,7 @@ int main(int argc, char *argv[])
audio->stopStream(stream1);
audio->stopStream(stream2);
}
catch (RtAudioError &m) {
m.printMessage();
catch (RtError &) {
}

cleanup:


+ 2
- 2
tests/twostreams.dsp View File

@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS_" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe


Loading…
Cancel
Save