@@ -11,10 +11,8 @@ CC = @CXX@ | |||
AR = @AR@ | |||
RANLIB = @RANLIB@ | |||
DEFS = @debug@ | |||
DEFS += @audio_apis@ | |||
CFLAGS = @CFLAGS@ -Iinclude | |||
CFLAGS += @warn@ | |||
DEFS = @CPPFLAGS@ | |||
CFLAGS = @CXXFLAGS@ -Iinclude | |||
all : $(LIBRARY) | |||
@@ -4,13 +4,13 @@ | |||
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 Jack), and Windows | |||
and OSS), Macintosh OS X (CoreAudio and Jack), and Windows | |||
(DirectSound and ASIO) operating systems. | |||
RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/ | |||
RtAudio: realtime audio i/o C++ classes | |||
Copyright (c) 2001-2008 Gary P. Scavone | |||
Copyright (c) 2001-2009 Gary P. Scavone | |||
Permission is hereby granted, free of charge, to any person | |||
obtaining a copy of this software and associated documentation files | |||
@@ -42,7 +42,7 @@ | |||
\file RtAudio.h | |||
*/ | |||
// RtAudio: Version 4.0.4 | |||
// RtAudio: Version 4.0.5 | |||
#ifndef __RTAUDIO_H | |||
#define __RTAUDIO_H | |||
@@ -108,11 +108,15 @@ static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/mi | |||
If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to | |||
open the input and/or output stream device(s) for exclusive use. | |||
Note that this is not possible with all supported audio APIs. | |||
If the RTAUDIO_SCHEDULE_REALTIME flag is set, RtAudio will attempt | |||
to select realtime scheduling (round-robin) for the callback thread. | |||
*/ | |||
typedef unsigned int RtAudioStreamFlags; | |||
static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1; // Use non-interleaved buffers (default = interleaved). | |||
static const RtAudioStreamFlags RTAUDIO_MINIMIZE_LATENCY = 0x2; // Attempt to set stream parameters for lowest possible latency. | |||
static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4; // Attempt grab device and prevent use by others. | |||
static const RtAudioStreamFlags RTAUDIO_SCHEDULE_REALTIME = 0x8; // Try to select realtime scheduling for callback thread. | |||
/*! \typedef typedef unsigned long RtAudioStreamStatus; | |||
\brief RtAudio stream status (over- or underflow) flags. | |||
@@ -240,9 +244,10 @@ class RtAudio | |||
The following flags can be OR'ed together to allow a client to | |||
make changes to the default stream behavior: | |||
- \e RTAUDIO_NONINTERLEAVED: Use non-interleaved buffers (default = interleaved). | |||
- \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency. | |||
- \e RTAUDIO_HOG_DEVICE: Attempt grab device for exclusive use. | |||
- \e RTAUDIO_NONINTERLEAVED: Use non-interleaved buffers (default = interleaved). | |||
- \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency. | |||
- \e RTAUDIO_HOG_DEVICE: Attempt grab device for exclusive use. | |||
- \e RTAUDIO_SCHEDULE_REALTIME: Attempt to select realtime scheduling for callback thread. | |||
By default, RtAudio streams pass and receive audio data from the | |||
client in an interleaved format. By passing the | |||
@@ -268,6 +273,11 @@ class RtAudio | |||
open the input and/or output stream device(s) for exclusive use. | |||
Note that this is not possible with all supported audio APIs. | |||
If the RTAUDIO_SCHEDULE_REALTIME flag is set, RtAudio will attempt | |||
to select realtime scheduling (round-robin) for the callback thread. | |||
The \c priority parameter will only be used if the RTAUDIO_SCHEDULE_REALTIME | |||
flag is set. It defines the thread's realtime priority. | |||
The \c numberOfBuffers parameter can be used to control stream | |||
latency in the Windows DirectSound, Linux OSS, and Linux Alsa APIs | |||
only. A value of two is usually the smallest allowed. Larger | |||
@@ -285,10 +295,11 @@ class RtAudio | |||
RtAudioStreamFlags flags; /*!< A bit-mask of stream flags (RTAUDIO_NONINTERLEAVED, RTAUDIO_MINIMIZE_LATENCY, RTAUDIO_HOG_DEVICE). */ | |||
unsigned int numberOfBuffers; /*!< Number of stream buffers. */ | |||
std::string streamName; /*!< A stream name (currently used only in Jack). */ | |||
int priority; /*!< Scheduling priority of callback thread (only used with flag RTAUDIO_SCHEDULE_REALTIME). */ | |||
// Default constructor. | |||
StreamOptions() | |||
: flags(0), numberOfBuffers(0) {} | |||
: flags(0), numberOfBuffers(0), priority(0) {} | |||
}; | |||
//! A static function to determine the available compiled audio APIs. | |||
@@ -440,10 +451,10 @@ class RtAudio | |||
void abortStream( void ); | |||
//! Returns true if a stream is open and false if not. | |||
bool isStreamOpen( void ) throw(); | |||
bool isStreamOpen( void ) const throw(); | |||
//! Returns true if the stream is running and false if it is stopped or not open. | |||
bool isStreamRunning( void ) throw(); | |||
bool isStreamRunning( void ) const throw(); | |||
//! Returns the number of elapsed seconds since the stream was started. | |||
/*! | |||
@@ -462,6 +473,14 @@ class RtAudio | |||
*/ | |||
long getStreamLatency( void ); | |||
//! Returns actual sample rate in use by the stream. | |||
/*! | |||
On some systems, the sample rate used may be slightly different | |||
than that specified in the stream parameters. If a stream is not | |||
open, an RtError (type = INVALID_USE) will be thrown. | |||
*/ | |||
unsigned int getStreamSampleRate( void ); | |||
//! Specify whether warning messages should be printed to stderr. | |||
void showWarnings( bool value = true ) throw(); | |||
@@ -551,9 +570,10 @@ public: | |||
virtual void stopStream( void ) = 0; | |||
virtual void abortStream( void ) = 0; | |||
long getStreamLatency( void ); | |||
unsigned int getStreamSampleRate( void ); | |||
virtual double getStreamTime( void ); | |||
bool isStreamOpen( void ) { return stream_.state != STREAM_CLOSED; }; | |||
bool isStreamRunning( void ) { return stream_.state == STREAM_RUNNING; }; | |||
bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; }; | |||
bool isStreamRunning( void ) const { return stream_.state == STREAM_RUNNING; }; | |||
void showWarnings( bool value ) { showWarnings_ = value; }; | |||
@@ -688,9 +708,10 @@ inline void RtAudio :: closeStream( void ) throw() { return rtapi_->closeStream( | |||
inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); } | |||
inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); } | |||
inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); } | |||
inline bool RtAudio :: isStreamOpen( void ) throw() { return rtapi_->isStreamOpen(); } | |||
inline bool RtAudio :: isStreamRunning( void ) throw() { return rtapi_->isStreamRunning(); } | |||
inline bool RtAudio :: isStreamOpen( void ) const throw() { return rtapi_->isStreamOpen(); } | |||
inline bool RtAudio :: isStreamRunning( void ) const throw() { return rtapi_->isStreamRunning(); } | |||
inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); } | |||
inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); }; | |||
inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); } | |||
inline void RtAudio :: showWarnings( bool value ) throw() { rtapi_->showWarnings( value ); } | |||
@@ -1,5 +1,6 @@ | |||
# Process this file with autoconf to produce a configure script. | |||
AC_INIT(RtAudio, 4.0, gary@music.mcgill.ca, rtaudio) | |||
AC_CONFIG_AUX_DIR(config) | |||
AC_CONFIG_SRCDIR(RtAudio.cpp) | |||
AC_CONFIG_FILES([rtaudio-config Makefile tests/Makefile]) | |||
@@ -7,8 +8,7 @@ AC_CONFIG_FILES([rtaudio-config Makefile tests/Makefile]) | |||
AC_SUBST( GXX, ["no"] ) | |||
# Checks for programs. | |||
AC_PROG_CC | |||
AC_PROG_CXX(g++ CC c++ cxx) | |||
AC_PROG_CXX | |||
AC_PROG_RANLIB | |||
AC_PATH_PROG(AR, ar, no) | |||
if [[ $AR = "no" ]] ; then | |||
@@ -19,66 +19,65 @@ fi | |||
AC_HEADER_STDC | |||
AC_CHECK_HEADERS(sys/ioctl.h unistd.h) | |||
# Checks for typedefs, structures, and compiler characteristics. | |||
AC_C_CONST | |||
# Check for debug | |||
AC_MSG_CHECKING(whether to compile debug version) | |||
AC_ARG_ENABLE(debug, | |||
[ --enable-debug = enable various debug output], | |||
[AC_SUBST( debug, [-D__RTAUDIO_DEBUG__] ) AC_SUBST( cflags, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)], | |||
[AC_SUBST( debug, [] ) AC_SUBST( cflags, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)]) | |||
[AC_SUBST( cppflag, [-D__RTAUDIO_DEBUG__] ) AC_SUBST( cxxflag, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)], | |||
[AC_SUBST( cppflag, [] ) AC_SUBST( cxxflag, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)]) | |||
# Checks for functions | |||
AC_CHECK_FUNC(gettimeofday, [CFLAGS=$CFLAGS" -DHAVE_GETTIMEOFDAY"], ) | |||
AC_CHECK_FUNC(gettimeofday, [cppflag="$cppflag -DHAVE_GETTIMEOFDAY"], ) | |||
# For -I and -D flags | |||
CPPFLAGS="$CPPFLAGS $cppflag" | |||
# For debugging and optimization ... overwrite default because it has both -g and -O2 | |||
#CXXFLAGS="$CXXFLAGS $cxxflag" | |||
CXXFLAGS="$cxxflag" | |||
# Check compiler and use -Wall if gnu. | |||
if [test $GXX = "yes" ;] then | |||
AC_SUBST( warn, [-Wall] ) | |||
AC_SUBST( cxxflag, [-Wall] ) | |||
fi | |||
CFLAGS="$CFLAGS $cflags" | |||
CXXFLAGS="$CXXFLAGS $cxxflag" | |||
# Checks for package options and external software | |||
AC_SUBST( api, [""] ) | |||
AC_CANONICAL_HOST | |||
AC_MSG_CHECKING(for audio API) | |||
case $host in | |||
*-*-netbsd*) | |||
AC_SUBST( sound_api, [-D__LINUX_OSS__] ) | |||
AC_MSG_RESULT(using OSS) | |||
AC_SUBST( audio_apis, [-D__LINUX_OSS__] ) | |||
CFLAGS=$CFLAGS" -lossaudio" | |||
api="$api -D__LINUX_OSS__" | |||
LIBS="$LIBS -lossaudio" | |||
AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!)) | |||
;; | |||
*-*-linux*) | |||
AC_SUBST( sound_api, [_NO_API_] ) | |||
AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (mac and linux only)], [AC_SUBST( sound_api, [-D__UNIX_JACK__] ) AC_MSG_RESULT(using JACK)], ) | |||
if [test $sound_api = -D__UNIX_JACK__;] then | |||
TEMP_LIBS=$LIBS | |||
AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!)) | |||
AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!)) | |||
LIBS="`pkg-config --CFLAGS --libs jack` $TEMP_LIBS -lasound" | |||
audio_apis="-D__UNIX_JACK__" | |||
fi | |||
AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (mac and linux only)], [ | |||
api="$api -D__UNIX_JACK__" | |||
AC_MSG_RESULT(using JACK) | |||
AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!)) | |||
AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))], ) | |||
# Look for ALSA flag | |||
AC_ARG_WITH(alsa, [ --with-alsa = choose native ALSA API support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_ALSA__] ) AC_MSG_RESULT(using ALSA)], ) | |||
if [test $sound_api = -D__LINUX_ALSA__;] then | |||
AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!)) | |||
audio_apis="-D__LINUX_ALSA__ $audio_apis" | |||
fi | |||
AC_ARG_WITH(alsa, [ --with-alsa = choose native ALSA API support (linux only)], [ | |||
api="$api -D__LINUX_ALSA__" | |||
AC_MSG_RESULT(using ALSA) | |||
AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))], ) | |||
# Look for OSS flag | |||
AC_ARG_WITH(oss, [ --with-oss = choose OSS API support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_OSS__] ) AC_MSG_RESULT(using OSS)], ) | |||
if test $sound_api = -D__LINUX_OSS__; then | |||
audio_apis="-D__LINUX_OSS__ $audio_apis" | |||
fi | |||
AC_ARG_WITH(oss, [ --with-oss = choose OSS API support (linux only)], [ | |||
api="$api -D__LINUX_OSS__" | |||
AC_MSG_RESULT(using OSS)], ) | |||
# If no audio api flags specified, use ALSA | |||
if [test $sound_api = _NO_API_;] then | |||
if [test "$api" == "";] then | |||
AC_MSG_RESULT(using ALSA) | |||
AC_SUBST( audio_apis, [-D__LINUX_ALSA__] ) | |||
AC_SUBST( api, [-D__LINUX_ALSA__] ) | |||
AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!)) | |||
fi | |||
@@ -86,54 +85,47 @@ case $host in | |||
;; | |||
*-apple*) | |||
AC_SUBST( sound_api, [_NO_API_] ) | |||
AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (unix only)], [AC_SUBST( sound_api, [-D__UNIX_JACK__] ) AC_MSG_RESULT(using JACK)], ) | |||
if [test $sound_api = -D__UNIX_JACK__;] then | |||
AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!)) | |||
audio_apis="-D__UNIX_JACK__" | |||
fi | |||
AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (unix only)], [ | |||
api="$api -D__UNIX_JACK__" | |||
AC_MSG_RESULT(using JACK) | |||
AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))], ) | |||
# Look for Core flag | |||
AC_ARG_WITH(core, [ --with-core = choose CoreAudio API support (mac only)], [AC_SUBST( sound_api, [-D__MACOSX_CORE__] ) AC_MSG_RESULT(using CoreAudio)], ) | |||
if test $sound_api = -D__MACOSX_CORE__; then | |||
AC_ARG_WITH(core, [ --with-core = choose CoreAudio API support (mac only)], [ | |||
api="$api -D__MACOSX_CORE__" | |||
AC_MSG_RESULT(using CoreAudio) | |||
AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] ) | |||
AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation"] ) | |||
audio_apis="-D__MACOSX_CORE__ $audio_apis" | |||
fi | |||
LIBS="$LIBS -framework CoreAudio -framework CoreFoundation" ], ) | |||
# If no audio api flags specified, use CoreAudio | |||
if [test $sound_api = _NO_API_;] then | |||
AC_SUBST( sound_api, [-D__MACOSX_CORE__] ) | |||
if [test "$api" == ""; ] then | |||
AC_SUBST( api, [-D__MACOSX_CORE__] ) | |||
AC_MSG_RESULT(using CoreAudio) | |||
AC_CHECK_HEADER(CoreAudio/CoreAudio.h, | |||
[AC_SUBST( audio_apis, [-D__MACOSX_CORE__] )], | |||
[], | |||
[AC_MSG_ERROR(CoreAudio header files not found!)] ) | |||
AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation"] ) | |||
AC_SUBST( LIBS, ["-framework CoreAudio -framework CoreFoundation"] ) | |||
fi | |||
AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!)) | |||
;; | |||
*-mingw32*) | |||
AC_SUBST( sound_api, [_NO_API_] ) | |||
AC_ARG_WITH(asio, [ --with-asio = choose ASIO API support (windoze only)], [AC_SUBST( sound_api, [-D__WINDOWS_ASIO__] ) AC_MSG_RESULT(using ASIO)], ) | |||
if [test $sound_api = -D__WINDOWS_ASIO__;] then | |||
audio_apis="-D__WINDOWS_ASIO__" | |||
AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] ) | |||
fi | |||
AC_ARG_WITH(asio, [ --with-asio = choose ASIO API support (windoze only)], [ | |||
api="$api -D__WINDOWS_ASIO__" | |||
AC_MSG_RESULT(using ASIO) | |||
AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] ) ], ) | |||
# Look for DirectSound flag | |||
AC_ARG_WITH(ds, [ --with-ds = choose DirectSound API support (windoze only)], [AC_SUBST( sound_api, [-D__WINDOWS_DS__] ) AC_MSG_RESULT(using DirectSound)], ) | |||
if test $sound_api = -D__WINDOWS_DS__; then | |||
audio_apis="-D__WINDOWS_DS__ $audio_apis" | |||
LIBS="-ldsound -lwinmm $LIBS" | |||
fi | |||
AC_ARG_WITH(ds, [ --with-ds = choose DirectSound API support (windoze only)], [ | |||
api="$api -D__WINDOWS_DS__" | |||
AC_MSG_RESULT(using DirectSound) | |||
LIBS="-ldsound -lwinmm $LIBS" ], ) | |||
# If no audio api flags specified, use DirectSound | |||
if [test $sound_api = _NO_API_;] then | |||
AC_SUBST( sound_api, [-D__WINDOWS_DS__] ) | |||
if [test "$api" == "";] then | |||
AC_SUBST( api, [-D__WINDOWS_DS__] ) | |||
AC_MSG_RESULT(using DirectSound) | |||
audio_apis="-D__WINDOWS_DS__" | |||
LIBS="-ldsound -lwinmm $LIBS" | |||
fi | |||
@@ -146,8 +138,7 @@ case $host in | |||
;; | |||
esac | |||
# Checks for library functions. | |||
AC_PROG_GCC_TRADITIONAL | |||
CPPFLAGS="$CPPFLAGS $api" | |||
AC_OUTPUT | |||
@@ -2,7 +2,7 @@ | |||
\section debug Debugging | |||
If you are having problems getting RtAudio to run on your system, make sure to pass a value of \e true to the RtAudio::showWarnings() function (this is the default setting). A variety of warning messages will be displayed which may help in determining the problem. Also, try using the programs included in the <tt>tests</tt> directory. The program <tt>audioprobe</tt> displays the queried capabilities of all hardware devices found for all APIs compiled. When using the ALSA API, further information can be displayed by defining the preprocessor definition __RTAUDIO_DEBUG__. | |||
If you are having problems getting RtAudio to run on your system, make sure to pass a value of \e true to the RtAudio::showWarnings() function (this is the default setting). A variety of warning messages will be displayed which may help in determining the problem. Also, try using the programs included in the <tt>tests</tt> directory. The program <tt>audioprobe</tt> displays the queried capabilities of all hardware devices found for all APIs compiled. When using the ALSA and JACK APIs, further information can be displayed by defining the preprocessor definition __RTAUDIO_DEBUG__. | |||
\section compile Compiling | |||
@@ -5,6 +5,8 @@ Finally, it is easy to use RtAudio for simultaneous audio input/output, or duple | |||
\code | |||
#include "RtAudio.h" | |||
#include <iostream> | |||
#include <cstdlib> | |||
#include <cstring> | |||
// Pass-through function. | |||
int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, | |||
@@ -1,7 +1,7 @@ | |||
<HR> | |||
<table><tr><td><img src="../images/mcgill.gif" width=165></td> | |||
<td>©2001-2008 Gary P. Scavone, McGill University. All Rights Reserved.<br>Maintained by <a href="http://www.music.mcgill.ca/~gary/">Gary P. Scavone</a>.</td></tr> | |||
<td>©2001-2009 Gary P. Scavone, McGill University. All Rights Reserved.<br>Maintained by <a href="http://www.music.mcgill.ca/~gary/">Gary P. Scavone</a>.</td></tr> | |||
</table> | |||
</BODY> | |||
@@ -1,7 +1,7 @@ | |||
/*! \page license License | |||
RtAudio: a set of realtime audio i/o C++ classes<BR> | |||
Copyright (c) 2001-2007 Gary P. Scavone | |||
Copyright (c) 2001-2009 Gary P. Scavone | |||
Permission is hereby granted, free of charge, to any person | |||
obtaining a copy of this software and associated documentation files | |||
@@ -5,6 +5,7 @@ In this example, we provide a complete program that demonstrates the use of RtAu | |||
\code | |||
#include "RtAudio.h" | |||
#include <iostream> | |||
#include <cstdlib> | |||
// Two-channel sawtooth wave generator. | |||
int saw( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, | |||
@@ -6,6 +6,8 @@ Using RtAudio for audio input is almost identical to the way it is used for play | |||
\code | |||
#include "RtAudio.h" | |||
#include <iostream> | |||
#include <cstdlib> | |||
#include <cstring> | |||
int record( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, | |||
double streamTime, RtAudioStreamStatus status, void *userData ) | |||
@@ -32,7 +32,7 @@ Devices are now re-enumerated every time the RtAudio::getDeviceCount(), RtAudio: | |||
\section download Download | |||
Latest Release (24 January 2008): <A href="http://music.mcgill.ca/~gary/rtaudio/release/rtaudio-4.0.4.tar.gz">Version 4.0.4</A> | |||
Latest Release (2 February 2009): <A href="http://www.music.mcgill.ca/~gary/rtaudio/release/rtaudio-4.0.5.tar.gz">Version 4.0.5</A> | |||
\section documentation Documentation Links | |||
@@ -1,6 +1,21 @@ | |||
RtAudio - a set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound and ASIO) operating systems. | |||
By Gary P. Scavone, 2001-2008. | |||
By Gary P. Scavone, 2001-2009. | |||
v4.0.5: (2 February 2009) | |||
- added support in CoreAudio for arbitrary stream channel configurations | |||
- added getStreamSampleRate() function because the actual sample rate can sometimes vary slightly from the specified one (thanks to Theo Veenker) | |||
- added new StreamOptions flag "RTAUDIO_SCHEDULE_REALTIME" and attribute "priority" to StreamOptions (thanks to Theo Veenker) | |||
- replaced usleep(50000) in callbackEvent() by a wait on condition variable which gets signaled in startStream() (thanks to Theo Veenker) | |||
- fix for Jack API when user callback function signals stop or abort calls | |||
- fix to way stream state is changed to avoid infinite loop problem | |||
- fix to int<->float conversion in convertBuffer() (thanks to Theo Veenker) | |||
- bug fix in byteSwapBuffer() (thanks to Stefan Muller Arisona and Theo Veenker) | |||
- fixed a few gcc 4.4 errors in OS-X | |||
- fixed bug in rtaudio-config script | |||
- revised configure script and Makefile structures | |||
- 64-bit fixes in ALSA API (thanks to Stefan Muller Arisona) | |||
- fixed ASIO sample rate selection bug (thanks to Sasha Zheligovsky) | |||
v4.0.4: (24 January 2008) | |||
- added functionality to allow getDeviceInfo() to work in ALSA for an open device (like ASIO) | |||
@@ -1,6 +1,6 @@ | |||
RtAudio - a set of C++ classes which provide a common API for realtime audio input/output across Linux (native ALSA, JACK, and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound and ASIO) operating systems. | |||
By Gary P. Scavone, 2001-2008. | |||
By Gary P. Scavone, 2001-2009. | |||
To configure and compile (on Unix systems and MinGW): | |||
@@ -1,6 +1,6 @@ | |||
RtAudio - a set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound and ASIO) operating systems. | |||
By Gary P. Scavone, 2001-2008. | |||
By Gary P. Scavone, 2001-2009. | |||
This distribution of RtAudio contains the following: | |||
@@ -11,7 +11,7 @@ tests/Windows: Visual C++ .net test program workspace and projects | |||
OVERVIEW: | |||
RtAudio is a set of C++ classes that 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 objectives: | |||
RtAudio is a set of C++ classes that provides 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 objectives: | |||
- object-oriented C++ design | |||
- simple, common API across all supported platforms | |||
@@ -34,7 +34,7 @@ LEGAL AND ETHICAL: | |||
The RtAudio license is similar to the MIT License. | |||
RtAudio: a set of realtime audio i/o C++ classes | |||
Copyright (c) 2001-2008 Gary P. Scavone | |||
Copyright (c) 2001-2009 Gary P. Scavone | |||
Permission is hereby granted, free of charge, to any person | |||
obtaining a copy of this software and associated documentation files | |||
@@ -1,16 +1,19 @@ | |||
#! /bin/sh | |||
if (test "x$#" != "x1") ; then | |||
echo "Usage: $0 [--libs | --cxxflags]" | |||
echo "Usage: $0 [--libs | --cxxflags | --cppflags]" | |||
exit; | |||
fi | |||
LIBRARY="@LIBS@ @frameworks@" | |||
CFLAGS="@audio_apis@" | |||
LIBRARY="@LIBS@" | |||
CXXFLAGS="@CXXFLAGS@" | |||
CPPFLAGS="@CPPFLAGS@" | |||
if (test "x$1" == "x--libs") ; then | |||
echo "$LIBRARY" | |||
elif (test "x$1" == "x--CFLAGS") ; then | |||
echo "$CFLAGS" | |||
elif (test "x$1" == "x--cxxflags") ; then | |||
echo "$CXXFLAGS" | |||
elif (test "x$1" == "x--cppflags") ; then | |||
echo "$CPPFLAGS" | |||
else | |||
echo "Unknown option: $1" | |||
fi |
@@ -11,12 +11,10 @@ vpath %.o $(OBJECT_PATH) | |||
OBJECTS = RtAudio.o @objects@ | |||
CC = @CXX@ | |||
DEFS = @debug@ | |||
DEFS += @audio_apis@ | |||
CFLAGS = @CFLAGS@ | |||
CFLAGS += @warn@ -I$(INCLUDE) -I../include | |||
DEFS = @CPPFLAGS@ | |||
CFLAGS = @CXXFLAGS@ | |||
CFLAGS += -I$(INCLUDE) -I../include | |||
LIBRARY = @LIBS@ | |||
LIBRARY += @frameworks@ | |||
%.o : $(SRC_PATH)/%.cpp | |||
$(CC) $(CFLAGS) $(DEFS) -c $(<) -o $(OBJECT_PATH)/$@ | |||
@@ -44,11 +42,14 @@ duplex : duplex.cpp $(OBJECTS) | |||
testall : testall.cpp $(OBJECTS) | |||
$(CC) $(CFLAGS) $(DEFS) -o testall testall.cpp $(OBJECT_PATH)/*.o $(LIBRARY) | |||
clean : | |||
-rm $(OBJECT_PATH)/*.o | |||
-rm $(PROGRAMS) | |||
-rm -f *.raw *~ *.exe | |||
-rm -fR *.dSYM | |||
distclean: clean | |||
-rm Makefile | |||
strip : | |||
strip $(PROGRAMS) |
@@ -10,6 +10,8 @@ | |||
#include "RtAudio.h" | |||
#include <iostream> | |||
#include <cstdlib> | |||
#include <cstring> | |||
/* | |||
typedef signed long MY_TYPE; | |||
@@ -11,16 +11,20 @@ | |||
#include "RtAudio.h" | |||
#include <iostream> | |||
#include <cstdlib> | |||
#include <cstring> | |||
/* | |||
typedef char MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT8 | |||
#define SCALE 127.0 | |||
*/ | |||
typedef signed short MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT16 | |||
#define SCALE 32767.0 | |||
/* | |||
typedef signed long MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT24 | |||
#define SCALE 8388607.0 | |||
@@ -28,13 +32,11 @@ typedef signed long MY_TYPE; | |||
typedef signed long MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT32 | |||
#define SCALE 2147483647.0 | |||
*/ | |||
typedef float MY_TYPE; | |||
#define FORMAT RTAUDIO_FLOAT32 | |||
#define SCALE 1.0; | |||
/* | |||
typedef double MY_TYPE; | |||
#define FORMAT RTAUDIO_FLOAT64 | |||
#define SCALE 1.0; | |||
@@ -10,6 +10,7 @@ | |||
#include "RtAudio.h" | |||
#include <iostream> | |||
#include <cstdlib> | |||
/* | |||
typedef signed long MY_TYPE; | |||
@@ -19,21 +20,21 @@ typedef signed long MY_TYPE; | |||
typedef char MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT8 | |||
#define SCALE 127.0 | |||
*/ | |||
typedef signed short MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT16 | |||
#define SCALE 32767.0 | |||
/* | |||
typedef signed long MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT32 | |||
#define SCALE 2147483647.0 | |||
*/ | |||
typedef float MY_TYPE; | |||
#define FORMAT RTAUDIO_FLOAT32 | |||
#define SCALE 1.0 | |||
/* | |||
typedef double MY_TYPE; | |||
#define FORMAT RTAUDIO_FLOAT64 | |||
#define SCALE 1.0 | |||
@@ -142,6 +143,7 @@ int main( int argc, char *argv[] ) | |||
oParams.firstChannel = offset; | |||
options.flags |= RTAUDIO_HOG_DEVICE; | |||
options.flags |= RTAUDIO_SCHEDULE_REALTIME; | |||
#if !defined( USE_INTERLEAVED ) | |||
options.flags |= RTAUDIO_NONINTERLEAVED; | |||
#endif | |||
@@ -155,12 +157,12 @@ int main( int argc, char *argv[] ) | |||
} | |||
char input; | |||
//std::cout << "Stream latency = " << dac.getStreamLatency() << "\n" << std::endl; | |||
std::cout << "\nPlaying ... press <enter> to quit (buffer size = " << bufferFrames << ").\n"; | |||
std::cin.get( input ); | |||
try { | |||
// Stop the stream | |||
std::cout << "Stream latency = " << dac.getStreamLatency() << "\n" << std::endl; | |||
dac.stopStream(); | |||
} | |||
catch ( RtError& e ) { | |||
@@ -11,25 +11,27 @@ | |||
#include "RtAudio.h" | |||
#include <iostream> | |||
#include <cstdlib> | |||
#include <cstring> | |||
/* | |||
typedef char MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT8 | |||
*/ | |||
typedef signed short MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT16 | |||
/* | |||
typedef signed long MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT24 | |||
typedef signed long MY_TYPE; | |||
#define FORMAT RTAUDIO_SINT32 | |||
*/ | |||
typedef float MY_TYPE; | |||
#define FORMAT RTAUDIO_FLOAT32 | |||
/* | |||
typedef double MY_TYPE; | |||
#define FORMAT RTAUDIO_FLOAT64 | |||
*/ | |||
@@ -1,7 +1,7 @@ | |||
/******************************************/ | |||
/* | |||
testall.cpp | |||
by Gary P. Scavone, 2007 | |||
by Gary P. Scavone, 2007-2008 | |||
This program will make a variety of calls | |||
to extensively test RtAudio functionality. | |||
@@ -10,6 +10,8 @@ | |||
#include "RtAudio.h" | |||
#include <iostream> | |||
#include <cstdlib> | |||
#include <cstring> | |||
#define BASE_RATE 0.005 | |||
#define TIME 1.0 | |||
@@ -17,11 +19,13 @@ | |||
void usage( void ) { | |||
// Error function in case of incorrect command-line | |||
// argument specifications | |||
std::cout << "\nuseage: testall N fs <device> <channelOffset>\n"; | |||
std::cout << "\nuseage: testall N fs <iDevice> <oDevice> <iChannelOffset> <oChannelOffset>\n"; | |||
std::cout << " where N = number of channels,\n"; | |||
std::cout << " fs = the sample rate,\n"; | |||
std::cout << " device = optional device to use (default = 0),\n"; | |||
std::cout << " and channelOffset = an optional channel offset on the device (default = 0).\n\n"; | |||
std::cout << " iDevice = optional input device to use (default = 0),\n"; | |||
std::cout << " oDevice = optional output device to use (default = 0),\n"; | |||
std::cout << " iChannelOffset = an optional input channel offset (default = 0),\n"; | |||
std::cout << " and oChannelOffset = optional output channel offset (default = 0).\n\n"; | |||
exit( 0 ); | |||
} | |||
@@ -89,11 +93,11 @@ int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames, | |||
int main( int argc, char *argv[] ) | |||
{ | |||
unsigned int bufferFrames, fs, device = 0, offset = 0; | |||
unsigned int bufferFrames, fs, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0; | |||
char input; | |||
// minimal command-line checking | |||
if (argc < 3 || argc > 5 ) usage(); | |||
if (argc < 3 || argc > 7 ) usage(); | |||
RtAudio dac; | |||
if ( dac.getDeviceCount() < 1 ) { | |||
@@ -104,9 +108,13 @@ int main( int argc, char *argv[] ) | |||
channels = (unsigned int) atoi( argv[1] ); | |||
fs = (unsigned int) atoi( argv[2] ); | |||
if ( argc > 3 ) | |||
device = (unsigned int) atoi( argv[3] ); | |||
iDevice = (unsigned int) atoi( argv[3] ); | |||
if ( argc > 4 ) | |||
offset = (unsigned int) atoi( argv[4] ); | |||
oDevice = (unsigned int) atoi(argv[4]); | |||
if ( argc > 5 ) | |||
iOffset = (unsigned int) atoi(argv[5]); | |||
if ( argc > 6 ) | |||
oOffset = (unsigned int) atoi(argv[6]); | |||
double *data = (double *) calloc( channels, sizeof( double ) ); | |||
@@ -116,9 +124,9 @@ int main( int argc, char *argv[] ) | |||
// Set our stream parameters for output only. | |||
bufferFrames = 256; | |||
RtAudio::StreamParameters oParams, iParams; | |||
oParams.deviceId = device; | |||
oParams.deviceId = oDevice; | |||
oParams.nChannels = channels; | |||
oParams.firstChannel = offset; | |||
oParams.firstChannel = oOffset; | |||
RtAudio::StreamOptions options; | |||
options.flags = RTAUDIO_HOG_DEVICE; | |||
@@ -181,9 +189,9 @@ int main( int argc, char *argv[] ) | |||
// Now open a duplex stream. | |||
unsigned int bufferBytes; | |||
iParams.deviceId = device; | |||
iParams.deviceId = iDevice; | |||
iParams.nChannels = channels; | |||
iParams.firstChannel = offset; | |||
iParams.firstChannel = iOffset; | |||
options.flags = RTAUDIO_NONINTERLEAVED; | |||
try { | |||
dac.openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options ); | |||