From 57e98ec9ad76a78303729837e35e175b65a01c96 Mon Sep 17 00:00:00 2001 From: Gary Scavone Date: Thu, 10 Oct 2013 23:59:34 +0200 Subject: Release 2.1.1 tarball --- doc/html/RtAudio_8h-source.html | 501 ++++++++++++++++++++-------------------- doc/html/index.html | 24 +- 2 files changed, 266 insertions(+), 259 deletions(-) (limited to 'doc/html') diff --git a/doc/html/RtAudio_8h-source.html b/doc/html/RtAudio_8h-source.html index 1b99c73..ffe382d 100644 --- a/doc/html/RtAudio_8h-source.html +++ b/doc/html/RtAudio_8h-source.html @@ -72,259 +72,258 @@ 00098 00099 #elif defined(__MACOSX_CORE__) 00100 -00101 #include <CoreServices/CoreServices.h> -00102 #include <CoreAudio/AudioHardware.h> -00103 #include <pthread.h> -00104 -00105 typedef unsigned int AUDIO_HANDLE; -00106 typedef AudioDeviceID DEVICE_ID; -00107 typedef pthread_t THREAD_HANDLE; -00108 typedef pthread_mutex_t MUTEX; -00109 -00110 #endif -00111 -00112 -00113 /************************************************************************/ -00126 /************************************************************************/ -00127 -00128 class RtError -00129 { -00130 public: -00132 enum TYPE { -00133 WARNING, -00134 DEBUG_WARNING, -00135 UNSPECIFIED, -00136 NO_DEVICES_FOUND, -00137 INVALID_DEVICE, -00138 INVALID_STREAM, -00139 MEMORY_ERROR, -00140 INVALID_PARAMETER, -00141 DRIVER_ERROR, -00142 SYSTEM_ERROR, -00143 THREAD_ERROR -00144 }; -00145 -00146 protected: -00147 char error_message[256]; -00148 TYPE type; -00149 -00150 public: -00152 RtError(const char *p, TYPE tipe = RtError::UNSPECIFIED); -00153 -00155 virtual ~RtError(void); -00156 -00158 virtual void printMessage(void); -00159 -00161 virtual const TYPE& getType(void) { return type; } -00162 -00164 virtual const char *getMessage(void) { return error_message; } -00165 }; +00101 #include <CoreAudio/AudioHardware.h> +00102 #include <pthread.h> +00103 +00104 typedef unsigned int AUDIO_HANDLE; +00105 typedef AudioDeviceID DEVICE_ID; +00106 typedef pthread_t THREAD_HANDLE; +00107 typedef pthread_mutex_t MUTEX; +00108 +00109 #endif +00110 +00111 +00112 /************************************************************************/ +00125 /************************************************************************/ +00126 +00127 class RtError +00128 { +00129 public: +00131 enum TYPE { +00132 WARNING, +00133 DEBUG_WARNING, +00134 UNSPECIFIED, +00135 NO_DEVICES_FOUND, +00136 INVALID_DEVICE, +00137 INVALID_STREAM, +00138 MEMORY_ERROR, +00139 INVALID_PARAMETER, +00140 DRIVER_ERROR, +00141 SYSTEM_ERROR, +00142 THREAD_ERROR +00143 }; +00144 +00145 protected: +00146 char error_message[256]; +00147 TYPE type; +00148 +00149 public: +00151 RtError(const char *p, TYPE tipe = RtError::UNSPECIFIED); +00152 +00154 virtual ~RtError(void); +00155 +00157 virtual void printMessage(void); +00158 +00160 virtual const TYPE& getType(void) { return type; } +00161 +00163 virtual const char *getMessage(void) { return error_message; } +00164 }; +00165 00166 -00167 -00168 // This public structure type is used to pass callback information -00169 // between the private RtAudio stream structure and global callback -00170 // handling functions. -00171 typedef struct { -00172 void *object; // Used as a "this" pointer. -00173 int streamId; -00174 DEVICE_ID device[2]; -00175 THREAD_HANDLE thread; -00176 void *callback; -00177 void *buffers; -00178 unsigned long waitTime; -00179 bool blockTick; -00180 bool stopStream; -00181 bool usingCallback; -00182 void *userData; -00183 } CALLBACK_INFO; +00167 // This public structure type is used to pass callback information +00168 // between the private RtAudio stream structure and global callback +00169 // handling functions. +00170 typedef struct { +00171 void *object; // Used as a "this" pointer. +00172 int streamId; +00173 DEVICE_ID device[2]; +00174 THREAD_HANDLE thread; +00175 void *callback; +00176 void *buffers; +00177 unsigned long waitTime; +00178 bool blockTick; +00179 bool stopStream; +00180 bool usingCallback; +00181 void *userData; +00182 } CALLBACK_INFO; +00183 00184 -00185 -00186 // *************************************************** // -00187 // -00188 // RtAudio class declaration. -00189 // -00190 // *************************************************** // -00191 -00192 class RtAudio -00193 { -00194 public: -00195 -00196 // Support for signed integers and floats. Audio data fed to/from -00197 // the tickStream() routine is assumed to ALWAYS be in host -00198 // byte order. The internal routines will automatically take care of -00199 // any necessary byte-swapping between the host format and the -00200 // soundcard. Thus, endian-ness is not a concern in the following -00201 // format definitions. -00202 typedef unsigned long RTAUDIO_FORMAT; -00203 static const RTAUDIO_FORMAT RTAUDIO_SINT8; -00204 static const RTAUDIO_FORMAT RTAUDIO_SINT16; -00205 static const RTAUDIO_FORMAT RTAUDIO_SINT24; -00206 static const RTAUDIO_FORMAT RTAUDIO_SINT32; -00207 static const RTAUDIO_FORMAT RTAUDIO_FLOAT32; -00208 static const RTAUDIO_FORMAT RTAUDIO_FLOAT64; -00210 //static const int MAX_SAMPLE_RATES = 14; -00211 enum { MAX_SAMPLE_RATES = 14 }; -00212 -00213 typedef int (*RTAUDIO_CALLBACK)(char *buffer, int bufferSize, void *userData); -00214 -00216 typedef struct { -00217 char name[128]; -00218 DEVICE_ID id[2]; /* No value reported by getDeviceInfo(). */ -00219 bool probed; -00220 int maxOutputChannels; -00221 int maxInputChannels; -00222 int maxDuplexChannels; -00223 int minOutputChannels; -00224 int minInputChannels; -00225 int minDuplexChannels; -00226 bool hasDuplexSupport; -00227 bool isDefault; -00228 int nSampleRates; -00229 int sampleRates[MAX_SAMPLE_RATES]; -00230 RTAUDIO_FORMAT nativeFormats; -00231 } RTAUDIO_DEVICE; -00232 -00234 -00240 RtAudio(); -00241 -00243 -00254 RtAudio(int *streamId, -00255 int outputDevice, int outputChannels, -00256 int inputDevice, int inputChannels, -00257 RTAUDIO_FORMAT format, int sampleRate, -00258 int *bufferSize, int numberOfBuffers); -00259 -00261 -00265 ~RtAudio(); -00266 -00268 -00295 int openStream(int outputDevice, int outputChannels, -00296 int inputDevice, int inputChannels, -00297 RTAUDIO_FORMAT format, int sampleRate, -00298 int *bufferSize, int numberOfBuffers); -00299 -00301 -00320 void setStreamCallback(int streamId, RTAUDIO_CALLBACK callback, void *userData); -00321 -00323 -00330 void cancelStreamCallback(int streamId); -00331 -00333 int getDeviceCount(void); -00334 -00336 -00344 void getDeviceInfo(int device, RTAUDIO_DEVICE *info); -00345 -00347 -00352 char * const getStreamBuffer(int streamId); -00353 -00355 -00360 void tickStream(int streamId); -00361 -00363 -00367 void closeStream(int streamId); -00368 -00370 -00374 void startStream(int streamId); -00375 -00377 -00381 void stopStream(int streamId); -00382 -00384 -00388 void abortStream(int streamId); -00389 -00391 -00396 int streamWillBlock(int streamId); -00397 -00398 #if (defined(__MACOSX_CORE__) || defined(__WINDOWS_ASIO__)) -00399 // This function is intended for internal use only. It must be -00400 // public because it is called by the internal callback handler, -00401 // which is not a member of RtAudio. External use of this function -00402 // will most likely produce highly undesireable results! -00403 void callbackEvent(int streamId, DEVICE_ID deviceId, void *inData, void *outData); -00404 #endif -00405 -00406 protected: -00407 -00408 private: -00409 -00410 static const unsigned int SAMPLE_RATES[MAX_SAMPLE_RATES]; -00411 -00412 enum { FAILURE, SUCCESS }; -00413 -00414 enum STREAM_MODE { -00415 OUTPUT, -00416 INPUT, -00417 DUPLEX, -00418 UNINITIALIZED = -75 -00419 }; -00420 -00421 enum STREAM_STATE { -00422 STREAM_STOPPED, -00423 STREAM_RUNNING -00424 }; -00425 -00426 typedef struct { -00427 int device[2]; // Playback and record, respectively. -00428 STREAM_MODE mode; // OUTPUT, INPUT, or DUPLEX. -00429 AUDIO_HANDLE handle[2]; // Playback and record handles, respectively. -00430 STREAM_STATE state; // STOPPED or RUNNING -00431 char *userBuffer; -00432 char *deviceBuffer; -00433 bool doConvertBuffer[2]; // Playback and record, respectively. -00434 bool deInterleave[2]; // Playback and record, respectively. -00435 bool doByteSwap[2]; // Playback and record, respectively. -00436 int sampleRate; -00437 int bufferSize; -00438 int nBuffers; -00439 int nUserChannels[2]; // Playback and record, respectively. -00440 int nDeviceChannels[2]; // Playback and record channels, respectively. -00441 RTAUDIO_FORMAT userFormat; -00442 RTAUDIO_FORMAT deviceFormat[2]; // Playback and record, respectively. -00443 MUTEX mutex; -00444 CALLBACK_INFO callbackInfo; -00445 } RTAUDIO_STREAM; -00446 -00447 typedef signed short INT16; -00448 typedef signed int INT32; -00449 typedef float FLOAT32; -00450 typedef double FLOAT64; -00451 -00452 char message[256]; -00453 int nDevices; -00454 RTAUDIO_DEVICE *devices; -00455 -00456 std::map<int, void *> streams; -00457 -00459 void error(RtError::TYPE type); -00460 -00465 void initialize(void); -00466 -00471 int getDefaultInputDevice(void); -00472 -00477 int getDefaultOutputDevice(void); -00478 -00480 void clearDeviceInfo(RTAUDIO_DEVICE *info); -00481 -00489 void probeDeviceInfo(RTAUDIO_DEVICE *info); -00490 -00497 bool probeDeviceOpen(int device, RTAUDIO_STREAM *stream, -00498 STREAM_MODE mode, int channels, -00499 int sampleRate, RTAUDIO_FORMAT format, -00500 int *bufferSize, int numberOfBuffers); -00501 -00508 void *verifyStream(int streamId); -00509 -00514 void convertStreamBuffer(RTAUDIO_STREAM *stream, STREAM_MODE mode); -00515 -00517 void byteSwapBuffer(char *buffer, int samples, RTAUDIO_FORMAT format); -00518 -00520 int formatBytes(RTAUDIO_FORMAT format); -00521 }; -00522 -00523 // Define the following flag to have extra information spewed to stderr. -00524 //#define __RTAUDIO_DEBUG__ -00525 -00526 #endif +00185 // *************************************************** // +00186 // +00187 // RtAudio class declaration. +00188 // +00189 // *************************************************** // +00190 +00191 class RtAudio +00192 { +00193 public: +00194 +00195 // Support for signed integers and floats. Audio data fed to/from +00196 // the tickStream() routine is assumed to ALWAYS be in host +00197 // byte order. The internal routines will automatically take care of +00198 // any necessary byte-swapping between the host format and the +00199 // soundcard. Thus, endian-ness is not a concern in the following +00200 // format definitions. +00201 typedef unsigned long RTAUDIO_FORMAT; +00202 static const RTAUDIO_FORMAT RTAUDIO_SINT8; +00203 static const RTAUDIO_FORMAT RTAUDIO_SINT16; +00204 static const RTAUDIO_FORMAT RTAUDIO_SINT24; +00205 static const RTAUDIO_FORMAT RTAUDIO_SINT32; +00206 static const RTAUDIO_FORMAT RTAUDIO_FLOAT32; +00207 static const RTAUDIO_FORMAT RTAUDIO_FLOAT64; +00209 //static const int MAX_SAMPLE_RATES = 14; +00210 enum { MAX_SAMPLE_RATES = 14 }; +00211 +00212 typedef int (*RTAUDIO_CALLBACK)(char *buffer, int bufferSize, void *userData); +00213 +00215 typedef struct { +00216 char name[128]; +00217 DEVICE_ID id[2]; /* No value reported by getDeviceInfo(). */ +00218 bool probed; +00219 int maxOutputChannels; +00220 int maxInputChannels; +00221 int maxDuplexChannels; +00222 int minOutputChannels; +00223 int minInputChannels; +00224 int minDuplexChannels; +00225 bool hasDuplexSupport; +00226 bool isDefault; +00227 int nSampleRates; +00228 int sampleRates[MAX_SAMPLE_RATES]; +00229 RTAUDIO_FORMAT nativeFormats; +00230 } RTAUDIO_DEVICE; +00231 +00233 +00239 RtAudio(); +00240 +00242 +00253 RtAudio(int *streamId, +00254 int outputDevice, int outputChannels, +00255 int inputDevice, int inputChannels, +00256 RTAUDIO_FORMAT format, int sampleRate, +00257 int *bufferSize, int numberOfBuffers); +00258 +00260 +00264 ~RtAudio(); +00265 +00267 +00294 int openStream(int outputDevice, int outputChannels, +00295 int inputDevice, int inputChannels, +00296 RTAUDIO_FORMAT format, int sampleRate, +00297 int *bufferSize, int numberOfBuffers); +00298 +00300 +00319 void setStreamCallback(int streamId, RTAUDIO_CALLBACK callback, void *userData); +00320 +00322 +00329 void cancelStreamCallback(int streamId); +00330 +00332 int getDeviceCount(void); +00333 +00335 +00343 void getDeviceInfo(int device, RTAUDIO_DEVICE *info); +00344 +00346 +00351 char * const getStreamBuffer(int streamId); +00352 +00354 +00359 void tickStream(int streamId); +00360 +00362 +00366 void closeStream(int streamId); +00367 +00369 +00373 void startStream(int streamId); +00374 +00376 +00380 void stopStream(int streamId); +00381 +00383 +00387 void abortStream(int streamId); +00388 +00390 +00395 int streamWillBlock(int streamId); +00396 +00397 #if (defined(__MACOSX_CORE__) || defined(__WINDOWS_ASIO__)) +00398 // This function is intended for internal use only. It must be +00399 // public because it is called by the internal callback handler, +00400 // which is not a member of RtAudio. External use of this function +00401 // will most likely produce highly undesireable results! +00402 void callbackEvent(int streamId, DEVICE_ID deviceId, void *inData, void *outData); +00403 #endif +00404 +00405 protected: +00406 +00407 private: +00408 +00409 static const unsigned int SAMPLE_RATES[MAX_SAMPLE_RATES]; +00410 +00411 enum { FAILURE, SUCCESS }; +00412 +00413 enum STREAM_MODE { +00414 OUTPUT, +00415 INPUT, +00416 DUPLEX, +00417 UNINITIALIZED = -75 +00418 }; +00419 +00420 enum STREAM_STATE { +00421 STREAM_STOPPED, +00422 STREAM_RUNNING +00423 }; +00424 +00425 typedef struct { +00426 int device[2]; // Playback and record, respectively. +00427 STREAM_MODE mode; // OUTPUT, INPUT, or DUPLEX. +00428 AUDIO_HANDLE handle[2]; // Playback and record handles, respectively. +00429 STREAM_STATE state; // STOPPED or RUNNING +00430 char *userBuffer; +00431 char *deviceBuffer; +00432 bool doConvertBuffer[2]; // Playback and record, respectively. +00433 bool deInterleave[2]; // Playback and record, respectively. +00434 bool doByteSwap[2]; // Playback and record, respectively. +00435 int sampleRate; +00436 int bufferSize; +00437 int nBuffers; +00438 int nUserChannels[2]; // Playback and record, respectively. +00439 int nDeviceChannels[2]; // Playback and record channels, respectively. +00440 RTAUDIO_FORMAT userFormat; +00441 RTAUDIO_FORMAT deviceFormat[2]; // Playback and record, respectively. +00442 MUTEX mutex; +00443 CALLBACK_INFO callbackInfo; +00444 } RTAUDIO_STREAM; +00445 +00446 typedef signed short INT16; +00447 typedef signed int INT32; +00448 typedef float FLOAT32; +00449 typedef double FLOAT64; +00450 +00451 char message[256]; +00452 int nDevices; +00453 RTAUDIO_DEVICE *devices; +00454 +00455 std::map<int, void *> streams; +00456 +00458 void error(RtError::TYPE type); +00459 +00464 void initialize(void); +00465 +00470 int getDefaultInputDevice(void); +00471 +00476 int getDefaultOutputDevice(void); +00477 +00479 void clearDeviceInfo(RTAUDIO_DEVICE *info); +00480 +00488 void probeDeviceInfo(RTAUDIO_DEVICE *info); +00489 +00496 bool probeDeviceOpen(int device, RTAUDIO_STREAM *stream, +00497 STREAM_MODE mode, int channels, +00498 int sampleRate, RTAUDIO_FORMAT format, +00499 int *bufferSize, int numberOfBuffers); +00500 +00507 void *verifyStream(int streamId); +00508 +00513 void convertStreamBuffer(RTAUDIO_STREAM *stream, STREAM_MODE mode); +00514 +00516 void byteSwapBuffer(char *buffer, int samples, RTAUDIO_FORMAT format); +00517 +00519 int formatBytes(RTAUDIO_FORMAT format); +00520 }; +00521 +00522 // Define the following flag to have extra information spewed to stderr. +00523 //#define __RTAUDIO_DEBUG__ +00524 +00525 #endif
diff --git a/doc/html/index.html b/doc/html/index.html index dda6132..5567502 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -30,7 +30,7 @@ The RtAudio API provides both blockin

Download

-Latest Release (7 October 2002): Version 2.1 (165 kB tar/gzipped) +Latest Release (24 October 2002): Version 2.1.1 (165 kB tar/gzipped)

Getting Started

@@ -436,7 +436,7 @@ In this example, the stream was opened for recording with a non-zero inputCh

Duplex Mode

-Finally, it is easy to use RtAudio for simultaneous audio input/output, or duplex operation. In this example, we use a callback function and pass our recorded data directly through for playback. +Finally, it is easy to use RtAudio for simultaneous audio input/output, or duplex operation. In this example, we use a callback function and simply scale the input data before sending it back to the output.

// duplex.cpp
 
@@ -444,9 +444,18 @@ Finally, it is easy to use RtAudio fo
 #include "RtAudio.h"
 
 // Pass-through function.
-int pass(char *buffer, int buffer_size, void *)
+int scale(char *buffer, int buffer_size, void *)
 {
-  // Surprise!!  We do nothing to pass the data through.
+  // Note: do nothing here for pass through.
+  double *my_buffer = (double *) buffer;
+
+  // Scale input data for output.
+  for (int i=0; i<buffer_size; i++) {
+    // Do for two channels.
+    *my_buffer++ *= 0.5;
+    *my_buffer++ *= 0.5;
+  }
+
   return 0;
 }
 
@@ -458,7 +467,6 @@ Finally, it is easy to use RtAudio fo
   int n_buffers = 4;      // number of internal buffers used by device
   int device = 0;         // 0 indicates the default or first available device
   int stream;             // our stream identifier
-  double data[2];
   char input;
   RtAudio *audio;
 
@@ -474,7 +482,7 @@ Finally, it is easy to use RtAudio fo
 
   try {
     // Set the stream callback function
-    audio->setStreamCallback(stream, &pass, NULL);
+    audio->setStreamCallback(stream, &scale, NULL);
 
     // Start the stream
     audio->startStream(stream);
@@ -504,7 +512,7 @@ Finally, it is easy to use RtAudio fo
 

When an RtAudio stream is running in duplex mode (nonzero input AND output channels), the audio write (playback) operation always occurs before the audio read (record) operation. This sequence allows the use of a single buffer to store both output and input data.

-As we see with this example, the write-read sequence of operations does not preclude the use of RtAudio in situations where input data is first processed and then output through a duplex stream. When the stream buffer is first allocated, it is initialized with zeros, which produces no audible result when output to the device. In this example, anything recorded by the audio stream input will be played out during the next round of audio processing. +As we see with this example, the write-read sequence of operations does not preclude the use of RtAudio in situations where input data is first processed and then output through a duplex stream. When the stream buffer is first allocated, it is initialized with zeros, which produces no audible result when output to the device. In this example, anything recorded by the audio stream input will be scaled and played out during the next round of audio processing.

Note that duplex operation can also be achieved by opening one output stream and one input stream using the same or different devices. However, there may be timing problems when attempting to use two different devices, due to possible device clock variations, unless a common external "sync" is provided. This becomes even more difficult to achieve using two separate callback streams because it is not possible to explicitly control the calling order of the callback functions.

@@ -527,7 +535,7 @@ In order to compile RtAudio for a spe - +
OS: Audio API: Preprocessor Definition: Library or Framework: Example Compiler Statement:
Linux ALSA __LINUX_ALSA__ asound, pthread g++ -Wall -D__LINUX_ALSA__ -o probe probe.cpp RtAudio.cpp -lasound -lpthread
Linux OSS __LINUX_OSS__ pthread g++ -Wall -D__LINUX_OSS__ -o probe probe.cpp RtAudio.cpp -lpthread
Macintosh OS X CoreAudio __MACOSX_CORE__ pthread, stdc++, CoreAudio cc -Wall -D__MACOSX_CORE__ -o probe probe.cpp RtAudio.cpp -framework CoreAudio -lstdc++ -lpthread
Macintosh OS X CoreAudio __MACOSX_CORE__ pthread, stdc++, CoreAudio CC -Wall -D__MACOSX_CORE__ -o probe probe.cpp RtAudio.cpp -framework CoreAudio -lstdc++ -lpthread
Irix AL __IRIX_AL__ audio, pthread CC -Wall -D__IRIX_AL__ -o probe probe.cpp RtAudio.cpp -laudio -lpthread
Windows Direct Sound __WINDOWS_DS__ dsound.lib (ver. 5.0 or higher), multithreaded compiler specific
Windows ASIO __WINDOWS_ASIO__ various ASIO header and source files compiler specific
-- cgit v1.2.3