Release 2.1 tarball
[rtaudio.git] / doc / html / index.html
1 <HTML>
2 <HEAD>
3 <TITLE>The RtAudio Tutorial</TITLE>
4 <LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
5 </HEAD>
6 <BODY BGCOLOR="#FFFFFF">
7 <CENTER>
8 <a class="qindex" href="index.html">Tutorial</a> &nbsp; <a class="qindex" href="annotated.html">Class/Enum List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </CENTER>
9 <HR>
10 <!-- Generated by Doxygen 1.2.8.1 -->
11 <h1>The <a class="el" href="classRtAudio.html">RtAudio</a> Tutorial</h1>
12 <p>
13  
14 <p>
15 <ul>
16 <li><a href="index.html#intro">Introduction</a><li><a href="index.html#download">Download</a><li><a href="index.html#start">Getting Started</a><li><a href="index.html#error">Error Handling</a><li><a href="index.html#probing">Probing Device Capabilities</a><li><a href="index.html#settings">Device Settings</a><li><a href="index.html#playbackb">Playback (blocking functionality)</a><li><a href="index.html#playbackc">Playback (callback functionality)</a><li><a href="index.html#recording">Recording</a><li><a href="index.html#duplex">Duplex Mode</a><li><a href="index.html#methods">Summary of Methods</a><li><a href="index.html#compiling">Compiling</a><li><a href="index.html#debug">Debugging</a><li><a href="index.html#osnotes">OS Notes</a><li><a href="index.html#acknowledge">Acknowledgements</a><li><a href="index.html#license">License</a></ul>
17 <a name="intro"><h2>Introduction</h2></a>
18
19 <p>
20 <a class="el" href="classRtAudio.html">RtAudio</a> is a C++ class which provides a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA and OSS), Macintosh OS X, SGI, and Windows (DirectSound and ASIO) operating systems. <a class="el" href="classRtAudio.html">RtAudio</a> significantly simplifies the process of interacting with computer audio hardware. It was designed with the following goals:
21 <p>
22 <ul>
23  <li>object oriented C++ design <li>simple, common API across all supported platforms <li>single independent header and source file for easy inclusion in programming projects <li>blocking functionality <li>callback functionality <li>extensive audio device parameter control <li>audio device capability probing <li>automatic internal conversion for data format, channel number compensation, de-interleaving, and byte-swapping <li>control over multiple audio streams and devices with a single instance </ul>
24
25 <p>
26 <a class="el" href="classRtAudio.html">RtAudio</a> incorporates the concept of audio streams, which represent audio output (playback) and/or input (recording). Available audio devices and their capabilities can be enumerated and then specified when opening a stream. When allowed by the underlying audio API, multiple streams can run at the same time and a single device can serve multiple streams. See the <a href="index.html#osnotes">OS Notes</a> section for information specific to each of the supported audio APIs.
27 <p>
28 The <a class="el" href="classRtAudio.html">RtAudio</a> 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.
29 <p>
30 <a name="download"><h2>Download</h2></a>
31
32 <p>
33 Latest Release (7 October 2002): <a href="http://www-ccrma.stanford.edu/~gary/rtaudio/release/rtaudio-2.1.tar.gz">Version 2.1 (165 kB tar/gzipped)</a>
34 <p>
35 <a name="start"><h2>Getting Started</h2></a>
36
37 <p>
38 The first thing that must be done when using <a class="el" href="classRtAudio.html">RtAudio</a> is to create an instance of the class. The default constructor <a class="el" href="classRtAudio.html#a0">RtAudio::RtAudio</a>() scans the underlying audio system to verify that at least one device is available. <a class="el" href="classRtAudio.html">RtAudio</a> often uses C++ exceptions to report errors, necessitating try/catch blocks around most member functions. The following code example demonstrates default object construction and destruction:
39 <p>
40 <div class="fragment"><pre><font class="preprocessor">#include "RtAudio.h"</font>
41
42 <font class="keywordtype">int</font> main()<font class="keyword"></font>
43 <font class="keyword"></font>{
44   <a class="code" href="classRtAudio.html">RtAudio</a> *audio;
45
46   <font class="comment">// Default RtAudio constructor</font>
47   <font class="keywordflow">try</font> {
48     audio = <font class="keyword">new</font> RtAudio();
49   }
50   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
51     <font class="comment">// Handle the exception here</font>
52   }
53
54   <font class="comment">// Clean up</font>
55   <font class="keyword">delete</font> audio;
56 }</pre></div>
57 <p>
58 Obviously, this example doesn't demonstrate any of the real functionality of <a class="el" href="classRtAudio.html">RtAudio</a>. However, all uses of <a class="el" href="classRtAudio.html">RtAudio</a> must begin with a constructor (either default or overloaded varieties) and must end with class destruction. Further, it is necessary that all class methods which can throw a C++ exception be called within a try/catch block.
59 <p>
60 <a name="error"><h2>Error Handling</h2></a>
61
62 <p>
63 <a class="el" href="classRtAudio.html">RtAudio</a> uses a C++ exception handler called <a class="el" href="classRtError.html">RtError</a>, which is declared and defined within the <a class="el" href="classRtAudio.html">RtAudio</a> class files. The <a class="el" href="classRtError.html">RtError</a> class is quite simple but it does allow errors to be "caught" by <a class="el" href="classRtError.html#s11">RtError::TYPE</a>. Almost all <a class="el" href="classRtAudio.html">RtAudio</a> methods can "throw" an <a class="el" href="classRtError.html">RtError</a>, most typically if an invalid stream identifier is supplied to a method or a driver error occurs. There are a number of cases within <a class="el" href="classRtAudio.html">RtAudio</a> where warning messages may be displayed but an exception is not thrown. There is a private <a class="el" href="classRtAudio.html">RtAudio</a> method, error(), which can be modified to globally control how these messages are handled and reported.
64 <p>
65 <a name="probing"><h2>Probing Device Capabilities</h2></a>
66
67 <p>
68 A programmer may wish to query the available audio device capabilities before deciding which to use. The following example outlines how this can be done.
69 <p>
70 <div class="fragment"><pre><font class="comment">// probe.cpp</font>
71
72 <font class="preprocessor">#include &lt;iostream&gt;</font>
73 <font class="preprocessor">#include "RtAudio.h"</font>
74
75 <font class="keywordtype">int</font> main()<font class="keyword"></font>
76 <font class="keyword"></font>{
77   <a class="code" href="classRtAudio.html">RtAudio</a> *audio;
78
79   <font class="comment">// Default RtAudio constructor</font>
80   <font class="keywordflow">try</font> {
81     audio = <font class="keyword">new</font> RtAudio();
82   }
83   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
84     error.printMessage();
85     exit(EXIT_FAILURE);
86   }
87
88   <font class="comment">// Determine the number of devices available</font>
89   <font class="keywordtype">int</font> devices = audio-&gt;<a class="code" href="classRtAudio.html#a6">getDeviceCount</a>();
90
91   <font class="comment">// Scan through devices for various capabilities</font>
92   <a class="code" href="structRtAudio_1_1RTAUDIO__DEVICE.html">RtAudio::RTAUDIO_DEVICE</a> info;
93   <font class="keywordflow">for</font> (<font class="keywordtype">int</font> i=1; i&lt;=devices; i++) {
94
95     <font class="keywordflow">try</font> {
96       audio-&gt;<a class="code" href="classRtAudio.html#a7">getDeviceInfo</a>(i, &amp;info);
97     }
98     <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
99       error.printMessage();
100       <font class="keywordflow">break</font>;
101     }
102
103     <font class="comment">// Print, for example, the maximum number of output channels for each device</font>
104     cout &lt;&lt; <font class="stringliteral">"device = "</font> &lt;&lt; i;
105     cout &lt;&lt; <font class="stringliteral">": maximum output channels = "</font> &lt;&lt; info.maxOutputChannels &lt;&lt; <font class="stringliteral">"\n"</font>;
106   }
107
108   <font class="comment">// Clean up</font>
109   <font class="keyword">delete</font> audio;
110
111   <font class="keywordflow">return</font> 0;
112 }</pre></div>
113 <p>
114 The RTAUDIO_DEVICE structure is defined in RtAudio.h and provides a variety of information useful in assessing the capabilities of a device:
115 <p>
116 <div class="fragment"><pre>  <font class="keyword">typedef</font> <font class="keyword">struct </font>{
117     <font class="keywordtype">char</font> name[128];
118     <font class="keywordtype">bool</font> probed;                          <font class="comment">// true if the device probe was successful.</font>
119     <font class="keywordtype">int</font> maxOutputChannels;
120     <font class="keywordtype">int</font> maxInputChannels;
121     <font class="keywordtype">int</font> maxDuplexChannels;
122     <font class="keywordtype">int</font> minOutputChannels;
123     <font class="keywordtype">int</font> minInputChannels;
124     <font class="keywordtype">int</font> minDuplexChannels;
125     <font class="keywordtype">bool</font> hasDuplexSupport;                <font class="comment">// true if duplex mode is supported.</font>
126     <font class="keywordtype">bool</font> isDefault;                       <font class="comment">// true if this is the default output or input device.</font>
127     <font class="keywordtype">int</font> nSampleRates;                     <font class="comment">// Number of discrete rates, or -1 if range supported.</font>
128     <font class="keywordtype">double</font> sampleRates[MAX_SAMPLE_RATES]; <font class="comment">// Supported sample rates, or {min, max} if range.</font>
129     RTAUDIO_FORMAT nativeFormats;
130   } RTAUDIO_DEVICE;</pre></div>
131 <p>
132 The following data formats are defined and fully supported by <a class="el" href="classRtAudio.html">RtAudio</a>:
133 <p>
134 <div class="fragment"><pre>  <font class="keyword">typedef</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> RTAUDIO_FORMAT;
135   <font class="keyword">static</font> <font class="keyword">const</font> RTAUDIO_FORMAT  RTAUDIO_SINT8;   <font class="comment">// Signed 8-bit integer</font>
136   <font class="keyword">static</font> <font class="keyword">const</font> RTAUDIO_FORMAT  RTAUDIO_SINT16;  <font class="comment">// Signed 16-bit integer</font>
137   <font class="keyword">static</font> <font class="keyword">const</font> RTAUDIO_FORMAT  RTAUDIO_SINT24;  <font class="comment">// Signed 24-bit integer (upper 3 bytes of 32-bit signed integer.)</font>
138   <font class="keyword">static</font> <font class="keyword">const</font> RTAUDIO_FORMAT  RTAUDIO_SINT32;  <font class="comment">// Signed 32-bit integer</font>
139   <font class="keyword">static</font> <font class="keyword">const</font> RTAUDIO_FORMAT  RTAUDIO_FLOAT32; <font class="comment">// 32-bit float normalized between +/- 1.0</font>
140   <font class="keyword">static</font> <font class="keyword">const</font> RTAUDIO_FORMAT  RTAUDIO_FLOAT64; <font class="comment">// 64-bit double normalized between +/- 1.0</font></pre></div>
141 <p>
142 The <em>nativeFormats</em> member of the <a class="el" href="structRtAudio_1_1RTAUDIO__DEVICE.html">RtAudio::RTAUDIO_DEVICE</a> structure is a bit mask of the above formats which are natively supported by the device. However, <a class="el" href="classRtAudio.html">RtAudio</a> will automatically provide format conversion if a particular format is not natively supported. When the <em>probed</em> member of the RTAUDIO_DEVICE structure is false, the remaining structure members are undefined and the device is probably unuseable.
143 <p>
144 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 &gt; 1, <a class="el" href="classRtAudio.html">RtAudio</a> will provide automatic channel number compensation when the number of channels set by the user is less than that required by the device. Channel compensation is <em>NOT</em> possible when the number of channels set by the user is greater than that supported by the device.
145 <p>
146 It should be noted that the capabilities reported by a device driver or underlying audio API are not always accurate and/or may be dependent on a combination of device settings. For this reason, <a class="el" href="classRtAudio.html">RtAudio</a> does not rely on the reported values when attempting to open a stream.
147 <p>
148 <a name="settings"><h2>Device Settings</h2></a>
149
150 <p>
151 The next step in using <a class="el" href="classRtAudio.html">RtAudio</a> is to open a stream with particular device and parameter settings.
152 <p>
153 <div class="fragment"><pre><font class="preprocessor">#include "RtAudio.h"</font>
154
155 <font class="keywordtype">int</font> main()<font class="keyword"></font>
156 <font class="keyword"></font>{
157   <font class="keywordtype">int</font> channels = 2;
158   <font class="keywordtype">int</font> sample_rate = 44100;
159   <font class="keywordtype">int</font> buffer_size = 256;  <font class="comment">// 256 sample frames</font>
160   <font class="keywordtype">int</font> n_buffers = 4;      <font class="comment">// number of internal buffers used by device</font>
161   <font class="keywordtype">int</font> device = 0;         <font class="comment">// 0 indicates the default or first available device</font>
162   <font class="keywordtype">int</font> stream;             <font class="comment">// our stream identifier</font>
163   <a class="code" href="classRtAudio.html">RtAudio</a> *audio;
164
165   <font class="comment">// Instantiate RtAudio and open a stream within a try/catch block</font>
166   <font class="keywordflow">try</font> {
167     audio = <font class="keyword">new</font> RtAudio();
168     stream = audio-&gt;<a class="code" href="classRtAudio.html#a3">openStream</a>(device, channels, 0, 0, RtAudio::RTAUDIO_FLOAT32,
169                                sample_rate, &amp;buffer_size, n_buffers);
170   }
171   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
172     error.printMessage();
173     exit(EXIT_FAILURE);
174   }
175
176   <font class="comment">// Clean up</font>
177   <font class="keyword">delete</font> audio;
178
179   <font class="keywordflow">return</font> 0;
180 }</pre></div>
181 <p>
182 The <a class="el" href="classRtAudio.html#a3">RtAudio::openStream</a>() 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 two channel playback stream with the default output device, 32-bit floating point data, a sample rate of 44100 Hz, a frame rate of 256 sample frames per read/write, and 4 internal device buffers. When device = 0, <a class="el" href="classRtAudio.html">RtAudio</a> first attempts to open the default audio device with the given parameters. If that attempt fails, <a class="el" href="classRtAudio.html">RtAudio</a> searches through the remaining available devices in an effort to find a device which will meet the given parameters. If all attempts are unsuccessful, an <a class="el" href="classRtError.html">RtError</a> is thrown. When a non-zero device value is specified, an attempt is made to open that device only (device = 1 specifies the first identified device, as reported by <a class="el" href="classRtAudio.html#a7">RtAudio::getDeviceInfo</a>()).
183 <p>
184 <a class="el" href="classRtAudio.html">RtAudio</a> 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, <a class="el" href="classRtAudio.html">RtAudio</a> will automatically perform the necessary data format conversion.
185 <p>
186 The <em>bufferSize</em> parameter specifies the desired number of sample frames which will be written to and/or read from a device per write/read operation. The <em>nBuffers</em> parameter is used in setting the underlying device buffer parameters. Both the <em>bufferSize</em> and <em>nBuffers</em> parameters can be used to control stream latency though there is no guarantee that the passed values will be those used by a device (the <em>nBuffers</em> parameter is ignored when using the OS X CoreAudio and the Windows ASIO APIs). In general, lower values for both parameters will produce less latency but perhaps less robust performance. Both parameters can be specified with values of zero, in which case the smallest allowable values will be used. The <em>bufferSize</em> parameter is passed as a pointer and the actual value used by the stream is set during the device setup procedure. <em>bufferSize</em> values should be a power of two. Optimal and allowable buffer values tend to vary between systems and devices. Check the <a href="index.html#osnotes">OS Notes</a> section for general guidelines.
187 <p>
188 As noted earlier, the device capabilities reported by a driver or underlying audio API are not always accurate and/or may be dependent on a combination of device settings. Because of this, <a class="el" href="classRtAudio.html">RtAudio</a> does not attempt to query a device's capabilities or use previously reported values when opening a device. Instead, <a class="el" href="classRtAudio.html">RtAudio</a> simply attempts to set the given parameters on a specified device and then checks whether the setup is successful or not.
189 <p>
190 <a name="playbackb"><h2>Playback (blocking functionality)</h2></a>
191
192 <p>
193 Once the device is open for playback, there are only a few final steps necessary for realtime audio output. We'll first provide an example (blocking functionality) and then discuss the details.
194 <p>
195 <div class="fragment"><pre><font class="comment">// playback.cpp</font>
196
197 <font class="preprocessor">#include "RtAudio.h"</font>
198
199 <font class="keywordtype">int</font> main()<font class="keyword"></font>
200 <font class="keyword"></font>{
201   <font class="keywordtype">int</font> count;
202   <font class="keywordtype">int</font> channels = 2;
203   <font class="keywordtype">int</font> sample_rate = 44100;
204   <font class="keywordtype">int</font> buffer_size = 256;  <font class="comment">// 256 sample frames</font>
205   <font class="keywordtype">int</font> n_buffers = 4;      <font class="comment">// number of internal buffers used by device</font>
206   <font class="keywordtype">float</font> *buffer;
207   <font class="keywordtype">int</font> device = 0;         <font class="comment">// 0 indicates the default or first available device</font>
208   <font class="keywordtype">int</font> stream;             <font class="comment">// our stream identifier</font>
209   <a class="code" href="classRtAudio.html">RtAudio</a> *audio;
210
211   <font class="comment">// Open a stream during RtAudio instantiation</font>
212   <font class="keywordflow">try</font> {
213     audio = <font class="keyword">new</font> RtAudio(&amp;stream, device, channels, 0, 0, RtAudio::RTAUDIO_FLOAT32,
214                         sample_rate, &amp;buffer_size, n_buffers);
215   }
216   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
217     error.printMessage();
218     exit(EXIT_FAILURE);
219   }
220
221   <font class="keywordflow">try</font> {
222     <font class="comment">// Get a pointer to the stream buffer</font>
223     buffer = (<font class="keywordtype">float</font> *) audio-&gt;<a class="code" href="classRtAudio.html#a8">getStreamBuffer</a>(stream);
224
225     <font class="comment">// Start the stream</font>
226     audio-&gt;<a class="code" href="classRtAudio.html#a11">startStream</a>(stream);
227   }
228   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
229     error.printMessage();
230     <font class="keywordflow">goto</font> cleanup;
231   }
232
233   <font class="comment">// An example loop which runs for about 40000 sample frames</font>
234   count = 0;
235   <font class="keywordflow">while</font> (count &lt; 40000) {
236     <font class="comment">// Generate your samples and fill the buffer with buffer_size sample frames of data</font>
237     ...
238
239     <font class="comment">// Trigger the output of the data buffer</font>
240     <font class="keywordflow">try</font> {
241       audio-&gt;<a class="code" href="classRtAudio.html#a9">tickStream</a>(stream);
242     }
243     <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
244       error.printMessage();
245       <font class="keywordflow">goto</font> cleanup;
246     }
247
248     count += buffer_size;
249   }
250
251   <font class="keywordflow">try</font> {
252     <font class="comment">// Stop and close the stream</font>
253     audio-&gt;<a class="code" href="classRtAudio.html#a12">stopStream</a>(stream);
254     audio-&gt;<a class="code" href="classRtAudio.html#a10">closeStream</a>(stream);
255   }
256   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
257     error.printMessage();
258   }
259
260  cleanup:
261   <font class="keyword">delete</font> audio;
262
263   <font class="keywordflow">return</font> 0;
264 }</pre></div>
265 <p>
266 The first thing to notice in this example is that we attempt to open a stream during class instantiation with an overloaded constructor. This constructor simply combines the functionality of the default constructor, used earlier, and the <a class="el" href="classRtAudio.html#a3">RtAudio::openStream</a>() method. Again, we have specified a device value of 0, indicating that the default or first available device meeting the given parameters should be used. The integer identifier of the opened stream is returned via the <em>stream</em> pointer value. An attempt is made to open the stream with the specified <em>bufferSize</em> value. However, it is possible that the device will not accept this value, in which case the closest allowable size is used and returned via the pointer value. The constructor can fail if no available devices are found, or a memory allocation or device driver error occurs. Note that you should not call the <a class="el" href="classRtAudio.html">RtAudio</a> destructor if an exception is thrown during instantiation.
267 <p>
268 Because <a class="el" href="classRtAudio.html">RtAudio</a> can typically be used to simultaneously control more than a single stream, it is necessary that the stream identifier be provided to nearly all public methods. Assuming the constructor is successful, it is necessary to get a pointer to the buffer, provided by <a class="el" href="classRtAudio.html">RtAudio</a>, for use in feeding data to/from the opened stream. Note that the user should <em>NOT</em> attempt to deallocate the stream buffer memory ... memory management for the stream buffer will be automatically controlled by <a class="el" href="classRtAudio.html">RtAudio</a>. After starting the stream with <a class="el" href="classRtAudio.html#a11">RtAudio::startStream</a>(), one simply fills that buffer, which is of length equal to the returned <em>bufferSize</em> value, with interleaved audio data (in the specified format) for playback. Finally, a call to the <a class="el" href="classRtAudio.html#a9">RtAudio::tickStream</a>() routine triggers a blocking write call for the stream.
269 <p>
270 In general, one should call the <a class="el" href="classRtAudio.html#a12">RtAudio::stopStream</a>() and <a class="el" href="classRtAudio.html#a10">RtAudio::closeStream</a>() methods after finishing with a stream. However, both methods will implicitly be called during object destruction if necessary.
271 <p>
272 <a name="playbackc"><h2>Playback (callback functionality)</h2></a>
273
274 <p>
275 The primary difference in using <a class="el" href="classRtAudio.html">RtAudio</a> with callback functionality involves the creation of a user-defined callback function. Here is an example which produces a sawtooth waveform for playback.
276 <p>
277 <div class="fragment"><pre><font class="preprocessor">#include &lt;iostream&gt;</font>
278 <font class="preprocessor">#include "RtAudio.h"</font>
279
280 <font class="comment">// Two-channel sawtooth wave generator.</font>
281 <font class="keywordtype">int</font> sawtooth(<font class="keywordtype">char</font> *buffer, <font class="keywordtype">int</font> buffer_size, <font class="keywordtype">void</font> *data)<font class="keyword"></font>
282 <font class="keyword"></font>{
283   <font class="keywordtype">int</font> i, j;
284   <font class="keywordtype">double</font> *my_buffer = (<font class="keywordtype">double</font> *) buffer;
285   <font class="keywordtype">double</font> *my_data = (<font class="keywordtype">double</font> *) data;
286
287   <font class="comment">// Write interleaved audio data.</font>
288   <font class="keywordflow">for</font> (i=0; i&lt;buffer_size; i++) {
289     <font class="keywordflow">for</font> (j=0; j&lt;2; j++) {
290       *my_buffer++ = my_data[j];
291
292       my_data[j] += 0.005 * (j+1+(j*0.1));
293       <font class="keywordflow">if</font> (my_data[j] &gt;= 1.0) my_data[j] -= 2.0;
294     }
295   }
296
297   <font class="keywordflow">return</font> 0;
298 }
299
300 <font class="keywordtype">int</font> main()<font class="keyword"></font>
301 <font class="keyword"></font>{
302   <font class="keywordtype">int</font> channels = 2;
303   <font class="keywordtype">int</font> sample_rate = 44100;
304   <font class="keywordtype">int</font> buffer_size = 256;  <font class="comment">// 256 sample frames</font>
305   <font class="keywordtype">int</font> n_buffers = 4;      <font class="comment">// number of internal buffers used by device</font>
306   <font class="keywordtype">int</font> device = 0;         <font class="comment">// 0 indicates the default or first available device</font>
307   <font class="keywordtype">int</font> stream;             <font class="comment">// our stream identifier</font>
308   <font class="keywordtype">double</font> data[2];
309   <font class="keywordtype">char</font> input;
310   <a class="code" href="classRtAudio.html">RtAudio</a> *audio;
311
312   <font class="comment">// Open a stream during RtAudio instantiation</font>
313   <font class="keywordflow">try</font> {
314     audio = <font class="keyword">new</font> RtAudio(&amp;stream, device, channels, 0, 0, RtAudio::RTAUDIO_FLOAT64,
315                         sample_rate, &amp;buffer_size, n_buffers);
316   }
317   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
318     error.printMessage();
319     exit(EXIT_FAILURE);
320   }
321
322   <font class="keywordflow">try</font> {
323     <font class="comment">// Set the stream callback function</font>
324     audio-&gt;<a class="code" href="classRtAudio.html#a4">setStreamCallback</a>(stream, &amp;sawtooth, (<font class="keywordtype">void</font> *)data);
325
326     <font class="comment">// Start the stream</font>
327     audio-&gt;<a class="code" href="classRtAudio.html#a11">startStream</a>(stream);
328   }
329   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
330     error.printMessage();
331     <font class="keywordflow">goto</font> cleanup;
332   }
333
334   cout &lt;&lt; <font class="stringliteral">"\nPlaying ... press &lt;enter&gt; to quit.\n"</font>;
335   cin.get(input);
336
337   <font class="keywordflow">try</font> {
338     <font class="comment">// Stop and close the stream</font>
339     audio-&gt;<a class="code" href="classRtAudio.html#a12">stopStream</a>(stream);
340     audio-&gt;<a class="code" href="classRtAudio.html#a10">closeStream</a>(stream);
341   }
342   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
343     error.printMessage();
344   }
345
346  cleanup:
347   <font class="keyword">delete</font> audio;
348
349   <font class="keywordflow">return</font> 0;
350 }</pre></div>
351 <p>
352 After opening the device in exactly the same way as the previous example (except with a data format change), we must set our callback function for the stream using <a class="el" href="classRtAudio.html#a4">RtAudio::setStreamCallback</a>(). When the underlying audio API uses blocking calls (OSS, ALSA, SGI, and Windows DirectSound), this method will spawn a new process (or thread) which automatically calls the callback function when more data is needed. Callback-based audio APIs (OS X CoreAudio and ASIO) implement their own event notification schemes. Note that the callback function is called only when the stream is "running" (between calls to the <a class="el" href="classRtAudio.html#a11">RtAudio::startStream</a>() and <a class="el" href="classRtAudio.html#a12">RtAudio::stopStream</a>() methods). The last argument to <a class="el" href="classRtAudio.html#a4">RtAudio::setStreamCallback</a>() is a pointer to arbitrary data that you wish to access from within your callback function.
353 <p>
354 In this example, we stop the stream with an explicit call to <a class="el" href="classRtAudio.html#a12">RtAudio::stopStream</a>(). When using callback functionality, it is also possible to stop a stream by returning a non-zero value from the callback function.
355 <p>
356 Once set with <a class="el" href="classRtAudio.html#a4">RtAudio::setStreamCallback</a>, the callback process exists for the life of the stream (until the stream is closed with <a class="el" href="classRtAudio.html#a10">RtAudio::closeStream</a>() or the <a class="el" href="classRtAudio.html">RtAudio</a> instance is deleted). It is possible to disassociate a callback function and cancel its process for an open stream using the <a class="el" href="classRtAudio.html#a5">RtAudio::cancelStreamCallback</a>() method. The stream can then be used with blocking functionality or a new callback can be associated with it.
357 <p>
358 <a name="recording"><h2>Recording</h2></a>
359
360 <p>
361 Using <a class="el" href="classRtAudio.html">RtAudio</a> for audio input is almost identical to the way it is used for playback. Here's the blocking playback example rewritten for recording:
362 <p>
363 <div class="fragment"><pre><font class="comment">// record.cpp</font>
364
365 <font class="preprocessor">#include "RtAudio.h"</font>
366
367 <font class="keywordtype">int</font> main()<font class="keyword"></font>
368 <font class="keyword"></font>{
369   <font class="keywordtype">int</font> count;
370   <font class="keywordtype">int</font> channels = 2;
371   <font class="keywordtype">int</font> sample_rate = 44100;
372   <font class="keywordtype">int</font> buffer_size = 256;  <font class="comment">// 256 sample frames</font>
373   <font class="keywordtype">int</font> n_buffers = 4;      <font class="comment">// number of internal buffers used by device</font>
374   <font class="keywordtype">float</font> *buffer;
375   <font class="keywordtype">int</font> device = 0;         <font class="comment">// 0 indicates the default or first available device</font>
376   <font class="keywordtype">int</font> stream;             <font class="comment">// our stream identifier</font>
377   <a class="code" href="classRtAudio.html">RtAudio</a> *audio;
378
379   <font class="comment">// Instantiate RtAudio and open a stream.</font>
380   <font class="keywordflow">try</font> {
381     audio = <font class="keyword">new</font> RtAudio(&amp;stream, 0, 0, device, channels,
382                         RtAudio::RTAUDIO_FLOAT32, sample_rate, &amp;buffer_size, n_buffers);
383   }
384   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
385     error.printMessage();
386     exit(EXIT_FAILURE);
387   }
388
389   <font class="keywordflow">try</font> {
390     <font class="comment">// Get a pointer to the stream buffer</font>
391     buffer = (<font class="keywordtype">float</font> *) audio-&gt;<a class="code" href="classRtAudio.html#a8">getStreamBuffer</a>(stream);
392
393     <font class="comment">// Start the stream</font>
394     audio-&gt;<a class="code" href="classRtAudio.html#a11">startStream</a>(stream);
395   }
396   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
397     error.printMessage();
398     <font class="keywordflow">goto</font> cleanup;
399   }
400
401   <font class="comment">// An example loop which runs for about 40000 sample frames</font>
402   count = 0;
403   <font class="keywordflow">while</font> (count &lt; 40000) {
404
405     <font class="comment">// Read a buffer of data</font>
406     <font class="keywordflow">try</font> {
407       audio-&gt;<a class="code" href="classRtAudio.html#a9">tickStream</a>(stream);
408     }
409     <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
410       error.printMessage();
411       <font class="keywordflow">goto</font> cleanup;
412     }
413
414     <font class="comment">// Process the input samples (buffer_size sample frames) that were read</font>
415     ...
416
417     count += buffer_size;
418   }
419
420   <font class="keywordflow">try</font> {
421     <font class="comment">// Stop the stream</font>
422     audio-&gt;<a class="code" href="classRtAudio.html#a12">stopStream</a>(stream);
423   }
424   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
425     error.printMessage();
426   }
427
428  cleanup:
429   <font class="keyword">delete</font> audio;
430
431   <font class="keywordflow">return</font> 0;
432 }</pre></div>
433 <p>
434 In this example, the stream was opened for recording with a non-zero <em>inputChannels</em> value. The only other difference between this example and that for playback involves the order of data processing in the loop, where it is necessary to first read a buffer of input data before manipulating it.
435 <p>
436 <a name="duplex"><h2>Duplex Mode</h2></a>
437
438 <p>
439 Finally, it is easy to use <a class="el" href="classRtAudio.html">RtAudio</a> for simultaneous audio input/output, or duplex operation. In this example, we use a callback function and pass our recorded data directly through for playback.
440 <p>
441 <div class="fragment"><pre><font class="comment">// duplex.cpp</font>
442
443 <font class="preprocessor">#include &lt;iostream&gt;</font>
444 <font class="preprocessor">#include "RtAudio.h"</font>
445
446 <font class="comment">// Pass-through function.</font>
447 <font class="keywordtype">int</font> pass(<font class="keywordtype">char</font> *buffer, <font class="keywordtype">int</font> buffer_size, <font class="keywordtype">void</font> *)<font class="keyword"></font>
448 <font class="keyword"></font>{
449   <font class="comment">// Surprise!!  We do nothing to pass the data through.</font>
450   <font class="keywordflow">return</font> 0;
451 }
452
453 <font class="keywordtype">int</font> main()<font class="keyword"></font>
454 <font class="keyword"></font>{
455   <font class="keywordtype">int</font> channels = 2;
456   <font class="keywordtype">int</font> sample_rate = 44100;
457   <font class="keywordtype">int</font> buffer_size = 256;  <font class="comment">// 256 sample frames</font>
458   <font class="keywordtype">int</font> n_buffers = 4;      <font class="comment">// number of internal buffers used by device</font>
459   <font class="keywordtype">int</font> device = 0;         <font class="comment">// 0 indicates the default or first available device</font>
460   <font class="keywordtype">int</font> stream;             <font class="comment">// our stream identifier</font>
461   <font class="keywordtype">double</font> data[2];
462   <font class="keywordtype">char</font> input;
463   <a class="code" href="classRtAudio.html">RtAudio</a> *audio;
464
465   <font class="comment">// Open a stream during RtAudio instantiation</font>
466   <font class="keywordflow">try</font> {
467     audio = <font class="keyword">new</font> RtAudio(&amp;stream, device, channels, device, channels, RtAudio::RTAUDIO_FLOAT64,
468                         sample_rate, &amp;buffer_size, n_buffers);
469   }
470   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
471     error.printMessage();
472     exit(EXIT_FAILURE);
473   }
474
475   <font class="keywordflow">try</font> {
476     <font class="comment">// Set the stream callback function</font>
477     audio-&gt;<a class="code" href="classRtAudio.html#a4">setStreamCallback</a>(stream, &amp;pass, NULL);
478
479     <font class="comment">// Start the stream</font>
480     audio-&gt;<a class="code" href="classRtAudio.html#a11">startStream</a>(stream);
481   }
482   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
483     error.printMessage();
484     <font class="keywordflow">goto</font> cleanup;
485   }
486
487   cout &lt;&lt; <font class="stringliteral">"\nRunning duplex ... press &lt;enter&gt; to quit.\n"</font>;
488   cin.get(input);
489
490   <font class="keywordflow">try</font> {
491     <font class="comment">// Stop and close the stream</font>
492     audio-&gt;<a class="code" href="classRtAudio.html#a12">stopStream</a>(stream);
493     audio-&gt;<a class="code" href="classRtAudio.html#a10">closeStream</a>(stream);
494   }
495   <font class="keywordflow">catch</font> (<a class="code" href="classRtError.html">RtError</a> &amp;error) {
496     error.printMessage();
497   }
498
499  cleanup:
500   <font class="keyword">delete</font> audio;
501
502   <font class="keywordflow">return</font> 0;
503 }</pre></div>
504 <p>
505 When an <a class="el" href="classRtAudio.html">RtAudio</a> stream is running in duplex mode (nonzero input <em>AND</em> output channels), the audio write (playback) operation always occurs before the audio read (record) operation. This sequence allows the use of a single buffer to store both output and input data.
506 <p>
507 As we see with this example, the write-read sequence of operations does not preclude the use of <a class="el" href="classRtAudio.html">RtAudio</a> in situations where input data is first processed and then output through a duplex stream. When the stream buffer is first allocated, it is initialized with zeros, which produces no audible result when output to the device. In this example, anything recorded by the audio stream input will be played out during the next round of audio processing.
508 <p>
509 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 <em>explicitly</em> control the calling order of the callback functions.
510 <p>
511 <a name="methods"><h2>Summary of Methods</h2></a>
512
513 <p>
514 The following is short summary of public methods (not including constructors and the destructor) provided by <a class="el" href="classRtAudio.html">RtAudio</a>:
515 <p>
516 <ul>
517  <li><a class="el" href="classRtAudio.html#a3">RtAudio::openStream</a>(): opens a stream with the specified parameters. <li><a class="el" href="classRtAudio.html#a4">RtAudio::setStreamCallback</a>(): sets a user-defined callback function for a given stream. <li><a class="el" href="classRtAudio.html#a5">RtAudio::cancelStreamCallback</a>(): cancels a callback process and function for a given stream. <li><a class="el" href="classRtAudio.html#a6">RtAudio::getDeviceCount</a>(): returns the number of audio devices available. <li><a class="el" href="classRtAudio.html#a7">RtAudio::getDeviceInfo</a>(): fills a user-supplied RTAUDIO_DEVICE structure for a specified device. <li><a class="el" href="classRtAudio.html#a8">RtAudio::getStreamBuffer</a>(): returns a pointer to the stream buffer. <li><a class="el" href="classRtAudio.html#a9">RtAudio::tickStream</a>(): triggers processing of input/output data for a stream (blocking). <li><a class="el" href="classRtAudio.html#a10">RtAudio::closeStream</a>(): closes the specified stream (implicitly called during object destruction). Once a stream is closed, the stream identifier is invalid and should not be used in calling any other <a class="el" href="classRtAudio.html">RtAudio</a> methods. <li><a class="el" href="classRtAudio.html#a11">RtAudio::startStream</a>(): (re)starts the specified stream, typically after it has been stopped with either stopStream() or abortStream() or after first opening the stream. <li><a class="el" href="classRtAudio.html#a12">RtAudio::stopStream</a>(): stops the specified stream, allowing any remaining samples in the queue to be played out and/or read in. This does not implicitly call <a class="el" href="classRtAudio.html#a10">RtAudio::closeStream</a>(). <li><a class="el" href="classRtAudio.html#a13">RtAudio::abortStream</a>(): stops the specified stream, discarding any remaining samples in the queue. This does not implicitly call closeStream(). <li><a class="el" href="classRtAudio.html#a14">RtAudio::streamWillBlock</a>(): queries a stream to determine whether a call to the <em>tickStream()</em> 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. </ul>
518
519 <p>
520 <a name="compiling"><h2>Compiling</h2></a>
521
522 <p>
523 In order to compile <a class="el" href="classRtAudio.html">RtAudio</a> for a specific OS and audio API, it is necessary to supply the appropriate preprocessor definition and library within the compiler statement: 
524 <p>
525
526 <p>
527   <table border=1 cellspacing=3 cellpadding=3><tr><td><b>OS:</b> </td><td><b>Audio API:</b> </td><td><b>Preprocessor Definition:</b> </td><td><b>Library or Framework:</b> </td><td><b>Example Compiler Statement:</b>   </td></tr>
528 <tr><td>Linux </td><td>ALSA </td><td>__LINUX_ALSA__ </td><td><code>asound, pthread</code> </td><td><code>g++ -Wall -D__LINUX_ALSA__ -o probe probe.cpp RtAudio.cpp -lasound -lpthread</code>   </td></tr>
529 <tr><td>Linux </td><td>OSS </td><td>__LINUX_OSS__ </td><td><code>pthread</code> </td><td><code>g++ -Wall -D__LINUX_OSS__ -o probe probe.cpp RtAudio.cpp -lpthread</code>   </td></tr>
530 <tr><td>Macintosh OS X </td><td>CoreAudio </td><td>__MACOSX_CORE__ </td><td><code>pthread, stdc++, CoreAudio</code> </td><td><code>cc -Wall -D__MACOSX_CORE__ -o probe probe.cpp RtAudio.cpp -framework CoreAudio -lstdc++ -lpthread</code>   </td></tr>
531 <tr><td>Irix </td><td>AL </td><td>__IRIX_AL__ </td><td><code>audio, pthread</code> </td><td><code>CC -Wall -D__IRIX_AL__ -o probe probe.cpp RtAudio.cpp -laudio -lpthread</code>   </td></tr>
532 <tr><td>Windows </td><td>Direct Sound </td><td>__WINDOWS_DS__ </td><td><code>dsound.lib (ver. 5.0 or higher), multithreaded</code> </td><td><em>compiler specific</em>   </td></tr>
533 <tr><td>Windows </td><td>ASIO </td><td>__WINDOWS_ASIO__ </td><td><em>various ASIO header and source files</em> </td><td><em>compiler specific</em>  </td></table>
534  
535 <p>
536
537 <p>
538 The example compiler statements above could be used to compile the <code>probe.cpp</code> example file, assuming that <code>probe.cpp</code>, <code>RtAudio.h</code>, and <code>RtAudio.cpp</code> all exist in the same directory.
539 <p>
540 <a name="debug"><h2>Debugging</h2></a>
541
542 <p>
543 If you are having problems getting <a class="el" href="classRtAudio.html">RtAudio</a> to run on your system, try passing the preprocessor definition <code>__RTAUDIO_DEBUG__</code> to the compiler (or uncomment the definition at the bottom of RtAudio.h). A variety of warning messages will be displayed which may help in determining the problem.
544 <p>
545 <a name="osnotes"><h2>OS Notes</h2></a>
546
547 <p>
548 <a class="el" href="classRtAudio.html">RtAudio</a> is designed to provide a common API across the various supported operating systems and audio libraries. Despite that, some issues need to be mentioned with regard to each.
549 <p>
550 <a name="linux"><h3>Linux:</h3></a>
551
552 <p>
553 <a class="el" href="classRtAudio.html">RtAudio</a> 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. <a class="el" href="classRtAudio.html">RtAudio</a> 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 <a class="el" href="classRtAudio.html">RtAudio</a> buffer parameters (without kernel modifications). Latencies on the order of 5 milliseconds or less can be achieved using a low-latency kernel patch and increasing FIFO scheduling priority. The pthread library, which is used for callback functionality, is a standard component of all Linux distributions.
554 <p>
555 The ALSA library includes OSS emulation support. That means that you can run programs compiled for the OSS API even when using the ALSA drivers and library. It should be noted however that OSS emulation under ALSA is not perfect. Specifically, channel number queries seem to consistently produce invalid results. While OSS emulation is successful for the majority of <a class="el" href="classRtAudio.html">RtAudio</a> tests, it is recommended that the native ALSA implementation of <a class="el" href="classRtAudio.html">RtAudio</a> be used on systems which have ALSA drivers installed.
556 <p>
557 The ALSA implementation of <a class="el" href="classRtAudio.html">RtAudio</a> makes no use of the ALSA "plug" interface. All necessary data format conversions, channel compensation, de-interleaving, and byte-swapping is handled by internal <a class="el" href="classRtAudio.html">RtAudio</a> routines.
558 <p>
559 <a name="macosx"><h3>Macintosh OS X (CoreAudio):</h3></a>
560
561 <p>
562 The Apple CoreAudio API is based on a callback scheme. <a class="el" href="classRtAudio.html">RtAudio</a> provides blocking functionality, in addition to callback functionality, within the context of that behavior. CoreAudio is designed to use a separate callback procedure for each of its audio devices. A single <a class="el" href="classRtAudio.html">RtAudio</a> duplex stream using two different devices is supported, though it cannot be guaranteed to always behave correctly because we cannot synchronize these two callbacks. This same functionality can be achieved with better synchrony by opening two separate streams for the devices and using <a class="el" href="classRtAudio.html">RtAudio</a> blocking calls (i.e. <a class="el" href="classRtAudio.html#a9">RtAudio::tickStream</a>()). The <em>numberOfBuffers</em> parameter to the <a class="el" href="classRtAudio.html#a3">RtAudio::openStream</a>() function has no affect in this implementation. It is not currently possible to have multiple simultaneous <a class="el" href="classRtAudio.html">RtAudio</a> streams accessing the same device.
563 <p>
564 <a name="irix"><h3>Irix (SGI):</h3></a>
565
566 <p>
567 The Irix version of <a class="el" href="classRtAudio.html">RtAudio</a> was written and tested on an SGI Indy running Irix version 6.5.4 and the newer "al" audio library. <a class="el" href="classRtAudio.html">RtAudio</a> does not compile under Irix version 6.3, mainly because the C++ compiler is too old. Despite the relatively slow speed of the Indy, <a class="el" href="classRtAudio.html">RtAudio</a> was found to behave quite well and input/output latency was very good. No problems were found with respect to using the pthread library.
568 <p>
569 <a name="windowsds"><h3>Windows (DirectSound):</h3></a>
570
571 <p>
572 In order to compile <a class="el" href="classRtAudio.html">RtAudio</a> under Windows for the DirectSound API, you must have the header and source files for DirectSound version 5.0 or higher. As far as I know, there is no DirectSoundCapture support for Windows NT. Audio output latency with DirectSound can be reasonably good (on the order of 20 milliseconds). On the other hand, input audio latency tends to be terrible (100 milliseconds or more). Further, DirectSound drivers tend to crash easily when experimenting with buffer parameters. On my system, I found it necessary to use values around nBuffers = 8 and bufferSize = 512 to avoid crashes. <a class="el" href="classRtAudio.html">RtAudio</a> was 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. Unfortunately, it appears they are continuing to undermine the C++ standard with more recent compiler releases.
573 <p>
574 <a name="windowsasio"><h3>Windows (ASIO):</h3></a>
575
576 <p>
577 The Steinberg ASIO audio API is based on a callback scheme. In addition, the API allows only a single device driver to be loaded and accessed at a time. Therefore, it is not possible to have multiple simultaneous <a class="el" href="classRtAudio.html">RtAudio</a> streams running concurrently with this API. ASIO device drivers must be supplied by audio hardware manufacturers, though ASIO emulation is possible on top of systems with DirectSound drivers. The <em>numberOfBuffers</em> parameter to the <a class="el" href="classRtAudio.html#a3">RtAudio::openStream</a>() function has no affect in this implementation.
578 <p>
579 A number of ASIO source and header files are required for use with <a class="el" href="classRtAudio.html">RtAudio</a>. Specifically, an <a class="el" href="classRtAudio.html">RtAudio</a> project must include the following files: <code>asio.h,cpp; asiodrivers.h,cpp; asiolist.h,cpp; asiodrvr.h; asiosys.h; ginclude.h; iasiodrv.h</code>. See the <code>/tests/asio/</code> directory for example Visual C++ 6.0 projects.
580 <p>
581 <a name="acknowledge"><h2>Acknowledgements</h2></a>
582
583 <p>
584 The <a class="el" href="classRtAudio.html">RtAudio</a> API incorporates many of the concepts developed in the <a href="http://www.portaudio.com/">PortAudio</a> project by Phil Burk and Ross Bencina. Early development also incorporated ideas from Bill Schottstaedt's <a href="http://www-ccrma.stanford.edu/software/snd/sndlib/">sndlib</a>. The CCRMA <a href="http://www-ccrma.stanford.edu/groups/soundwire/">SoundWire group</a> provided valuable feedback during the API proposal stages.
585 <p>
586 <a class="el" href="classRtAudio.html">RtAudio</a>, version 2.0, 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).
587 <p>
588 <a name="license"><h2>License</h2></a>
589
590 <p>
591 <a class="el" href="classRtAudio.html">RtAudio</a>: a realtime audio i/o C++ class<br>
592  Copyright (c) 2001-2002 Gary P. Scavone
593 <p>
594 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
595 <p>
596 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
597 <p>
598 Any person wishing to distribute modifications to the Software is requested to send the modifications to the original developer so that they can be incorporated into the canonical version.
599 <p>
600 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
601 <p>
602 <HR>
603
604 <table><tr><td><img src="../images/ccrma.gif">
605   <td>&copy;2001-2002 Gary P. Scavone, CCRMA, Stanford University. All Rights Reserved.<br>
606   Maintained by Gary P. Scavone, <a href="mailto:gary@ccrma.stanford.edu">gary@ccrma.stanford.edu</a><P>
607 </table>
608
609 </BODY>
610 </HTML>