Merge 3.0.3 into releases
[rtaudio.git] / doc / html / classRtAudio.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.4.4 -->
11 <h1>RtAudio Class Reference</h1><!-- doxytag: class="RtAudio" -->Realtime audio i/o C++ classes.  
12 <a href="#_details">More...</a>
13 <p>
14 <code>#include &lt;<a class="el" href="RtAudio_8h-source.html">RtAudio.h</a>&gt;</code>
15 <p>
16 <a href="classRtAudio-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
17 <tr><td></td></tr>
18 <tr><td colspan="2"><br><h2>Public Types</h2></td></tr>
19 <tr><td class="memItemLeft" nowrap align="right" valign="top">enum &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#w8">RtAudioApi</a> { <br>
20 &nbsp;&nbsp;<a class="el" href="classRtAudio.html#w8w0">UNSPECIFIED</a>, 
21 <a class="el" href="classRtAudio.html#w8w1">LINUX_ALSA</a>, 
22 <a class="el" href="classRtAudio.html#w8w2">LINUX_OSS</a>, 
23 <a class="el" href="classRtAudio.html#w8w3">LINUX_JACK</a>, 
24 <br>
25 &nbsp;&nbsp;<a class="el" href="classRtAudio.html#w8w4">MACOSX_CORE</a>, 
26 <a class="el" href="classRtAudio.html#w8w5">IRIX_AL</a>, 
27 <a class="el" href="classRtAudio.html#w8w6">WINDOWS_ASIO</a>, 
28 <a class="el" href="classRtAudio.html#w8w7">WINDOWS_DS</a>
29 <br>
30  }</td></tr>
31
32 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Audio API specifier arguments.  <a href="classRtAudio.html#w8">More...</a><br></td></tr>
33 <tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
34 <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a0">RtAudio</a> (<a class="el" href="classRtAudio.html#w8">RtAudioApi</a> api=UNSPECIFIED)</td></tr>
35
36 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The default class constructor.  <a href="#a0"></a><br></td></tr>
37 <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a1">RtAudio</a> (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers, <a class="el" href="classRtAudio.html#w8">RtAudioApi</a> api=UNSPECIFIED)</td></tr>
38
39 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A constructor which can be used to open a stream during instantiation.  <a href="#a1"></a><br></td></tr>
40 <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a2">RtAudio</a> (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int *numberOfBuffers, <a class="el" href="classRtAudio.html#w8">RtAudioApi</a> api=UNSPECIFIED)</td></tr>
41
42 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">An overloaded constructor which opens a stream and also returns <code>numberOfBuffers</code> parameter via pointer argument.  <a href="#a2"></a><br></td></tr>
43 <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a3">~RtAudio</a> ()</td></tr>
44
45 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The destructor.  <a href="#a3"></a><br></td></tr>
46 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a4">openStream</a> (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers)</td></tr>
47
48 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method for opening a stream with the specified parameters.  <a href="#a4"></a><br></td></tr>
49 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a5">openStream</a> (int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int *numberOfBuffers)</td></tr>
50
51 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method for opening a stream and also returning <code>numberOfBuffers</code> parameter via pointer argument.  <a href="#a5"></a><br></td></tr>
52 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a6">setStreamCallback</a> (RtAudioCallback callback, void *userData)</td></tr>
53
54 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method which sets a user-defined callback function for a given stream.  <a href="#a6"></a><br></td></tr>
55 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a7">cancelStreamCallback</a> ()</td></tr>
56
57 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method which cancels a callback process and function for the stream.  <a href="#a7"></a><br></td></tr>
58 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a8"></a><!-- doxytag: member="RtAudio::getDeviceCount" ref="a8" args="(void)" -->
59 int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a8">getDeviceCount</a> (void)</td></tr>
60
61 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method which returns the number of audio devices found. <br></td></tr>
62 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a9">getDeviceInfo</a> (int device)</td></tr>
63
64 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return an <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> structure for a specified device number.  <a href="#a9"></a><br></td></tr>
65 <tr><td class="memItemLeft" nowrap align="right" valign="top">char *const&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a10">getStreamBuffer</a> ()</td></tr>
66
67 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A public method which returns a pointer to the buffer for an open stream.  <a href="#a10"></a><br></td></tr>
68 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a11">tickStream</a> ()</td></tr>
69
70 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Public method used to trigger processing of input/output data for a stream.  <a href="#a11"></a><br></td></tr>
71 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a12">closeStream</a> ()</td></tr>
72
73 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Public method which closes a stream and frees any associated buffers.  <a href="#a12"></a><br></td></tr>
74 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a13">startStream</a> ()</td></tr>
75
76 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Public method which starts a stream.  <a href="#a13"></a><br></td></tr>
77 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a14">stopStream</a> ()</td></tr>
78
79 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.  <a href="#a14"></a><br></td></tr>
80 <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html#a15">abortStream</a> ()</td></tr>
81
82 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Stop a stream, discarding any samples remaining in the input/output queue.  <a href="#a15"></a><br></td></tr>
83 </table>
84 <hr><a name="_details"></a><h2>Detailed Description</h2>
85 Realtime audio i/o C++ classes. 
86 <p>
87 RtAudio provides a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA, Jack, and OSS), SGI, Macintosh OS X (CoreAudio), and Windows (DirectSound and ASIO) operating systems.<p>
88 RtAudio WWW site: <a href="http://music.mcgill.ca/~gary/rtaudio/">http://music.mcgill.ca/~gary/rtaudio/</a><p>
89 RtAudio: realtime audio i/o C++ classes Copyright (c) 2001-2005 Gary P. Scavone<p>
90 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:<p>
91 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.<p>
92 Any person wishing to distribute modifications to the Software is requested to send the modifications to the original developer so that they can be incorporated into the canonical version.<p>
93 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.
94 <p>
95 <hr><h2>Member Enumeration Documentation</h2>
96 <a class="anchor" name="w8"></a><!-- doxytag: member="RtAudio::RtAudioApi" ref="w8" args="" --><p>
97 <table class="mdTable" cellpadding="2" cellspacing="0">
98   <tr>
99     <td class="mdRow">
100       <table cellpadding="0" cellspacing="0" border="0">
101         <tr>
102           <td class="md" nowrap valign="top">enum <a class="el" href="classRtAudio.html#w8">RtAudio::RtAudioApi</a>          </td>
103         </tr>
104       </table>
105     </td>
106   </tr>
107 </table>
108 <table cellspacing="5" cellpadding="0" border="0">
109   <tr>
110     <td>
111       &nbsp;
112     </td>
113     <td>
114
115 <p>
116 Audio API specifier arguments. 
117 <p>
118 <dl compact><dt><b>Enumerator: </b></dt><dd>
119 <table border="0" cellspacing="2" cellpadding="0">
120 <tr><td valign="top"><em><a class="anchor" name="w8w0"></a><!-- doxytag: member="UNSPECIFIED" ref="w8w0" args="" -->UNSPECIFIED</em>&nbsp;</td><td>
121 Search for a working compiled API. </td></tr>
122 <tr><td valign="top"><em><a class="anchor" name="w8w1"></a><!-- doxytag: member="LINUX_ALSA" ref="w8w1" args="" -->LINUX_ALSA</em>&nbsp;</td><td>
123 The Advanced Linux Sound Architecture API. </td></tr>
124 <tr><td valign="top"><em><a class="anchor" name="w8w2"></a><!-- doxytag: member="LINUX_OSS" ref="w8w2" args="" -->LINUX_OSS</em>&nbsp;</td><td>
125 The Linux Open Sound System API. </td></tr>
126 <tr><td valign="top"><em><a class="anchor" name="w8w3"></a><!-- doxytag: member="LINUX_JACK" ref="w8w3" args="" -->LINUX_JACK</em>&nbsp;</td><td>
127 The Linux Jack Low-Latency Audio Server API. </td></tr>
128 <tr><td valign="top"><em><a class="anchor" name="w8w4"></a><!-- doxytag: member="MACOSX_CORE" ref="w8w4" args="" -->MACOSX_CORE</em>&nbsp;</td><td>
129 Macintosh OS-X Core Audio API. </td></tr>
130 <tr><td valign="top"><em><a class="anchor" name="w8w5"></a><!-- doxytag: member="IRIX_AL" ref="w8w5" args="" -->IRIX_AL</em>&nbsp;</td><td>
131 The Irix Audio Library API. </td></tr>
132 <tr><td valign="top"><em><a class="anchor" name="w8w6"></a><!-- doxytag: member="WINDOWS_ASIO" ref="w8w6" args="" -->WINDOWS_ASIO</em>&nbsp;</td><td>
133 The Steinberg Audio Stream I/O API. </td></tr>
134 <tr><td valign="top"><em><a class="anchor" name="w8w7"></a><!-- doxytag: member="WINDOWS_DS" ref="w8w7" args="" -->WINDOWS_DS</em>&nbsp;</td><td>
135 The Microsoft Direct Sound API. </td></tr>
136 </table>
137 </dl>
138     </td>
139   </tr>
140 </table>
141 <hr><h2>Constructor &amp; Destructor Documentation</h2>
142 <a class="anchor" name="a0"></a><!-- doxytag: member="RtAudio::RtAudio" ref="a0" args="(RtAudioApi api=UNSPECIFIED)" --><p>
143 <table class="mdTable" cellpadding="2" cellspacing="0">
144   <tr>
145     <td class="mdRow">
146       <table cellpadding="0" cellspacing="0" border="0">
147         <tr>
148           <td class="md" nowrap valign="top">RtAudio::RtAudio           </td>
149           <td class="md" valign="top">(&nbsp;</td>
150           <td class="md" nowrap valign="top"><a class="el" href="classRtAudio.html#w8">RtAudioApi</a>&nbsp;</td>
151           <td class="mdname1" valign="top" nowrap> <em>api</em> = <code>UNSPECIFIED</code>          </td>
152           <td class="md" valign="top">&nbsp;)&nbsp;</td>
153           <td class="md" nowrap></td>
154         </tr>
155       </table>
156     </td>
157   </tr>
158 </table>
159 <table cellspacing="5" cellpadding="0" border="0">
160   <tr>
161     <td>
162       &nbsp;
163     </td>
164     <td>
165
166 <p>
167 The default class constructor. 
168 <p>
169 Probes the system to make sure at least one audio input/output device is available and determines the api-specific identifier for each device found. An <a class="el" href="classRtError.html">RtError</a> error can be thrown if no devices are found or if a memory allocation error occurs.<p>
170 If no API argument is specified and multiple API support has been compiled, the default order of use is JACK, ALSA, OSS (Linux systems) and ASIO, DS (Windows systems).    </td>
171   </tr>
172 </table>
173 <a class="anchor" name="a1"></a><!-- doxytag: member="RtAudio::RtAudio" ref="a1" args="(int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers, RtAudioApi api=UNSPECIFIED)" --><p>
174 <table class="mdTable" cellpadding="2" cellspacing="0">
175   <tr>
176     <td class="mdRow">
177       <table cellpadding="0" cellspacing="0" border="0">
178         <tr>
179           <td class="md" nowrap valign="top">RtAudio::RtAudio           </td>
180           <td class="md" valign="top">(&nbsp;</td>
181           <td class="md" nowrap valign="top">int&nbsp;</td>
182           <td class="mdname" nowrap> <em>outputDevice</em>, </td>
183         </tr>
184         <tr>
185           <td class="md" nowrap align="right"></td>
186           <td class="md"></td>
187           <td class="md" nowrap>int&nbsp;</td>
188           <td class="mdname" nowrap> <em>outputChannels</em>, </td>
189         </tr>
190         <tr>
191           <td class="md" nowrap align="right"></td>
192           <td class="md"></td>
193           <td class="md" nowrap>int&nbsp;</td>
194           <td class="mdname" nowrap> <em>inputDevice</em>, </td>
195         </tr>
196         <tr>
197           <td class="md" nowrap align="right"></td>
198           <td class="md"></td>
199           <td class="md" nowrap>int&nbsp;</td>
200           <td class="mdname" nowrap> <em>inputChannels</em>, </td>
201         </tr>
202         <tr>
203           <td class="md" nowrap align="right"></td>
204           <td class="md"></td>
205           <td class="md" nowrap>RtAudioFormat&nbsp;</td>
206           <td class="mdname" nowrap> <em>format</em>, </td>
207         </tr>
208         <tr>
209           <td class="md" nowrap align="right"></td>
210           <td class="md"></td>
211           <td class="md" nowrap>int&nbsp;</td>
212           <td class="mdname" nowrap> <em>sampleRate</em>, </td>
213         </tr>
214         <tr>
215           <td class="md" nowrap align="right"></td>
216           <td class="md"></td>
217           <td class="md" nowrap>int *&nbsp;</td>
218           <td class="mdname" nowrap> <em>bufferSize</em>, </td>
219         </tr>
220         <tr>
221           <td class="md" nowrap align="right"></td>
222           <td class="md"></td>
223           <td class="md" nowrap>int&nbsp;</td>
224           <td class="mdname" nowrap> <em>numberOfBuffers</em>, </td>
225         </tr>
226         <tr>
227           <td class="md" nowrap align="right"></td>
228           <td class="md"></td>
229           <td class="md" nowrap><a class="el" href="classRtAudio.html#w8">RtAudioApi</a>&nbsp;</td>
230           <td class="mdname" nowrap> <em>api</em> = <code>UNSPECIFIED</code></td>
231         </tr>
232         <tr>
233           <td class="md"></td>
234           <td class="md">)&nbsp;</td>
235           <td class="md" colspan="2"></td>
236         </tr>
237       </table>
238     </td>
239   </tr>
240 </table>
241 <table cellspacing="5" cellpadding="0" border="0">
242   <tr>
243     <td>
244       &nbsp;
245     </td>
246     <td>
247
248 <p>
249 A constructor which can be used to open a stream during instantiation. 
250 <p>
251 The specified output and/or input device identifiers correspond to those enumerated via the <a class="el" href="classRtAudio.html#a9">getDeviceInfo()</a> method. If device = 0, the default or first available devices meeting the given parameters is selected. If an output or input channel value is zero, the corresponding device value is ignored. When a stream is successfully opened, its identifier is returned via the "streamId" pointer. An <a class="el" href="classRtError.html">RtError</a> can be thrown if no devices are found for the given parameters, if a memory allocation error occurs, or if a driver error occurs.<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="classRtAudio.html#a4">openStream()</a></dd></dl>
252     </td>
253   </tr>
254 </table>
255 <a class="anchor" name="a2"></a><!-- doxytag: member="RtAudio::RtAudio" ref="a2" args="(int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int *numberOfBuffers, RtAudioApi api=UNSPECIFIED)" --><p>
256 <table class="mdTable" cellpadding="2" cellspacing="0">
257   <tr>
258     <td class="mdRow">
259       <table cellpadding="0" cellspacing="0" border="0">
260         <tr>
261           <td class="md" nowrap valign="top">RtAudio::RtAudio           </td>
262           <td class="md" valign="top">(&nbsp;</td>
263           <td class="md" nowrap valign="top">int&nbsp;</td>
264           <td class="mdname" nowrap> <em>outputDevice</em>, </td>
265         </tr>
266         <tr>
267           <td class="md" nowrap align="right"></td>
268           <td class="md"></td>
269           <td class="md" nowrap>int&nbsp;</td>
270           <td class="mdname" nowrap> <em>outputChannels</em>, </td>
271         </tr>
272         <tr>
273           <td class="md" nowrap align="right"></td>
274           <td class="md"></td>
275           <td class="md" nowrap>int&nbsp;</td>
276           <td class="mdname" nowrap> <em>inputDevice</em>, </td>
277         </tr>
278         <tr>
279           <td class="md" nowrap align="right"></td>
280           <td class="md"></td>
281           <td class="md" nowrap>int&nbsp;</td>
282           <td class="mdname" nowrap> <em>inputChannels</em>, </td>
283         </tr>
284         <tr>
285           <td class="md" nowrap align="right"></td>
286           <td class="md"></td>
287           <td class="md" nowrap>RtAudioFormat&nbsp;</td>
288           <td class="mdname" nowrap> <em>format</em>, </td>
289         </tr>
290         <tr>
291           <td class="md" nowrap align="right"></td>
292           <td class="md"></td>
293           <td class="md" nowrap>int&nbsp;</td>
294           <td class="mdname" nowrap> <em>sampleRate</em>, </td>
295         </tr>
296         <tr>
297           <td class="md" nowrap align="right"></td>
298           <td class="md"></td>
299           <td class="md" nowrap>int *&nbsp;</td>
300           <td class="mdname" nowrap> <em>bufferSize</em>, </td>
301         </tr>
302         <tr>
303           <td class="md" nowrap align="right"></td>
304           <td class="md"></td>
305           <td class="md" nowrap>int *&nbsp;</td>
306           <td class="mdname" nowrap> <em>numberOfBuffers</em>, </td>
307         </tr>
308         <tr>
309           <td class="md" nowrap align="right"></td>
310           <td class="md"></td>
311           <td class="md" nowrap><a class="el" href="classRtAudio.html#w8">RtAudioApi</a>&nbsp;</td>
312           <td class="mdname" nowrap> <em>api</em> = <code>UNSPECIFIED</code></td>
313         </tr>
314         <tr>
315           <td class="md"></td>
316           <td class="md">)&nbsp;</td>
317           <td class="md" colspan="2"></td>
318         </tr>
319       </table>
320     </td>
321   </tr>
322 </table>
323 <table cellspacing="5" cellpadding="0" border="0">
324   <tr>
325     <td>
326       &nbsp;
327     </td>
328     <td>
329
330 <p>
331 An overloaded constructor which opens a stream and also returns <code>numberOfBuffers</code> parameter via pointer argument. 
332 <p>
333 See the previous constructor call for details. This overloaded version differs only in that it takes a pointer argument for the <code>numberOfBuffers</code> parameter and returns the value used by the audio device (which may be different from that requested). Note that the <code>numberofBuffers</code> parameter is not used with the Linux Jack, Macintosh CoreAudio, and Windows ASIO APIs.    </td>
334   </tr>
335 </table>
336 <a class="anchor" name="a3"></a><!-- doxytag: member="RtAudio::~RtAudio" ref="a3" args="()" --><p>
337 <table class="mdTable" cellpadding="2" cellspacing="0">
338   <tr>
339     <td class="mdRow">
340       <table cellpadding="0" cellspacing="0" border="0">
341         <tr>
342           <td class="md" nowrap valign="top">RtAudio::~RtAudio           </td>
343           <td class="md" valign="top">(&nbsp;</td>
344           <td class="mdname1" valign="top" nowrap>          </td>
345           <td class="md" valign="top">&nbsp;)&nbsp;</td>
346           <td class="md" nowrap></td>
347         </tr>
348       </table>
349     </td>
350   </tr>
351 </table>
352 <table cellspacing="5" cellpadding="0" border="0">
353   <tr>
354     <td>
355       &nbsp;
356     </td>
357     <td>
358
359 <p>
360 The destructor. 
361 <p>
362 Stops and closes an open stream and devices and deallocates buffer and structure memory.    </td>
363   </tr>
364 </table>
365 <hr><h2>Member Function Documentation</h2>
366 <a class="anchor" name="a4"></a><!-- doxytag: member="RtAudio::openStream" ref="a4" args="(int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers)" --><p>
367 <table class="mdTable" cellpadding="2" cellspacing="0">
368   <tr>
369     <td class="mdRow">
370       <table cellpadding="0" cellspacing="0" border="0">
371         <tr>
372           <td class="md" nowrap valign="top">void RtAudio::openStream           </td>
373           <td class="md" valign="top">(&nbsp;</td>
374           <td class="md" nowrap valign="top">int&nbsp;</td>
375           <td class="mdname" nowrap> <em>outputDevice</em>, </td>
376         </tr>
377         <tr>
378           <td class="md" nowrap align="right"></td>
379           <td class="md"></td>
380           <td class="md" nowrap>int&nbsp;</td>
381           <td class="mdname" nowrap> <em>outputChannels</em>, </td>
382         </tr>
383         <tr>
384           <td class="md" nowrap align="right"></td>
385           <td class="md"></td>
386           <td class="md" nowrap>int&nbsp;</td>
387           <td class="mdname" nowrap> <em>inputDevice</em>, </td>
388         </tr>
389         <tr>
390           <td class="md" nowrap align="right"></td>
391           <td class="md"></td>
392           <td class="md" nowrap>int&nbsp;</td>
393           <td class="mdname" nowrap> <em>inputChannels</em>, </td>
394         </tr>
395         <tr>
396           <td class="md" nowrap align="right"></td>
397           <td class="md"></td>
398           <td class="md" nowrap>RtAudioFormat&nbsp;</td>
399           <td class="mdname" nowrap> <em>format</em>, </td>
400         </tr>
401         <tr>
402           <td class="md" nowrap align="right"></td>
403           <td class="md"></td>
404           <td class="md" nowrap>int&nbsp;</td>
405           <td class="mdname" nowrap> <em>sampleRate</em>, </td>
406         </tr>
407         <tr>
408           <td class="md" nowrap align="right"></td>
409           <td class="md"></td>
410           <td class="md" nowrap>int *&nbsp;</td>
411           <td class="mdname" nowrap> <em>bufferSize</em>, </td>
412         </tr>
413         <tr>
414           <td class="md" nowrap align="right"></td>
415           <td class="md"></td>
416           <td class="md" nowrap>int&nbsp;</td>
417           <td class="mdname" nowrap> <em>numberOfBuffers</em></td>
418         </tr>
419         <tr>
420           <td class="md"></td>
421           <td class="md">)&nbsp;</td>
422           <td class="md" colspan="2"></td>
423         </tr>
424       </table>
425     </td>
426   </tr>
427 </table>
428 <table cellspacing="5" cellpadding="0" border="0">
429   <tr>
430     <td>
431       &nbsp;
432     </td>
433     <td>
434
435 <p>
436 A public method for opening a stream with the specified parameters. 
437 <p>
438 An <a class="el" href="classRtError.html">RtError</a> is thrown if a stream cannot be opened.<p>
439 <dl compact><dt><b>Parameters:</b></dt><dd>
440   <table border="0" cellspacing="2" cellpadding="0">
441     <tr><td valign="top"></td><td valign="top"><em>outputDevice,:</em>&nbsp;</td><td>If equal to 0, the default or first device found meeting the given parameters is opened. Otherwise, the device number should correspond to one of those enumerated via the <a class="el" href="classRtAudio.html#a9">getDeviceInfo()</a> method. </td></tr>
442     <tr><td valign="top"></td><td valign="top"><em>outputChannels,:</em>&nbsp;</td><td>The desired number of output channels. If equal to zero, the outputDevice identifier is ignored. </td></tr>
443     <tr><td valign="top"></td><td valign="top"><em>inputDevice,:</em>&nbsp;</td><td>If equal to 0, the default or first device found meeting the given parameters is opened. Otherwise, the device number should correspond to one of those enumerated via the <a class="el" href="classRtAudio.html#a9">getDeviceInfo()</a> method. </td></tr>
444     <tr><td valign="top"></td><td valign="top"><em>inputChannels,:</em>&nbsp;</td><td>The desired number of input channels. If equal to zero, the inputDevice identifier is ignored. </td></tr>
445     <tr><td valign="top"></td><td valign="top"><em>format,:</em>&nbsp;</td><td>An RtAudioFormat specifying the desired sample data format. </td></tr>
446     <tr><td valign="top"></td><td valign="top"><em>sampleRate,:</em>&nbsp;</td><td>The desired sample rate (sample frames per second). </td></tr>
447     <tr><td valign="top"></td><td valign="top"><em>*bufferSize,:</em>&nbsp;</td><td>A pointer value indicating the desired internal buffer size in sample frames. The actual value used by the device is returned via the same pointer. A value of zero can be specified, in which case the lowest allowable value is determined. </td></tr>
448     <tr><td valign="top"></td><td valign="top"><em>numberOfBuffers,:</em>&nbsp;</td><td>A value which can be used to help control device latency. More buffers typically result in more robust performance, though at a cost of greater latency. A value of zero can be specified, in which case the lowest allowable value is used.</td></tr>
449   </table>
450 </dl>
451     </td>
452   </tr>
453 </table>
454 <a class="anchor" name="a5"></a><!-- doxytag: member="RtAudio::openStream" ref="a5" args="(int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int *numberOfBuffers)" --><p>
455 <table class="mdTable" cellpadding="2" cellspacing="0">
456   <tr>
457     <td class="mdRow">
458       <table cellpadding="0" cellspacing="0" border="0">
459         <tr>
460           <td class="md" nowrap valign="top">void RtAudio::openStream           </td>
461           <td class="md" valign="top">(&nbsp;</td>
462           <td class="md" nowrap valign="top">int&nbsp;</td>
463           <td class="mdname" nowrap> <em>outputDevice</em>, </td>
464         </tr>
465         <tr>
466           <td class="md" nowrap align="right"></td>
467           <td class="md"></td>
468           <td class="md" nowrap>int&nbsp;</td>
469           <td class="mdname" nowrap> <em>outputChannels</em>, </td>
470         </tr>
471         <tr>
472           <td class="md" nowrap align="right"></td>
473           <td class="md"></td>
474           <td class="md" nowrap>int&nbsp;</td>
475           <td class="mdname" nowrap> <em>inputDevice</em>, </td>
476         </tr>
477         <tr>
478           <td class="md" nowrap align="right"></td>
479           <td class="md"></td>
480           <td class="md" nowrap>int&nbsp;</td>
481           <td class="mdname" nowrap> <em>inputChannels</em>, </td>
482         </tr>
483         <tr>
484           <td class="md" nowrap align="right"></td>
485           <td class="md"></td>
486           <td class="md" nowrap>RtAudioFormat&nbsp;</td>
487           <td class="mdname" nowrap> <em>format</em>, </td>
488         </tr>
489         <tr>
490           <td class="md" nowrap align="right"></td>
491           <td class="md"></td>
492           <td class="md" nowrap>int&nbsp;</td>
493           <td class="mdname" nowrap> <em>sampleRate</em>, </td>
494         </tr>
495         <tr>
496           <td class="md" nowrap align="right"></td>
497           <td class="md"></td>
498           <td class="md" nowrap>int *&nbsp;</td>
499           <td class="mdname" nowrap> <em>bufferSize</em>, </td>
500         </tr>
501         <tr>
502           <td class="md" nowrap align="right"></td>
503           <td class="md"></td>
504           <td class="md" nowrap>int *&nbsp;</td>
505           <td class="mdname" nowrap> <em>numberOfBuffers</em></td>
506         </tr>
507         <tr>
508           <td class="md"></td>
509           <td class="md">)&nbsp;</td>
510           <td class="md" colspan="2"></td>
511         </tr>
512       </table>
513     </td>
514   </tr>
515 </table>
516 <table cellspacing="5" cellpadding="0" border="0">
517   <tr>
518     <td>
519       &nbsp;
520     </td>
521     <td>
522
523 <p>
524 A public method for opening a stream and also returning <code>numberOfBuffers</code> parameter via pointer argument. 
525 <p>
526 See the previous function call for details. This overloaded version differs only in that it takes a pointer argument for the <code>numberOfBuffers</code> parameter and returns the value used by the audio device (which may be different from that requested). Note that the <code>numberofBuffers</code> parameter is not used with the Linux Jack, Macintosh CoreAudio, and Windows ASIO APIs.    </td>
527   </tr>
528 </table>
529 <a class="anchor" name="a6"></a><!-- doxytag: member="RtAudio::setStreamCallback" ref="a6" args="(RtAudioCallback callback, void *userData)" --><p>
530 <table class="mdTable" cellpadding="2" cellspacing="0">
531   <tr>
532     <td class="mdRow">
533       <table cellpadding="0" cellspacing="0" border="0">
534         <tr>
535           <td class="md" nowrap valign="top">void RtAudio::setStreamCallback           </td>
536           <td class="md" valign="top">(&nbsp;</td>
537           <td class="md" nowrap valign="top">RtAudioCallback&nbsp;</td>
538           <td class="mdname" nowrap> <em>callback</em>, </td>
539         </tr>
540         <tr>
541           <td class="md" nowrap align="right"></td>
542           <td class="md"></td>
543           <td class="md" nowrap>void *&nbsp;</td>
544           <td class="mdname" nowrap> <em>userData</em></td>
545         </tr>
546         <tr>
547           <td class="md"></td>
548           <td class="md">)&nbsp;</td>
549           <td class="md" colspan="2"><code> [inline]</code></td>
550         </tr>
551       </table>
552     </td>
553   </tr>
554 </table>
555 <table cellspacing="5" cellpadding="0" border="0">
556   <tr>
557     <td>
558       &nbsp;
559     </td>
560     <td>
561
562 <p>
563 A public method which sets a user-defined callback function for a given stream. 
564 <p>
565 This method assigns a callback function to a previously opened stream for non-blocking stream functionality. A separate process is initiated, though the user function is called only when the stream is "running" (between calls to the <a class="el" href="classRtAudio.html#a13">startStream()</a> and <a class="el" href="classRtAudio.html#a14">stopStream()</a> methods, respectively). The callback process remains active for the duration of the stream and is automatically shutdown when the stream is closed (via the <a class="el" href="classRtAudio.html#a12">closeStream()</a> method or by object destruction). The callback process can also be shutdown and the user function de-referenced through an explicit call to the <a class="el" href="classRtAudio.html#a7">cancelStreamCallback()</a> method. Note that the stream can use only blocking or callback functionality at a particular time, though it is possible to alternate modes on the same stream through the use of the <a class="el" href="classRtAudio.html#a6">setStreamCallback()</a> and <a class="el" href="classRtAudio.html#a7">cancelStreamCallback()</a> methods (the blocking <a class="el" href="classRtAudio.html#a11">tickStream()</a> method can be used before a callback is set and/or after a callback is cancelled). An <a class="el" href="classRtError.html">RtError</a> will be thrown if called when no stream is open or a thread errors occurs.    </td>
566   </tr>
567 </table>
568 <a class="anchor" name="a7"></a><!-- doxytag: member="RtAudio::cancelStreamCallback" ref="a7" args="()" --><p>
569 <table class="mdTable" cellpadding="2" cellspacing="0">
570   <tr>
571     <td class="mdRow">
572       <table cellpadding="0" cellspacing="0" border="0">
573         <tr>
574           <td class="md" nowrap valign="top">void RtAudio::cancelStreamCallback           </td>
575           <td class="md" valign="top">(&nbsp;</td>
576           <td class="mdname1" valign="top" nowrap>          </td>
577           <td class="md" valign="top">&nbsp;)&nbsp;</td>
578           <td class="md" nowrap><code> [inline]</code></td>
579         </tr>
580       </table>
581     </td>
582   </tr>
583 </table>
584 <table cellspacing="5" cellpadding="0" border="0">
585   <tr>
586     <td>
587       &nbsp;
588     </td>
589     <td>
590
591 <p>
592 A public method which cancels a callback process and function for the stream. 
593 <p>
594 This method shuts down a callback process and de-references the user function for the stream. Callback functionality can subsequently be restarted on the stream via the <a class="el" href="classRtAudio.html#a6">setStreamCallback()</a> method. An <a class="el" href="classRtError.html">RtError</a> will be thrown if called when no stream is open.    </td>
595   </tr>
596 </table>
597 <a class="anchor" name="a9"></a><!-- doxytag: member="RtAudio::getDeviceInfo" ref="a9" args="(int device)" --><p>
598 <table class="mdTable" cellpadding="2" cellspacing="0">
599   <tr>
600     <td class="mdRow">
601       <table cellpadding="0" cellspacing="0" border="0">
602         <tr>
603           <td class="md" nowrap valign="top"><a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> RtAudio::getDeviceInfo           </td>
604           <td class="md" valign="top">(&nbsp;</td>
605           <td class="md" nowrap valign="top">int&nbsp;</td>
606           <td class="mdname1" valign="top" nowrap> <em>device</em>          </td>
607           <td class="md" valign="top">&nbsp;)&nbsp;</td>
608           <td class="md" nowrap><code> [inline]</code></td>
609         </tr>
610       </table>
611     </td>
612   </tr>
613 </table>
614 <table cellspacing="5" cellpadding="0" border="0">
615   <tr>
616     <td>
617       &nbsp;
618     </td>
619     <td>
620
621 <p>
622 Return an <a class="el" href="structRtAudioDeviceInfo.html">RtAudioDeviceInfo</a> structure for a specified device number. 
623 <p>
624 Any device integer between 1 and <a class="el" href="classRtAudio.html#a8">getDeviceCount()</a> is valid. If a device is busy or otherwise unavailable, the structure member "probed" will have a value of "false" and all other members are undefined. If the specified device is the current default input or output device, the "isDefault" member will have a value of "true". An <a class="el" href="classRtError.html">RtError</a> will be thrown for an invalid device argument.    </td>
625   </tr>
626 </table>
627 <a class="anchor" name="a10"></a><!-- doxytag: member="RtAudio::getStreamBuffer" ref="a10" args="()" --><p>
628 <table class="mdTable" cellpadding="2" cellspacing="0">
629   <tr>
630     <td class="mdRow">
631       <table cellpadding="0" cellspacing="0" border="0">
632         <tr>
633           <td class="md" nowrap valign="top">char* const RtAudio::getStreamBuffer           </td>
634           <td class="md" valign="top">(&nbsp;</td>
635           <td class="mdname1" valign="top" nowrap>          </td>
636           <td class="md" valign="top">&nbsp;)&nbsp;</td>
637           <td class="md" nowrap><code> [inline]</code></td>
638         </tr>
639       </table>
640     </td>
641   </tr>
642 </table>
643 <table cellspacing="5" cellpadding="0" border="0">
644   <tr>
645     <td>
646       &nbsp;
647     </td>
648     <td>
649
650 <p>
651 A public method which returns a pointer to the buffer for an open stream. 
652 <p>
653 The user should fill and/or read the buffer data in interleaved format and then call the <a class="el" href="classRtAudio.html#a11">tickStream()</a> method. An <a class="el" href="classRtError.html">RtError</a> will be thrown if called when no stream is open.    </td>
654   </tr>
655 </table>
656 <a class="anchor" name="a11"></a><!-- doxytag: member="RtAudio::tickStream" ref="a11" args="()" --><p>
657 <table class="mdTable" cellpadding="2" cellspacing="0">
658   <tr>
659     <td class="mdRow">
660       <table cellpadding="0" cellspacing="0" border="0">
661         <tr>
662           <td class="md" nowrap valign="top">void RtAudio::tickStream           </td>
663           <td class="md" valign="top">(&nbsp;</td>
664           <td class="mdname1" valign="top" nowrap>          </td>
665           <td class="md" valign="top">&nbsp;)&nbsp;</td>
666           <td class="md" nowrap><code> [inline]</code></td>
667         </tr>
668       </table>
669     </td>
670   </tr>
671 </table>
672 <table cellspacing="5" cellpadding="0" border="0">
673   <tr>
674     <td>
675       &nbsp;
676     </td>
677     <td>
678
679 <p>
680 Public method used to trigger processing of input/output data for a stream. 
681 <p>
682 This method blocks until all buffer data is read/written. An <a class="el" href="classRtError.html">RtError</a> will be thrown if a driver error occurs or if called when no stream is open.    </td>
683   </tr>
684 </table>
685 <a class="anchor" name="a12"></a><!-- doxytag: member="RtAudio::closeStream" ref="a12" args="()" --><p>
686 <table class="mdTable" cellpadding="2" cellspacing="0">
687   <tr>
688     <td class="mdRow">
689       <table cellpadding="0" cellspacing="0" border="0">
690         <tr>
691           <td class="md" nowrap valign="top">void RtAudio::closeStream           </td>
692           <td class="md" valign="top">(&nbsp;</td>
693           <td class="mdname1" valign="top" nowrap>          </td>
694           <td class="md" valign="top">&nbsp;)&nbsp;</td>
695           <td class="md" nowrap><code> [inline]</code></td>
696         </tr>
697       </table>
698     </td>
699   </tr>
700 </table>
701 <table cellspacing="5" cellpadding="0" border="0">
702   <tr>
703     <td>
704       &nbsp;
705     </td>
706     <td>
707
708 <p>
709 Public method which closes a stream and frees any associated buffers. 
710 <p>
711 If a stream is not open, this method issues a warning and returns (an <a class="el" href="classRtError.html">RtError</a> is not thrown).    </td>
712   </tr>
713 </table>
714 <a class="anchor" name="a13"></a><!-- doxytag: member="RtAudio::startStream" ref="a13" args="()" --><p>
715 <table class="mdTable" cellpadding="2" cellspacing="0">
716   <tr>
717     <td class="mdRow">
718       <table cellpadding="0" cellspacing="0" border="0">
719         <tr>
720           <td class="md" nowrap valign="top">void RtAudio::startStream           </td>
721           <td class="md" valign="top">(&nbsp;</td>
722           <td class="mdname1" valign="top" nowrap>          </td>
723           <td class="md" valign="top">&nbsp;)&nbsp;</td>
724           <td class="md" nowrap><code> [inline]</code></td>
725         </tr>
726       </table>
727     </td>
728   </tr>
729 </table>
730 <table cellspacing="5" cellpadding="0" border="0">
731   <tr>
732     <td>
733       &nbsp;
734     </td>
735     <td>
736
737 <p>
738 Public method which starts a stream. 
739 <p>
740 An <a class="el" href="classRtError.html">RtError</a> will be thrown if a driver error occurs or if called when no stream is open.    </td>
741   </tr>
742 </table>
743 <a class="anchor" name="a14"></a><!-- doxytag: member="RtAudio::stopStream" ref="a14" args="()" --><p>
744 <table class="mdTable" cellpadding="2" cellspacing="0">
745   <tr>
746     <td class="mdRow">
747       <table cellpadding="0" cellspacing="0" border="0">
748         <tr>
749           <td class="md" nowrap valign="top">void RtAudio::stopStream           </td>
750           <td class="md" valign="top">(&nbsp;</td>
751           <td class="mdname1" valign="top" nowrap>          </td>
752           <td class="md" valign="top">&nbsp;)&nbsp;</td>
753           <td class="md" nowrap><code> [inline]</code></td>
754         </tr>
755       </table>
756     </td>
757   </tr>
758 </table>
759 <table cellspacing="5" cellpadding="0" border="0">
760   <tr>
761     <td>
762       &nbsp;
763     </td>
764     <td>
765
766 <p>
767 Stop a stream, allowing any samples remaining in the queue to be played out and/or read in. 
768 <p>
769 An <a class="el" href="classRtError.html">RtError</a> will be thrown if a driver error occurs or if called when no stream is open.    </td>
770   </tr>
771 </table>
772 <a class="anchor" name="a15"></a><!-- doxytag: member="RtAudio::abortStream" ref="a15" args="()" --><p>
773 <table class="mdTable" cellpadding="2" cellspacing="0">
774   <tr>
775     <td class="mdRow">
776       <table cellpadding="0" cellspacing="0" border="0">
777         <tr>
778           <td class="md" nowrap valign="top">void RtAudio::abortStream           </td>
779           <td class="md" valign="top">(&nbsp;</td>
780           <td class="mdname1" valign="top" nowrap>          </td>
781           <td class="md" valign="top">&nbsp;)&nbsp;</td>
782           <td class="md" nowrap><code> [inline]</code></td>
783         </tr>
784       </table>
785     </td>
786   </tr>
787 </table>
788 <table cellspacing="5" cellpadding="0" border="0">
789   <tr>
790     <td>
791       &nbsp;
792     </td>
793     <td>
794
795 <p>
796 Stop a stream, discarding any samples remaining in the input/output queue. 
797 <p>
798 An <a class="el" href="classRtError.html">RtError</a> will be thrown if a driver error occurs or if called when no stream is open.    </td>
799   </tr>
800 </table>
801 <hr>The documentation for this class was generated from the following file:<ul>
802 <li><a class="el" href="RtAudio_8h-source.html">RtAudio.h</a></ul>
803 <HR>
804
805 <table><tr><td><img src="../images/mcgill.gif" width=165></td>
806   <td>&copy;2001-2005 Gary P. Scavone, McGill University. All Rights Reserved.<br>
807   Maintained by Gary P. Scavone, <a href="mailto:gary@music.mcgill.ca">gary@music.mcgill.ca</a></td></tr>
808 </table>
809
810 </BODY>
811 </HTML>