Release 4.0.7 tarball
[rtaudio.git] / doc / html / RtAudio_8h.html
1 <HTML>
2 <HEAD>
3 <TITLE>The RtAudio Home Page</TITLE>
4 <LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
5 <LINK REL="SHORTCUT ICON" HREF="http://www.music.mcgill.ca/~gary/favicon.ico">
6 </HEAD>
7 <BODY BGCOLOR="#FFFFFF">
8 <CENTER>
9 <a class="qindex" href="index.html">Home</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>
10 <HR>
11 <!-- Generated by Doxygen 1.6.2 -->
12 <div class="contents">
13 <h1>RtAudio.h File Reference</h1><code>#include &lt;string&gt;</code><br/>
14 <code>#include &lt;vector&gt;</code><br/>
15 <code>#include &quot;RtError.h&quot;</code><br/>
16 <code>#include &lt;sstream&gt;</code><br/>
17
18 <p><a href="RtAudio_8h_source.html">Go to the source code of this file.</a></p>
19 <table border="0" cellpadding="0" cellspacing="0">
20 <tr><td colspan="2"><h2>Classes</h2></td></tr>
21 <tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classRtAudio.html">RtAudio</a></td></tr>
22 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Realtime audio i/o C++ classes.  <a href="classRtAudio.html#_details">More...</a><br/></td></tr>
23 <tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structRtAudio_1_1DeviceInfo.html">RtAudio::DeviceInfo</a></td></tr>
24 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The public device information structure for returning queried values.  <a href="structRtAudio_1_1DeviceInfo.html#_details">More...</a><br/></td></tr>
25 <tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structRtAudio_1_1StreamParameters.html">RtAudio::StreamParameters</a></td></tr>
26 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The structure for specifying input or ouput stream parameters.  <a href="structRtAudio_1_1StreamParameters.html#_details">More...</a><br/></td></tr>
27 <tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structRtAudio_1_1StreamOptions.html">RtAudio::StreamOptions</a></td></tr>
28 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The structure for specifying stream options.  <a href="structRtAudio_1_1StreamOptions.html#_details">More...</a><br/></td></tr>
29 <tr><td colspan="2"><h2>Typedefs</h2></td></tr>
30 <tr><td class="memItemLeft" align="right" valign="top">typedef unsigned long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="RtAudio_8h.html#aafca92882d25915560018873221e44b8">RtAudioFormat</a></td></tr>
31 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> data format type.  <a href="#aafca92882d25915560018873221e44b8"></a><br/></td></tr>
32 <tr><td class="memItemLeft" align="right" valign="top">typedef unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="RtAudio_8h.html#a2c0f59b200dcec4d4e760f9166b29c41">RtAudioStreamFlags</a></td></tr>
33 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> stream option flags.  <a href="#a2c0f59b200dcec4d4e760f9166b29c41"></a><br/></td></tr>
34 <tr><td class="memItemLeft" align="right" valign="top">typedef unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="RtAudio_8h.html#a80e306d363583da3b0a1b65d9b57c806">RtAudioStreamStatus</a></td></tr>
35 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> stream status (over- or underflow) flags.  <a href="#a80e306d363583da3b0a1b65d9b57c806"></a><br/></td></tr>
36 <tr><td class="memItemLeft" align="right" valign="top">typedef int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="RtAudio_8h.html#a112c7b7e25a974977f6fc094cef1a31f">RtAudioCallback</a> )(void *outputBuffer, void *inputBuffer, unsigned int nFrames, double streamTime, <a class="el" href="RtAudio_8h.html#a80e306d363583da3b0a1b65d9b57c806">RtAudioStreamStatus</a> status, void *userData)</td></tr>
37 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight"><a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> callback function prototype.  <a href="#a112c7b7e25a974977f6fc094cef1a31f"></a><br/></td></tr>
38 </table>
39 <hr/><a name="_details"></a><h2>Detailed Description</h2>
40 <hr/><h2>Typedef Documentation</h2>
41 <a class="anchor" id="aafca92882d25915560018873221e44b8"></a><!-- doxytag: member="RtAudio.h::RtAudioFormat" ref="aafca92882d25915560018873221e44b8" args="" -->
42 <div class="memitem">
43 <div class="memproto">
44       <table class="memname">
45         <tr>
46           <td class="memname">typedef unsigned long <a class="el" href="RtAudio_8h.html#aafca92882d25915560018873221e44b8">RtAudioFormat</a></td>
47         </tr>
48       </table>
49 </div>
50 <div class="memdoc">
51
52 <p><a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> data format type. </p>
53 <p>Support for signed integers and floats. Audio data fed to/from an <a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> stream is assumed to ALWAYS be in host byte order. The internal routines will automatically take care of any necessary byte-swapping between the host format and the soundcard. Thus, endian-ness is not a concern in the following format definitions.</p>
54 <ul>
55 <li><em>RTAUDIO_SINT8:</em> 8-bit signed integer.</li>
56 <li><em>RTAUDIO_SINT16:</em> 16-bit signed integer.</li>
57 <li><em>RTAUDIO_SINT24:</em> Upper 3 bytes of 32-bit signed integer.</li>
58 <li><em>RTAUDIO_SINT32:</em> 32-bit signed integer.</li>
59 <li><em>RTAUDIO_FLOAT32:</em> Normalized between plus/minus 1.0.</li>
60 <li><em>RTAUDIO_FLOAT64:</em> Normalized between plus/minus 1.0. </li>
61 </ul>
62
63 </div>
64 </div>
65 <a class="anchor" id="a2c0f59b200dcec4d4e760f9166b29c41"></a><!-- doxytag: member="RtAudio.h::RtAudioStreamFlags" ref="a2c0f59b200dcec4d4e760f9166b29c41" args="" -->
66 <div class="memitem">
67 <div class="memproto">
68       <table class="memname">
69         <tr>
70           <td class="memname">typedef unsigned long <a class="el" href="RtAudio_8h.html#a2c0f59b200dcec4d4e760f9166b29c41">RtAudioStreamFlags</a></td>
71         </tr>
72       </table>
73 </div>
74 <div class="memdoc">
75
76 <p><a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> stream option flags. </p>
77 <p>The following flags can be OR'ed together to allow a client to make changes to the default stream behavior:</p>
78 <ul>
79 <li><em>RTAUDIO_NONINTERLEAVED:</em> Use non-interleaved buffers (default = interleaved).</li>
80 <li><em>RTAUDIO_MINIMIZE_LATENCY:</em> Attempt to set stream parameters for lowest possible latency.</li>
81 <li><em>RTAUDIO_HOG_DEVICE:</em> Attempt grab device for exclusive use.</li>
82 </ul>
83 <p>By default, <a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> streams pass and receive audio data from the client in an interleaved format. By passing the RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio data will instead be presented in non-interleaved buffers. In this case, each buffer argument in the RtAudioCallback function will point to a single array of data, with <code>nFrames</code> samples for each channel concatenated back-to-back. For example, the first sample of data for the second channel would be located at index <code>nFrames</code> (assuming the <code>buffer</code> pointer was recast to the correct data type for the stream).</p>
84 <p>Certain audio APIs offer a number of parameters that influence the I/O latency of a stream. By default, <a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> will attempt to set these parameters internally for robust (glitch-free) performance (though some APIs, like Windows Direct Sound, make this difficult). By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream() function, internal stream settings will be influenced in an attempt to minimize stream latency, though possibly at the expense of stream performance.</p>
85 <p>If the RTAUDIO_HOG_DEVICE flag is set, <a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> will attempt to open the input and/or output stream device(s) for exclusive use. Note that this is not possible with all supported audio APIs.</p>
86 <p>If the RTAUDIO_SCHEDULE_REALTIME flag is set, <a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> will attempt to select realtime scheduling (round-robin) for the callback thread. </p>
87
88 </div>
89 </div>
90 <a class="anchor" id="a80e306d363583da3b0a1b65d9b57c806"></a><!-- doxytag: member="RtAudio.h::RtAudioStreamStatus" ref="a80e306d363583da3b0a1b65d9b57c806" args="" -->
91 <div class="memitem">
92 <div class="memproto">
93       <table class="memname">
94         <tr>
95           <td class="memname">typedef unsigned long <a class="el" href="RtAudio_8h.html#a80e306d363583da3b0a1b65d9b57c806">RtAudioStreamStatus</a></td>
96         </tr>
97       </table>
98 </div>
99 <div class="memdoc">
100
101 <p><a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> stream status (over- or underflow) flags. </p>
102 <p>Notification of a stream over- or underflow is indicated by a non-zero stream <code>status</code> argument in the RtAudioCallback function. The stream status can be one of the following two options, depending on whether the stream is open for output and/or input:</p>
103 <ul>
104 <li><em>RTAUDIO_INPUT_OVERFLOW:</em> Input data was discarded because of an overflow condition at the driver.</li>
105 <li><em>RTAUDIO_OUTPUT_UNDERFLOW:</em> The output buffer ran low, likely producing a break in the output sound. </li>
106 </ul>
107
108 </div>
109 </div>
110 <a class="anchor" id="a112c7b7e25a974977f6fc094cef1a31f"></a><!-- doxytag: member="RtAudio.h::RtAudioCallback" ref="a112c7b7e25a974977f6fc094cef1a31f" args=")(void *outputBuffer, void *inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status, void *userData)" -->
111 <div class="memitem">
112 <div class="memproto">
113       <table class="memname">
114         <tr>
115           <td class="memname">typedef int(* <a class="el" href="RtAudio_8h.html#a112c7b7e25a974977f6fc094cef1a31f">RtAudioCallback</a>)(void *outputBuffer, void *inputBuffer, unsigned int nFrames, double streamTime, <a class="el" href="RtAudio_8h.html#a80e306d363583da3b0a1b65d9b57c806">RtAudioStreamStatus</a> status, void *userData)</td>
116         </tr>
117       </table>
118 </div>
119 <div class="memdoc">
120
121 <p><a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> callback function prototype. </p>
122 <p>All <a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> clients must create a function of type RtAudioCallback to read and/or write data from/to the audio stream. When the underlying audio system is ready for new input or output data, this function will be invoked.</p>
123 <dl><dt><b>Parameters:</b></dt><dd>
124   <table border="0" cellspacing="2" cellpadding="0">
125     <tr><td valign="top"></td><td valign="top"><em>outputBuffer</em>&nbsp;</td><td>For output (or duplex) streams, the client should write <code>nFrames</code> of audio sample frames into this buffer. This argument should be recast to the datatype specified when the stream was opened. For input-only streams, this argument will be NULL.</td></tr>
126     <tr><td valign="top"></td><td valign="top"><em>inputBuffer</em>&nbsp;</td><td>For input (or duplex) streams, this buffer will hold <code>nFrames</code> of input audio sample frames. This argument should be recast to the datatype specified when the stream was opened. For output-only streams, this argument will be NULL.</td></tr>
127     <tr><td valign="top"></td><td valign="top"><em>nFrames</em>&nbsp;</td><td>The number of sample frames of input or output data in the buffers. The actual buffer size in bytes is dependent on the data type and number of channels in use.</td></tr>
128     <tr><td valign="top"></td><td valign="top"><em>streamTime</em>&nbsp;</td><td>The number of seconds that have elapsed since the stream was started.</td></tr>
129     <tr><td valign="top"></td><td valign="top"><em>status</em>&nbsp;</td><td>If non-zero, this argument indicates a data overflow or underflow condition for the stream. The particular condition can be determined by comparison with the RtAudioStreamStatus flags.</td></tr>
130     <tr><td valign="top"></td><td valign="top"><em>userData</em>&nbsp;</td><td>A pointer to optional data provided by the client when opening the stream (default = NULL).</td></tr>
131   </table>
132   </dd>
133 </dl>
134 <p>To continue normal stream operation, the RtAudioCallback function should return a value of zero. To stop the stream and drain the output buffer, the function should return a value of one. To abort the stream immediately, the client should return a value of two. </p>
135
136 </div>
137 </div>
138 </div>
139 <HR>
140
141 <table><tr><td><img src="../images/mcgill.gif" width=165></td>
142   <td>&copy;2001-2010 Gary P. Scavone, McGill University. All Rights Reserved.<br>Maintained by <a href="http://www.music.mcgill.ca/~gary/">Gary P. Scavone</a>.</td></tr>
143 </table>
144
145 </BODY>
146 </HTML>