Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

642 lines
86KB

  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.5.8 -->
  12. <h1>RtAudio.h</h1><a href="RtAudio_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/************************************************************************/</span>
  13. <a name="l00039"></a>00039 <span class="comment">/************************************************************************/</span>
  14. <a name="l00040"></a>00040
  15. <a name="l00045"></a>00045 <span class="comment">// RtAudio: Version 4.0.6</span>
  16. <a name="l00046"></a>00046
  17. <a name="l00047"></a>00047 <span class="preprocessor">#ifndef __RTAUDIO_H</span>
  18. <a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#define __RTAUDIO_H</span>
  19. <a name="l00049"></a>00049 <span class="preprocessor"></span>
  20. <a name="l00050"></a>00050 <span class="preprocessor">#include &lt;string&gt;</span>
  21. <a name="l00051"></a>00051 <span class="preprocessor">#include &lt;vector&gt;</span>
  22. <a name="l00052"></a>00052 <span class="preprocessor">#include "RtError.h"</span>
  23. <a name="l00053"></a>00053
  24. <a name="l00070"></a><a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8">00070</a> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a>;
  25. <a name="l00071"></a>00071 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> RTAUDIO_SINT8 = 0x1; <span class="comment">// 8-bit signed integer.</span>
  26. <a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> RTAUDIO_SINT16 = 0x2; <span class="comment">// 16-bit signed integer.</span>
  27. <a name="l00073"></a>00073 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> RTAUDIO_SINT24 = 0x4; <span class="comment">// Lower 3 bytes of 32-bit signed integer.</span>
  28. <a name="l00074"></a>00074 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> RTAUDIO_SINT32 = 0x8; <span class="comment">// 32-bit signed integer.</span>
  29. <a name="l00075"></a>00075 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> RTAUDIO_FLOAT32 = 0x10; <span class="comment">// Normalized between plus/minus 1.0.</span>
  30. <a name="l00076"></a>00076 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> RTAUDIO_FLOAT64 = 0x20; <span class="comment">// Normalized between plus/minus 1.0.</span>
  31. <a name="l00077"></a>00077
  32. <a name="l00115"></a><a class="code" href="RtAudio_8h.html#2c0f59b200dcec4d4e760f9166b29c41">00115</a> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="RtAudio_8h.html#2c0f59b200dcec4d4e760f9166b29c41" title="RtAudio stream option flags.">RtAudioStreamFlags</a>;
  33. <a name="l00116"></a>00116 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#2c0f59b200dcec4d4e760f9166b29c41" title="RtAudio stream option flags.">RtAudioStreamFlags</a> RTAUDIO_NONINTERLEAVED = 0x1; <span class="comment">// Use non-interleaved buffers (default = interleaved).</span>
  34. <a name="l00117"></a>00117 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#2c0f59b200dcec4d4e760f9166b29c41" title="RtAudio stream option flags.">RtAudioStreamFlags</a> RTAUDIO_MINIMIZE_LATENCY = 0x2; <span class="comment">// Attempt to set stream parameters for lowest possible latency.</span>
  35. <a name="l00118"></a>00118 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#2c0f59b200dcec4d4e760f9166b29c41" title="RtAudio stream option flags.">RtAudioStreamFlags</a> RTAUDIO_HOG_DEVICE = 0x4; <span class="comment">// Attempt grab device and prevent use by others.</span>
  36. <a name="l00119"></a>00119 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#2c0f59b200dcec4d4e760f9166b29c41" title="RtAudio stream option flags.">RtAudioStreamFlags</a> RTAUDIO_SCHEDULE_REALTIME = 0x8; <span class="comment">// Try to select realtime scheduling for callback thread.</span>
  37. <a name="l00120"></a>00120
  38. <a name="l00132"></a><a class="code" href="RtAudio_8h.html#80e306d363583da3b0a1b65d9b57c806">00132</a> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="RtAudio_8h.html#80e306d363583da3b0a1b65d9b57c806" title="RtAudio stream status (over- or underflow) flags.">RtAudioStreamStatus</a>;
  39. <a name="l00133"></a>00133 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#80e306d363583da3b0a1b65d9b57c806" title="RtAudio stream status (over- or underflow) flags.">RtAudioStreamStatus</a> RTAUDIO_INPUT_OVERFLOW = 0x1; <span class="comment">// Input data was discarded because of an overflow condition at the driver.</span>
  40. <a name="l00134"></a>00134 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="RtAudio_8h.html#80e306d363583da3b0a1b65d9b57c806" title="RtAudio stream status (over- or underflow) flags.">RtAudioStreamStatus</a> RTAUDIO_OUTPUT_UNDERFLOW = 0x2; <span class="comment">// The output buffer ran low, likely causing a gap in the output sound.</span>
  41. <a name="l00135"></a>00135
  42. <a name="l00137"></a>00137
  43. <a name="l00175"></a><a class="code" href="RtAudio_8h.html#112c7b7e25a974977f6fc094cef1a31f">00175</a> <span class="keyword">typedef</span> int (*<a class="code" href="RtAudio_8h.html#112c7b7e25a974977f6fc094cef1a31f" title="RtAudio callback function prototype.">RtAudioCallback</a>)( <span class="keywordtype">void</span> *outputBuffer, <span class="keywordtype">void</span> *inputBuffer,
  44. <a name="l00176"></a>00176 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nFrames,
  45. <a name="l00177"></a>00177 <span class="keywordtype">double</span> streamTime,
  46. <a name="l00178"></a>00178 <a class="code" href="RtAudio_8h.html#80e306d363583da3b0a1b65d9b57c806" title="RtAudio stream status (over- or underflow) flags.">RtAudioStreamStatus</a> status,
  47. <a name="l00179"></a>00179 <span class="keywordtype">void</span> *userData );
  48. <a name="l00180"></a>00180
  49. <a name="l00181"></a>00181
  50. <a name="l00182"></a>00182 <span class="comment">// **************************************************************** //</span>
  51. <a name="l00183"></a>00183 <span class="comment">//</span>
  52. <a name="l00184"></a>00184 <span class="comment">// RtAudio class declaration.</span>
  53. <a name="l00185"></a>00185 <span class="comment">//</span>
  54. <a name="l00186"></a>00186 <span class="comment">// RtAudio is a "controller" used to select an available audio i/o</span>
  55. <a name="l00187"></a>00187 <span class="comment">// interface. It presents a common API for the user to call but all</span>
  56. <a name="l00188"></a>00188 <span class="comment">// functionality is implemented by the class RtApi and its</span>
  57. <a name="l00189"></a>00189 <span class="comment">// subclasses. RtAudio creates an instance of an RtApi subclass</span>
  58. <a name="l00190"></a>00190 <span class="comment">// based on the user's API choice. If no choice is made, RtAudio</span>
  59. <a name="l00191"></a>00191 <span class="comment">// attempts to make a "logical" API selection.</span>
  60. <a name="l00192"></a>00192 <span class="comment">//</span>
  61. <a name="l00193"></a>00193 <span class="comment">// **************************************************************** //</span>
  62. <a name="l00194"></a>00194
  63. <a name="l00195"></a>00195 <span class="keyword">class </span>RtApi;
  64. <a name="l00196"></a>00196
  65. <a name="l00197"></a><a class="code" href="classRtAudio.html">00197</a> <span class="keyword">class </span><a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a>
  66. <a name="l00198"></a>00198 {
  67. <a name="l00199"></a>00199 <span class="keyword">public</span>:
  68. <a name="l00200"></a>00200
  69. <a name="l00202"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849">00202</a> <span class="keyword">enum</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">Api</a> {
  70. <a name="l00203"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849a49af3ac767106158bc6cad74fb214ae">00203</a> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849a49af3ac767106158bc6cad74fb214ae">UNSPECIFIED</a>,
  71. <a name="l00204"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849a7a2ba095c2806caa893b6fb8fc3a1a8">00204</a> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849a7a2ba095c2806caa893b6fb8fc3a1a8">LINUX_ALSA</a>,
  72. <a name="l00205"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d84939c84615e61de75e6a4e865596d62c82">00205</a> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d84939c84615e61de75e6a4e865596d62c82">LINUX_OSS</a>,
  73. <a name="l00206"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d8494767e17c6edfbd827f91763915df4105">00206</a> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d8494767e17c6edfbd827f91763915df4105">UNIX_JACK</a>,
  74. <a name="l00207"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d8499fec92b8272244a87a6a11a717bd662d">00207</a> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d8499fec92b8272244a87a6a11a717bd662d">MACOSX_CORE</a>,
  75. <a name="l00208"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849219517d1df90f94d07758481155bd469">00208</a> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849219517d1df90f94d07758481155bd469">WINDOWS_ASIO</a>,
  76. <a name="l00209"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d84928478830f42c2fd61e6c7ad498901931">00209</a> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d84928478830f42c2fd61e6c7ad498901931">WINDOWS_DS</a>,
  77. <a name="l00210"></a><a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849b06b8fd88bf18c9a2b8271f6961ae2d1">00210</a> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849b06b8fd88bf18c9a2b8271f6961ae2d1">RTAUDIO_DUMMY</a>
  78. <a name="l00211"></a>00211 };
  79. <a name="l00212"></a>00212
  80. <a name="l00214"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html">00214</a> <span class="keyword">struct </span><a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">DeviceInfo</a> {
  81. <a name="l00215"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#5bf008c629ef493c713ec870d0217407">00215</a> <span class="keywordtype">bool</span> <a class="code" href="structRtAudio_1_1DeviceInfo.html#5bf008c629ef493c713ec870d0217407">probed</a>;
  82. <a name="l00216"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#a0e2ea10c52c206c9e105ac76b01f194">00216</a> std::string <a class="code" href="structRtAudio_1_1DeviceInfo.html#a0e2ea10c52c206c9e105ac76b01f194">name</a>;
  83. <a name="l00217"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#185f8aac1095de4fbb6e0076875d24c4">00217</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structRtAudio_1_1DeviceInfo.html#185f8aac1095de4fbb6e0076875d24c4">outputChannels</a>;
  84. <a name="l00218"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#731b31adf84c550ab98329be1baa58b4">00218</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structRtAudio_1_1DeviceInfo.html#731b31adf84c550ab98329be1baa58b4">inputChannels</a>;
  85. <a name="l00219"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#ca6ecfb8b5b8c114c54809d8af50ee5b">00219</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structRtAudio_1_1DeviceInfo.html#ca6ecfb8b5b8c114c54809d8af50ee5b">duplexChannels</a>;
  86. <a name="l00220"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#af74fc23f451fdd22ed073a47f0db674">00220</a> <span class="keywordtype">bool</span> <a class="code" href="structRtAudio_1_1DeviceInfo.html#af74fc23f451fdd22ed073a47f0db674">isDefaultOutput</a>;
  87. <a name="l00221"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#a8b03618fa1d4c051f6add14bb031728">00221</a> <span class="keywordtype">bool</span> <a class="code" href="structRtAudio_1_1DeviceInfo.html#a8b03618fa1d4c051f6add14bb031728">isDefaultInput</a>;
  88. <a name="l00222"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#5b158efcbfbd30e7226df92d0109d475">00222</a> std::vector&lt;unsigned int&gt; <a class="code" href="structRtAudio_1_1DeviceInfo.html#5b158efcbfbd30e7226df92d0109d475">sampleRates</a>;
  89. <a name="l00223"></a><a class="code" href="structRtAudio_1_1DeviceInfo.html#97559ee4a1f2c8cfb765949e6193e1f4">00223</a> <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> <a class="code" href="structRtAudio_1_1DeviceInfo.html#97559ee4a1f2c8cfb765949e6193e1f4">nativeFormats</a>;
  90. <a name="l00225"></a>00225 <span class="comment">// Default constructor.</span>
  91. <a name="l00226"></a>00226 <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">DeviceInfo</a>()
  92. <a name="l00227"></a>00227 :<a class="code" href="structRtAudio_1_1DeviceInfo.html#5bf008c629ef493c713ec870d0217407">probed</a>(false), <a class="code" href="structRtAudio_1_1DeviceInfo.html#185f8aac1095de4fbb6e0076875d24c4">outputChannels</a>(0), <a class="code" href="structRtAudio_1_1DeviceInfo.html#731b31adf84c550ab98329be1baa58b4">inputChannels</a>(0), <a class="code" href="structRtAudio_1_1DeviceInfo.html#ca6ecfb8b5b8c114c54809d8af50ee5b">duplexChannels</a>(0),
  93. <a name="l00228"></a>00228 <a class="code" href="structRtAudio_1_1DeviceInfo.html#af74fc23f451fdd22ed073a47f0db674">isDefaultOutput</a>(false), <a class="code" href="structRtAudio_1_1DeviceInfo.html#a8b03618fa1d4c051f6add14bb031728">isDefaultInput</a>(false), <a class="code" href="structRtAudio_1_1DeviceInfo.html#97559ee4a1f2c8cfb765949e6193e1f4">nativeFormats</a>(0) {}
  94. <a name="l00229"></a>00229 };
  95. <a name="l00230"></a>00230
  96. <a name="l00232"></a><a class="code" href="structRtAudio_1_1StreamParameters.html">00232</a> <span class="keyword">struct </span><a class="code" href="structRtAudio_1_1StreamParameters.html" title="The structure for specifying input or ouput stream parameters.">StreamParameters</a> {
  97. <a name="l00233"></a><a class="code" href="structRtAudio_1_1StreamParameters.html#ffd27496c70c0986522056234c64e28e">00233</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structRtAudio_1_1StreamParameters.html#ffd27496c70c0986522056234c64e28e">deviceId</a>;
  98. <a name="l00234"></a><a class="code" href="structRtAudio_1_1StreamParameters.html#78798b65fada7941e1a7e47c11c9e627">00234</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structRtAudio_1_1StreamParameters.html#78798b65fada7941e1a7e47c11c9e627">nChannels</a>;
  99. <a name="l00235"></a><a class="code" href="structRtAudio_1_1StreamParameters.html#ddc8281f23a87455ec6dedbc766a74db">00235</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structRtAudio_1_1StreamParameters.html#ddc8281f23a87455ec6dedbc766a74db">firstChannel</a>;
  100. <a name="l00237"></a>00237 <span class="comment">// Default constructor.</span>
  101. <a name="l00238"></a>00238 <a class="code" href="structRtAudio_1_1StreamParameters.html" title="The structure for specifying input or ouput stream parameters.">StreamParameters</a>()
  102. <a name="l00239"></a>00239 : <a class="code" href="structRtAudio_1_1StreamParameters.html#ffd27496c70c0986522056234c64e28e">deviceId</a>(0), <a class="code" href="structRtAudio_1_1StreamParameters.html#78798b65fada7941e1a7e47c11c9e627">nChannels</a>(0), <a class="code" href="structRtAudio_1_1StreamParameters.html#ddc8281f23a87455ec6dedbc766a74db">firstChannel</a>(0) {}
  103. <a name="l00240"></a>00240 };
  104. <a name="l00241"></a>00241
  105. <a name="l00243"></a>00243
  106. <a name="l00294"></a><a class="code" href="structRtAudio_1_1StreamOptions.html">00294</a> <span class="keyword">struct </span><a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">StreamOptions</a> {
  107. <a name="l00295"></a><a class="code" href="structRtAudio_1_1StreamOptions.html#6a284d045b8adcfcf178a4f6a22330f8">00295</a> <a class="code" href="RtAudio_8h.html#2c0f59b200dcec4d4e760f9166b29c41" title="RtAudio stream option flags.">RtAudioStreamFlags</a> <a class="code" href="structRtAudio_1_1StreamOptions.html#6a284d045b8adcfcf178a4f6a22330f8">flags</a>;
  108. <a name="l00296"></a><a class="code" href="structRtAudio_1_1StreamOptions.html#5a04d3c3d0c1cfa063872ecff383af1d">00296</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structRtAudio_1_1StreamOptions.html#5a04d3c3d0c1cfa063872ecff383af1d">numberOfBuffers</a>;
  109. <a name="l00297"></a><a class="code" href="structRtAudio_1_1StreamOptions.html#214da35056f18ffb7c8e4dc074a01a9a">00297</a> std::string <a class="code" href="structRtAudio_1_1StreamOptions.html#214da35056f18ffb7c8e4dc074a01a9a">streamName</a>;
  110. <a name="l00298"></a><a class="code" href="structRtAudio_1_1StreamOptions.html#81b364f137d1ee1073b74dac666af352">00298</a> <span class="keywordtype">int</span> <a class="code" href="structRtAudio_1_1StreamOptions.html#81b364f137d1ee1073b74dac666af352">priority</a>;
  111. <a name="l00300"></a>00300 <span class="comment">// Default constructor.</span>
  112. <a name="l00301"></a>00301 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">StreamOptions</a>()
  113. <a name="l00302"></a>00302 : <a class="code" href="structRtAudio_1_1StreamOptions.html#6a284d045b8adcfcf178a4f6a22330f8">flags</a>(0), <a class="code" href="structRtAudio_1_1StreamOptions.html#5a04d3c3d0c1cfa063872ecff383af1d">numberOfBuffers</a>(0), <a class="code" href="structRtAudio_1_1StreamOptions.html#81b364f137d1ee1073b74dac666af352">priority</a>(0) {}
  114. <a name="l00303"></a>00303 };
  115. <a name="l00304"></a>00304
  116. <a name="l00306"></a>00306
  117. <a name="l00311"></a>00311 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#e266ffad2ef428d0b2c6c262d391ce26" title="A static function to determine the available compiled audio APIs.">getCompiledApi</a>( std::vector&lt;RtAudio::Api&gt; &amp;apis ) <span class="keywordflow">throw</span>();
  118. <a name="l00312"></a>00312
  119. <a name="l00314"></a>00314
  120. <a name="l00322"></a>00322 <a class="code" href="classRtAudio.html#fd0bfa26deae9804e18faff59d0273d9" title="The class constructor.">RtAudio</a>( <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> api=<a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849a49af3ac767106158bc6cad74fb214ae">UNSPECIFIED</a> ) throw();
  121. <a name="l00323"></a>00323
  122. <a name="l00325"></a>00325
  123. <a name="l00329"></a>00329 ~<a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a>() throw();
  124. <a name="l00330"></a>00330
  125. <a name="l00332"></a>00332 <a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a>::<a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">Api</a> <a class="code" href="classRtAudio.html#83687634795792b2c47e4ae1cf8a5246" title="Returns the audio API specifier for the current instance of RtAudio.">getCurrentApi</a>( <span class="keywordtype">void</span> ) throw();
  126. <a name="l00333"></a>00333
  127. <a name="l00335"></a>00335
  128. <a name="l00340"></a>00340 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#747ce2d73803641bbb66d6e78092aa1a" title="A public function that queries for the number of audio devices available.">getDeviceCount</a>( <span class="keywordtype">void</span> ) throw();
  129. <a name="l00341"></a>00341
  130. <a name="l00343"></a>00343
  131. <a name="l00353"></a>00353 <a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a>::DeviceInfo <a class="code" href="classRtAudio.html#02d7ff44ad1d7eae22283a052f3dfda8" title="Return an RtAudio::DeviceInfo structure for a specified device number.">getDeviceInfo</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device );
  132. <a name="l00354"></a>00354
  133. <a name="l00356"></a>00356
  134. <a name="l00363"></a>00363 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#3a3f3dbe13ea696b521e49cdaaa357bc" title="A function that returns the index of the default output device.">getDefaultOutputDevice</a>( <span class="keywordtype">void</span> ) throw();
  135. <a name="l00364"></a>00364
  136. <a name="l00366"></a>00366
  137. <a name="l00373"></a>00373 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#ad8b94edd3cd379ee300b125750ac6ce" title="A function that returns the index of the default input device.">getDefaultInputDevice</a>( <span class="keywordtype">void</span> ) throw();
  138. <a name="l00374"></a>00374
  139. <a name="l00376"></a>00376
  140. <a name="l00413"></a>00413 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#facc99740fa4c5606fb35467cdea6da8" title="A public function for opening a stream with the specified parameters.">openStream</a>( <a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a>::StreamParameters *outputParameters,
  141. <a name="l00414"></a>00414 <a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a>::StreamParameters *inputParameters,
  142. <a name="l00415"></a>00415 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  143. <a name="l00416"></a>00416 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferFrames, <a class="code" href="RtAudio_8h.html#112c7b7e25a974977f6fc094cef1a31f" title="RtAudio callback function prototype.">RtAudioCallback</a> callback,
  144. <a name="l00417"></a>00417 <span class="keywordtype">void</span> *userData = NULL, <a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a>::StreamOptions *options = NULL );
  145. <a name="l00418"></a>00418
  146. <a name="l00420"></a>00420
  147. <a name="l00424"></a>00424 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#90d599002ad32cf250a4cb866f2cc93a" title="A function that closes a stream and frees any associated stream memory.">closeStream</a>( <span class="keywordtype">void</span> ) throw();
  148. <a name="l00425"></a>00425
  149. <a name="l00427"></a>00427
  150. <a name="l00433"></a>00433 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#ec017a89629ccef66a90b60be22a2f80" title="A function that starts a stream.">startStream</a>( <span class="keywordtype">void</span> );
  151. <a name="l00434"></a>00434
  152. <a name="l00436"></a>00436
  153. <a name="l00442"></a>00442 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#f4c241ff86936ecc8108f0d9dfe3efdd" title="Stop a stream, allowing any samples remaining in the output queue to be played.">stopStream</a>( <span class="keywordtype">void</span> );
  154. <a name="l00443"></a>00443
  155. <a name="l00445"></a>00445
  156. <a name="l00451"></a>00451 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#d0586b47cd6bb9591a80b4052815991f" title="Stop a stream, discarding any samples remaining in the input/output queue.">abortStream</a>( <span class="keywordtype">void</span> );
  157. <a name="l00452"></a>00452
  158. <a name="l00454"></a>00454 <span class="keywordtype">bool</span> <a class="code" href="classRtAudio.html#3863e45ff81dbe97176de0ee7545917f" title="Returns true if a stream is open and false if not.">isStreamOpen</a>( <span class="keywordtype">void</span> ) const throw();
  159. <a name="l00455"></a>00455
  160. <a name="l00457"></a>00457 <span class="keywordtype">bool</span> <a class="code" href="classRtAudio.html#84cc8d9b7ab9bc5f37bcf48430ec5aea" title="Returns true if the stream is running and false if it is stopped or not open.">isStreamRunning</a>( <span class="keywordtype">void</span> ) const throw();
  161. <a name="l00458"></a>00458
  162. <a name="l00460"></a>00460
  163. <a name="l00463"></a>00463 <span class="keywordtype">double</span> <a class="code" href="classRtAudio.html#344e59a62353c5791db4621b985cb2ca" title="Returns the number of elapsed seconds since the stream was started.">getStreamTime</a>( <span class="keywordtype">void</span> );
  164. <a name="l00464"></a>00464
  165. <a name="l00466"></a>00466
  166. <a name="l00474"></a>00474 <span class="keywordtype">long</span> <a class="code" href="classRtAudio.html#843c989d9f501c71bc2f2c5ca18df9f3" title="Returns the internal stream latency in sample frames.">getStreamLatency</a>( <span class="keywordtype">void</span> );
  167. <a name="l00475"></a>00475
  168. <a name="l00477"></a>00477
  169. <a name="l00482"></a>00482 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#28214b8b05d60b45c24ee6fae7b2a0b5" title="Returns actual sample rate in use by the stream.">getStreamSampleRate</a>( <span class="keywordtype">void</span> );
  170. <a name="l00483"></a>00483
  171. <a name="l00485"></a>00485 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#f0752ee51cce3dd90a3bd009f9fdbe77" title="Specify whether warning messages should be printed to stderr.">showWarnings</a>( <span class="keywordtype">bool</span> value = true ) throw();
  172. <a name="l00486"></a>00486
  173. <a name="l00487"></a>00487 protected:
  174. <a name="l00488"></a>00488
  175. <a name="l00489"></a>00489 <span class="keywordtype">void</span> openRtApi( <a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a>::<a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">Api</a> api );
  176. <a name="l00490"></a>00490 RtApi *rtapi_;
  177. <a name="l00491"></a>00491 };
  178. <a name="l00492"></a>00492
  179. <a name="l00493"></a>00493 <span class="comment">// Operating system dependent thread functionality.</span>
  180. <a name="l00494"></a>00494 <span class="preprocessor">#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)</span>
  181. <a name="l00495"></a>00495 <span class="preprocessor"></span><span class="preprocessor"> #include &lt;windows.h&gt;</span>
  182. <a name="l00496"></a>00496 <span class="preprocessor"> #include &lt;process.h&gt;</span>
  183. <a name="l00497"></a>00497
  184. <a name="l00498"></a>00498 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> ThreadHandle;
  185. <a name="l00499"></a>00499 <span class="keyword">typedef</span> CRITICAL_SECTION StreamMutex;
  186. <a name="l00500"></a>00500
  187. <a name="l00501"></a>00501 <span class="preprocessor">#elif defined(__LINUX_ALSA__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__)</span>
  188. <a name="l00502"></a>00502 <span class="preprocessor"></span> <span class="comment">// Using pthread library for various flavors of unix.</span>
  189. <a name="l00503"></a>00503 <span class="preprocessor"> #include &lt;pthread.h&gt;</span>
  190. <a name="l00504"></a>00504
  191. <a name="l00505"></a>00505 <span class="keyword">typedef</span> pthread_t ThreadHandle;
  192. <a name="l00506"></a>00506 <span class="keyword">typedef</span> pthread_mutex_t StreamMutex;
  193. <a name="l00507"></a>00507
  194. <a name="l00508"></a>00508 <span class="preprocessor">#else // Setup for "dummy" behavior</span>
  195. <a name="l00509"></a>00509 <span class="preprocessor"></span>
  196. <a name="l00510"></a>00510 <span class="preprocessor"> #define __RTAUDIO_DUMMY__</span>
  197. <a name="l00511"></a>00511 <span class="preprocessor"></span> <span class="keyword">typedef</span> <span class="keywordtype">int</span> ThreadHandle;
  198. <a name="l00512"></a>00512 <span class="keyword">typedef</span> <span class="keywordtype">int</span> StreamMutex;
  199. <a name="l00513"></a>00513
  200. <a name="l00514"></a>00514 <span class="preprocessor">#endif</span>
  201. <a name="l00515"></a>00515 <span class="preprocessor"></span>
  202. <a name="l00516"></a>00516 <span class="comment">// This global structure type is used to pass callback information</span>
  203. <a name="l00517"></a>00517 <span class="comment">// between the private RtAudio stream structure and global callback</span>
  204. <a name="l00518"></a>00518 <span class="comment">// handling functions.</span>
  205. <a name="l00519"></a>00519 <span class="keyword">struct </span>CallbackInfo {
  206. <a name="l00520"></a>00520 <span class="keywordtype">void</span> *object; <span class="comment">// Used as a "this" pointer.</span>
  207. <a name="l00521"></a>00521 ThreadHandle thread;
  208. <a name="l00522"></a>00522 <span class="keywordtype">void</span> *callback;
  209. <a name="l00523"></a>00523 <span class="keywordtype">void</span> *userData;
  210. <a name="l00524"></a>00524 <span class="keywordtype">void</span> *apiInfo; <span class="comment">// void pointer for API specific callback information</span>
  211. <a name="l00525"></a>00525 <span class="keywordtype">bool</span> isRunning;
  212. <a name="l00526"></a>00526
  213. <a name="l00527"></a>00527 <span class="comment">// Default constructor.</span>
  214. <a name="l00528"></a>00528 CallbackInfo()
  215. <a name="l00529"></a>00529 :object(0), callback(0), userData(0), apiInfo(0), isRunning(false) {}
  216. <a name="l00530"></a>00530 };
  217. <a name="l00531"></a>00531
  218. <a name="l00532"></a>00532 <span class="comment">// **************************************************************** //</span>
  219. <a name="l00533"></a>00533 <span class="comment">//</span>
  220. <a name="l00534"></a>00534 <span class="comment">// RtApi class declaration.</span>
  221. <a name="l00535"></a>00535 <span class="comment">//</span>
  222. <a name="l00536"></a>00536 <span class="comment">// Subclasses of RtApi contain all API- and OS-specific code necessary</span>
  223. <a name="l00537"></a>00537 <span class="comment">// to fully implement the RtAudio API.</span>
  224. <a name="l00538"></a>00538 <span class="comment">//</span>
  225. <a name="l00539"></a>00539 <span class="comment">// Note that RtApi is an abstract base class and cannot be</span>
  226. <a name="l00540"></a>00540 <span class="comment">// explicitly instantiated. The class RtAudio will create an</span>
  227. <a name="l00541"></a>00541 <span class="comment">// instance of an RtApi subclass (RtApiOss, RtApiAlsa,</span>
  228. <a name="l00542"></a>00542 <span class="comment">// RtApiJack, RtApiCore, RtApiAl, RtApiDs, or RtApiAsio).</span>
  229. <a name="l00543"></a>00543 <span class="comment">//</span>
  230. <a name="l00544"></a>00544 <span class="comment">// **************************************************************** //</span>
  231. <a name="l00545"></a>00545
  232. <a name="l00546"></a>00546 <span class="preprocessor">#if defined( HAVE_GETTIMEOFDAY )</span>
  233. <a name="l00547"></a>00547 <span class="preprocessor"></span><span class="preprocessor"> #include &lt;sys/time.h&gt;</span>
  234. <a name="l00548"></a>00548 <span class="preprocessor">#endif</span>
  235. <a name="l00549"></a>00549 <span class="preprocessor"></span>
  236. <a name="l00550"></a>00550 <span class="preprocessor">#include &lt;sstream&gt;</span>
  237. <a name="l00551"></a>00551
  238. <a name="l00552"></a>00552 <span class="keyword">class </span>RtApi
  239. <a name="l00553"></a>00553 {
  240. <a name="l00554"></a>00554 <span class="keyword">public</span>:
  241. <a name="l00555"></a>00555
  242. <a name="l00556"></a>00556 RtApi();
  243. <a name="l00557"></a>00557 <span class="keyword">virtual</span> ~RtApi();
  244. <a name="l00558"></a>00558 <span class="keyword">virtual</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> <a class="code" href="classRtAudio.html#83687634795792b2c47e4ae1cf8a5246" title="Returns the audio API specifier for the current instance of RtAudio.">getCurrentApi</a>( <span class="keywordtype">void</span> ) = 0;
  245. <a name="l00559"></a>00559 <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#747ce2d73803641bbb66d6e78092aa1a" title="A public function that queries for the number of audio devices available.">getDeviceCount</a>( <span class="keywordtype">void</span> ) = 0;
  246. <a name="l00560"></a>00560 <span class="keyword">virtual</span> <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> <a class="code" href="classRtAudio.html#02d7ff44ad1d7eae22283a052f3dfda8" title="Return an RtAudio::DeviceInfo structure for a specified device number.">getDeviceInfo</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device ) = 0;
  247. <a name="l00561"></a>00561 <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#ad8b94edd3cd379ee300b125750ac6ce" title="A function that returns the index of the default input device.">getDefaultInputDevice</a>( <span class="keywordtype">void</span> );
  248. <a name="l00562"></a>00562 <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#3a3f3dbe13ea696b521e49cdaaa357bc" title="A function that returns the index of the default output device.">getDefaultOutputDevice</a>( <span class="keywordtype">void</span> );
  249. <a name="l00563"></a>00563 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#facc99740fa4c5606fb35467cdea6da8" title="A public function for opening a stream with the specified parameters.">openStream</a>( <a class="code" href="structRtAudio_1_1StreamParameters.html" title="The structure for specifying input or ouput stream parameters.">RtAudio::StreamParameters</a> *outputParameters,
  250. <a name="l00564"></a>00564 <a class="code" href="structRtAudio_1_1StreamParameters.html" title="The structure for specifying input or ouput stream parameters.">RtAudio::StreamParameters</a> *inputParameters,
  251. <a name="l00565"></a>00565 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  252. <a name="l00566"></a>00566 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferFrames, <a class="code" href="RtAudio_8h.html#112c7b7e25a974977f6fc094cef1a31f" title="RtAudio callback function prototype.">RtAudioCallback</a> callback,
  253. <a name="l00567"></a>00567 <span class="keywordtype">void</span> *userData, <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options );
  254. <a name="l00568"></a>00568 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#90d599002ad32cf250a4cb866f2cc93a" title="A function that closes a stream and frees any associated stream memory.">closeStream</a>( <span class="keywordtype">void</span> );
  255. <a name="l00569"></a>00569 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#ec017a89629ccef66a90b60be22a2f80" title="A function that starts a stream.">startStream</a>( <span class="keywordtype">void</span> ) = 0;
  256. <a name="l00570"></a>00570 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#f4c241ff86936ecc8108f0d9dfe3efdd" title="Stop a stream, allowing any samples remaining in the output queue to be played.">stopStream</a>( <span class="keywordtype">void</span> ) = 0;
  257. <a name="l00571"></a>00571 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#d0586b47cd6bb9591a80b4052815991f" title="Stop a stream, discarding any samples remaining in the input/output queue.">abortStream</a>( <span class="keywordtype">void</span> ) = 0;
  258. <a name="l00572"></a>00572 <span class="keywordtype">long</span> <a class="code" href="classRtAudio.html#843c989d9f501c71bc2f2c5ca18df9f3" title="Returns the internal stream latency in sample frames.">getStreamLatency</a>( <span class="keywordtype">void</span> );
  259. <a name="l00573"></a>00573 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#28214b8b05d60b45c24ee6fae7b2a0b5" title="Returns actual sample rate in use by the stream.">getStreamSampleRate</a>( <span class="keywordtype">void</span> );
  260. <a name="l00574"></a>00574 <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classRtAudio.html#344e59a62353c5791db4621b985cb2ca" title="Returns the number of elapsed seconds since the stream was started.">getStreamTime</a>( <span class="keywordtype">void</span> );
  261. <a name="l00575"></a>00575 <span class="keywordtype">bool</span> <a class="code" href="classRtAudio.html#3863e45ff81dbe97176de0ee7545917f" title="Returns true if a stream is open and false if not.">isStreamOpen</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> stream_.state != STREAM_CLOSED; };
  262. <a name="l00576"></a>00576 <span class="keywordtype">bool</span> <a class="code" href="classRtAudio.html#84cc8d9b7ab9bc5f37bcf48430ec5aea" title="Returns true if the stream is running and false if it is stopped or not open.">isStreamRunning</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> stream_.state == STREAM_RUNNING; };
  263. <a name="l00577"></a>00577 <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#f0752ee51cce3dd90a3bd009f9fdbe77" title="Specify whether warning messages should be printed to stderr.">showWarnings</a>( <span class="keywordtype">bool</span> value ) { showWarnings_ = value; };
  264. <a name="l00578"></a>00578
  265. <a name="l00579"></a>00579
  266. <a name="l00580"></a>00580 <span class="keyword">protected</span>:
  267. <a name="l00581"></a>00581
  268. <a name="l00582"></a>00582 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MAX_SAMPLE_RATES;
  269. <a name="l00583"></a>00583 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> SAMPLE_RATES[];
  270. <a name="l00584"></a>00584
  271. <a name="l00585"></a>00585 <span class="keyword">enum</span> { FAILURE, SUCCESS };
  272. <a name="l00586"></a>00586
  273. <a name="l00587"></a>00587 <span class="keyword">enum</span> StreamState {
  274. <a name="l00588"></a>00588 STREAM_STOPPED,
  275. <a name="l00589"></a>00589 STREAM_RUNNING,
  276. <a name="l00590"></a>00590 STREAM_CLOSED = -50
  277. <a name="l00591"></a>00591 };
  278. <a name="l00592"></a>00592
  279. <a name="l00593"></a>00593 <span class="keyword">enum</span> StreamMode {
  280. <a name="l00594"></a>00594 OUTPUT,
  281. <a name="l00595"></a>00595 INPUT,
  282. <a name="l00596"></a>00596 DUPLEX,
  283. <a name="l00597"></a>00597 UNINITIALIZED = -75
  284. <a name="l00598"></a>00598 };
  285. <a name="l00599"></a>00599
  286. <a name="l00600"></a>00600 <span class="comment">// A protected structure used for buffer conversion.</span>
  287. <a name="l00601"></a>00601 <span class="keyword">struct </span>ConvertInfo {
  288. <a name="l00602"></a>00602 <span class="keywordtype">int</span> channels;
  289. <a name="l00603"></a>00603 <span class="keywordtype">int</span> inJump, outJump;
  290. <a name="l00604"></a>00604 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> inFormat, outFormat;
  291. <a name="l00605"></a>00605 std::vector&lt;int&gt; inOffset;
  292. <a name="l00606"></a>00606 std::vector&lt;int&gt; outOffset;
  293. <a name="l00607"></a>00607 };
  294. <a name="l00608"></a>00608
  295. <a name="l00609"></a>00609 <span class="comment">// A protected structure for audio streams.</span>
  296. <a name="l00610"></a>00610 <span class="keyword">struct </span>RtApiStream {
  297. <a name="l00611"></a>00611 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device[2]; <span class="comment">// Playback and record, respectively.</span>
  298. <a name="l00612"></a>00612 <span class="keywordtype">void</span> *apiHandle; <span class="comment">// void pointer for API specific stream handle information</span>
  299. <a name="l00613"></a>00613 StreamMode mode; <span class="comment">// OUTPUT, INPUT, or DUPLEX.</span>
  300. <a name="l00614"></a>00614 StreamState state; <span class="comment">// STOPPED, RUNNING, or CLOSED</span>
  301. <a name="l00615"></a>00615 <span class="keywordtype">char</span> *userBuffer[2]; <span class="comment">// Playback and record, respectively.</span>
  302. <a name="l00616"></a>00616 <span class="keywordtype">char</span> *deviceBuffer;
  303. <a name="l00617"></a>00617 <span class="keywordtype">bool</span> doConvertBuffer[2]; <span class="comment">// Playback and record, respectively.</span>
  304. <a name="l00618"></a>00618 <span class="keywordtype">bool</span> userInterleaved;
  305. <a name="l00619"></a>00619 <span class="keywordtype">bool</span> deviceInterleaved[2]; <span class="comment">// Playback and record, respectively.</span>
  306. <a name="l00620"></a>00620 <span class="keywordtype">bool</span> doByteSwap[2]; <span class="comment">// Playback and record, respectively.</span>
  307. <a name="l00621"></a>00621 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate;
  308. <a name="l00622"></a>00622 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bufferSize;
  309. <a name="l00623"></a>00623 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nBuffers;
  310. <a name="l00624"></a>00624 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nUserChannels[2]; <span class="comment">// Playback and record, respectively.</span>
  311. <a name="l00625"></a>00625 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nDeviceChannels[2]; <span class="comment">// Playback and record channels, respectively.</span>
  312. <a name="l00626"></a>00626 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channelOffset[2]; <span class="comment">// Playback and record, respectively.</span>
  313. <a name="l00627"></a>00627 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> latency[2]; <span class="comment">// Playback and record, respectively.</span>
  314. <a name="l00628"></a>00628 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> userFormat;
  315. <a name="l00629"></a>00629 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> deviceFormat[2]; <span class="comment">// Playback and record, respectively.</span>
  316. <a name="l00630"></a>00630 StreamMutex mutex;
  317. <a name="l00631"></a>00631 CallbackInfo callbackInfo;
  318. <a name="l00632"></a>00632 ConvertInfo convertInfo[2];
  319. <a name="l00633"></a>00633 <span class="keywordtype">double</span> streamTime; <span class="comment">// Number of elapsed seconds since the stream started.</span>
  320. <a name="l00634"></a>00634
  321. <a name="l00635"></a>00635 <span class="preprocessor">#if defined(HAVE_GETTIMEOFDAY)</span>
  322. <a name="l00636"></a>00636 <span class="preprocessor"></span> <span class="keyword">struct </span>timeval lastTickTimestamp;
  323. <a name="l00637"></a>00637 <span class="preprocessor">#endif</span>
  324. <a name="l00638"></a>00638 <span class="preprocessor"></span>
  325. <a name="l00639"></a>00639 RtApiStream()
  326. <a name="l00640"></a>00640 :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; }
  327. <a name="l00641"></a>00641 };
  328. <a name="l00642"></a>00642
  329. <a name="l00643"></a>00643 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">short</span> Int16;
  330. <a name="l00644"></a>00644 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">int</span> Int32;
  331. <a name="l00645"></a>00645 <span class="keyword">typedef</span> <span class="keywordtype">float</span> Float32;
  332. <a name="l00646"></a>00646 <span class="keyword">typedef</span> <span class="keywordtype">double</span> Float64;
  333. <a name="l00647"></a>00647
  334. <a name="l00648"></a>00648 std::ostringstream errorStream_;
  335. <a name="l00649"></a>00649 std::string errorText_;
  336. <a name="l00650"></a>00650 <span class="keywordtype">bool</span> showWarnings_;
  337. <a name="l00651"></a>00651 RtApiStream stream_;
  338. <a name="l00652"></a>00652
  339. <a name="l00660"></a>00660 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channels,
  340. <a name="l00661"></a>00661 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  341. <a name="l00662"></a>00662 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferSize,
  342. <a name="l00663"></a>00663 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options );
  343. <a name="l00664"></a>00664
  344. <a name="l00666"></a>00666 <span class="keywordtype">void</span> tickStreamTime( <span class="keywordtype">void</span> );
  345. <a name="l00667"></a>00667
  346. <a name="l00669"></a>00669 <span class="keywordtype">void</span> clearStreamInfo();
  347. <a name="l00670"></a>00670
  348. <a name="l00675"></a>00675 <span class="keywordtype">void</span> verifyStream( <span class="keywordtype">void</span> );
  349. <a name="l00676"></a>00676
  350. <a name="l00678"></a>00678 <span class="keywordtype">void</span> error( <a class="code" href="classRtError.html#b04667aae01bffc354a9ac6bda6903ac" title="Defined RtError types.">RtError::Type</a> type );
  351. <a name="l00679"></a>00679
  352. <a name="l00684"></a>00684 <span class="keywordtype">void</span> convertBuffer( <span class="keywordtype">char</span> *outBuffer, <span class="keywordtype">char</span> *inBuffer, ConvertInfo &amp;info );
  353. <a name="l00685"></a>00685
  354. <a name="l00687"></a>00687 <span class="keywordtype">void</span> byteSwapBuffer( <span class="keywordtype">char</span> *buffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> samples, <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format );
  355. <a name="l00688"></a>00688
  356. <a name="l00690"></a>00690 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> formatBytes( <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format );
  357. <a name="l00691"></a>00691
  358. <a name="l00693"></a>00693 <span class="keywordtype">void</span> setConvertInfo( StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel );
  359. <a name="l00694"></a>00694 };
  360. <a name="l00695"></a>00695
  361. <a name="l00696"></a>00696 <span class="comment">// **************************************************************** //</span>
  362. <a name="l00697"></a>00697 <span class="comment">//</span>
  363. <a name="l00698"></a>00698 <span class="comment">// Inline RtAudio definitions.</span>
  364. <a name="l00699"></a>00699 <span class="comment">//</span>
  365. <a name="l00700"></a>00700 <span class="comment">// **************************************************************** //</span>
  366. <a name="l00701"></a>00701
  367. <a name="l00702"></a><a class="code" href="classRtAudio.html#83687634795792b2c47e4ae1cf8a5246">00702</a> <span class="keyword">inline</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> <a class="code" href="classRtAudio.html#83687634795792b2c47e4ae1cf8a5246" title="Returns the audio API specifier for the current instance of RtAudio.">RtAudio :: getCurrentApi</a>( <span class="keywordtype">void</span> ) throw() { <span class="keywordflow">return</span> rtapi_-&gt;getCurrentApi(); }
  368. <a name="l00703"></a><a class="code" href="classRtAudio.html#747ce2d73803641bbb66d6e78092aa1a">00703</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#747ce2d73803641bbb66d6e78092aa1a" title="A public function that queries for the number of audio devices available.">RtAudio :: getDeviceCount</a>( <span class="keywordtype">void</span> ) throw() { <span class="keywordflow">return</span> rtapi_-&gt;getDeviceCount(); }
  369. <a name="l00704"></a><a class="code" href="classRtAudio.html#02d7ff44ad1d7eae22283a052f3dfda8">00704</a> <span class="keyword">inline</span> <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> <a class="code" href="classRtAudio.html#02d7ff44ad1d7eae22283a052f3dfda8" title="Return an RtAudio::DeviceInfo structure for a specified device number.">RtAudio :: getDeviceInfo</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device ) { <span class="keywordflow">return</span> rtapi_-&gt;getDeviceInfo( device ); }
  370. <a name="l00705"></a><a class="code" href="classRtAudio.html#ad8b94edd3cd379ee300b125750ac6ce">00705</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#ad8b94edd3cd379ee300b125750ac6ce" title="A function that returns the index of the default input device.">RtAudio :: getDefaultInputDevice</a>( <span class="keywordtype">void</span> ) throw() { <span class="keywordflow">return</span> rtapi_-&gt;getDefaultInputDevice(); }
  371. <a name="l00706"></a><a class="code" href="classRtAudio.html#3a3f3dbe13ea696b521e49cdaaa357bc">00706</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#3a3f3dbe13ea696b521e49cdaaa357bc" title="A function that returns the index of the default output device.">RtAudio :: getDefaultOutputDevice</a>( <span class="keywordtype">void</span> ) throw() { <span class="keywordflow">return</span> rtapi_-&gt;getDefaultOutputDevice(); }
  372. <a name="l00707"></a><a class="code" href="classRtAudio.html#90d599002ad32cf250a4cb866f2cc93a">00707</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#90d599002ad32cf250a4cb866f2cc93a" title="A function that closes a stream and frees any associated stream memory.">RtAudio :: closeStream</a>( <span class="keywordtype">void</span> ) throw() { <span class="keywordflow">return</span> rtapi_-&gt;closeStream(); }
  373. <a name="l00708"></a><a class="code" href="classRtAudio.html#ec017a89629ccef66a90b60be22a2f80">00708</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#ec017a89629ccef66a90b60be22a2f80" title="A function that starts a stream.">RtAudio :: startStream</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> rtapi_-&gt;startStream(); }
  374. <a name="l00709"></a><a class="code" href="classRtAudio.html#f4c241ff86936ecc8108f0d9dfe3efdd">00709</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#f4c241ff86936ecc8108f0d9dfe3efdd" title="Stop a stream, allowing any samples remaining in the output queue to be played.">RtAudio :: stopStream</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> rtapi_-&gt;stopStream(); }
  375. <a name="l00710"></a><a class="code" href="classRtAudio.html#d0586b47cd6bb9591a80b4052815991f">00710</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#d0586b47cd6bb9591a80b4052815991f" title="Stop a stream, discarding any samples remaining in the input/output queue.">RtAudio :: abortStream</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> rtapi_-&gt;abortStream(); }
  376. <a name="l00711"></a><a class="code" href="classRtAudio.html#3863e45ff81dbe97176de0ee7545917f">00711</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classRtAudio.html#3863e45ff81dbe97176de0ee7545917f" title="Returns true if a stream is open and false if not.">RtAudio :: isStreamOpen</a>( <span class="keywordtype">void</span> ) <span class="keyword">const</span> throw() { <span class="keywordflow">return</span> rtapi_-&gt;isStreamOpen(); }
  377. <a name="l00712"></a><a class="code" href="classRtAudio.html#84cc8d9b7ab9bc5f37bcf48430ec5aea">00712</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classRtAudio.html#84cc8d9b7ab9bc5f37bcf48430ec5aea" title="Returns true if the stream is running and false if it is stopped or not open.">RtAudio :: isStreamRunning</a>( <span class="keywordtype">void</span> ) <span class="keyword">const</span> throw() { <span class="keywordflow">return</span> rtapi_-&gt;isStreamRunning(); }
  378. <a name="l00713"></a><a class="code" href="classRtAudio.html#843c989d9f501c71bc2f2c5ca18df9f3">00713</a> <span class="keyword">inline</span> <span class="keywordtype">long</span> <a class="code" href="classRtAudio.html#843c989d9f501c71bc2f2c5ca18df9f3" title="Returns the internal stream latency in sample frames.">RtAudio :: getStreamLatency</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> rtapi_-&gt;getStreamLatency(); }
  379. <a name="l00714"></a><a class="code" href="classRtAudio.html#28214b8b05d60b45c24ee6fae7b2a0b5">00714</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classRtAudio.html#28214b8b05d60b45c24ee6fae7b2a0b5" title="Returns actual sample rate in use by the stream.">RtAudio :: getStreamSampleRate</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> rtapi_-&gt;getStreamSampleRate(); };
  380. <a name="l00715"></a><a class="code" href="classRtAudio.html#344e59a62353c5791db4621b985cb2ca">00715</a> <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="classRtAudio.html#344e59a62353c5791db4621b985cb2ca" title="Returns the number of elapsed seconds since the stream was started.">RtAudio :: getStreamTime</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> rtapi_-&gt;getStreamTime(); }
  381. <a name="l00716"></a><a class="code" href="classRtAudio.html#f0752ee51cce3dd90a3bd009f9fdbe77">00716</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classRtAudio.html#f0752ee51cce3dd90a3bd009f9fdbe77" title="Specify whether warning messages should be printed to stderr.">RtAudio :: showWarnings</a>( <span class="keywordtype">bool</span> value ) <span class="keywordflow">throw</span>() { rtapi_-&gt;showWarnings( value ); }
  382. <a name="l00717"></a>00717
  383. <a name="l00718"></a>00718 <span class="comment">// RtApi Subclass prototypes.</span>
  384. <a name="l00719"></a>00719
  385. <a name="l00720"></a>00720 <span class="preprocessor">#if defined(__MACOSX_CORE__)</span>
  386. <a name="l00721"></a>00721 <span class="preprocessor"></span>
  387. <a name="l00722"></a>00722 <span class="preprocessor">#include &lt;CoreAudio/AudioHardware.h&gt;</span>
  388. <a name="l00723"></a>00723
  389. <a name="l00724"></a>00724 <span class="keyword">class </span>RtApiCore: <span class="keyword">public</span> RtApi
  390. <a name="l00725"></a>00725 {
  391. <a name="l00726"></a>00726 <span class="keyword">public</span>:
  392. <a name="l00727"></a>00727
  393. <a name="l00728"></a>00728 RtApiCore();
  394. <a name="l00729"></a>00729 ~RtApiCore();
  395. <a name="l00730"></a>00730 <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> getCurrentApi( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d8499fec92b8272244a87a6a11a717bd662d">RtAudio::MACOSX_CORE</a>; };
  396. <a name="l00731"></a>00731 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDeviceCount( <span class="keywordtype">void</span> );
  397. <a name="l00732"></a>00732 <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> getDeviceInfo( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device );
  398. <a name="l00733"></a>00733 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDefaultOutputDevice( <span class="keywordtype">void</span> );
  399. <a name="l00734"></a>00734 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDefaultInputDevice( <span class="keywordtype">void</span> );
  400. <a name="l00735"></a>00735 <span class="keywordtype">void</span> closeStream( <span class="keywordtype">void</span> );
  401. <a name="l00736"></a>00736 <span class="keywordtype">void</span> startStream( <span class="keywordtype">void</span> );
  402. <a name="l00737"></a>00737 <span class="keywordtype">void</span> stopStream( <span class="keywordtype">void</span> );
  403. <a name="l00738"></a>00738 <span class="keywordtype">void</span> abortStream( <span class="keywordtype">void</span> );
  404. <a name="l00739"></a>00739 <span class="keywordtype">long</span> getStreamLatency( <span class="keywordtype">void</span> );
  405. <a name="l00740"></a>00740
  406. <a name="l00741"></a>00741 <span class="comment">// This function is intended for internal use only. It must be</span>
  407. <a name="l00742"></a>00742 <span class="comment">// public because it is called by the internal callback handler,</span>
  408. <a name="l00743"></a>00743 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
  409. <a name="l00744"></a>00744 <span class="comment">// will most likely produce highly undesireable results!</span>
  410. <a name="l00745"></a>00745 <span class="keywordtype">bool</span> callbackEvent( AudioDeviceID deviceId,
  411. <a name="l00746"></a>00746 <span class="keyword">const</span> AudioBufferList *inBufferList,
  412. <a name="l00747"></a>00747 <span class="keyword">const</span> AudioBufferList *outBufferList );
  413. <a name="l00748"></a>00748
  414. <a name="l00749"></a>00749 <span class="keyword">private</span>:
  415. <a name="l00750"></a>00750
  416. <a name="l00751"></a>00751 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channels,
  417. <a name="l00752"></a>00752 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  418. <a name="l00753"></a>00753 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferSize,
  419. <a name="l00754"></a>00754 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options );
  420. <a name="l00755"></a>00755 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* getErrorCode( OSStatus code );
  421. <a name="l00756"></a>00756 };
  422. <a name="l00757"></a>00757
  423. <a name="l00758"></a>00758 <span class="preprocessor">#endif</span>
  424. <a name="l00759"></a>00759 <span class="preprocessor"></span>
  425. <a name="l00760"></a>00760 <span class="preprocessor">#if defined(__UNIX_JACK__)</span>
  426. <a name="l00761"></a>00761 <span class="preprocessor"></span>
  427. <a name="l00762"></a>00762 <span class="keyword">class </span>RtApiJack: <span class="keyword">public</span> RtApi
  428. <a name="l00763"></a>00763 {
  429. <a name="l00764"></a>00764 <span class="keyword">public</span>:
  430. <a name="l00765"></a>00765
  431. <a name="l00766"></a>00766 RtApiJack();
  432. <a name="l00767"></a>00767 ~RtApiJack();
  433. <a name="l00768"></a>00768 <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> getCurrentApi( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d8494767e17c6edfbd827f91763915df4105">RtAudio::UNIX_JACK</a>; };
  434. <a name="l00769"></a>00769 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDeviceCount( <span class="keywordtype">void</span> );
  435. <a name="l00770"></a>00770 <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> getDeviceInfo( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device );
  436. <a name="l00771"></a>00771 <span class="keywordtype">void</span> closeStream( <span class="keywordtype">void</span> );
  437. <a name="l00772"></a>00772 <span class="keywordtype">void</span> startStream( <span class="keywordtype">void</span> );
  438. <a name="l00773"></a>00773 <span class="keywordtype">void</span> stopStream( <span class="keywordtype">void</span> );
  439. <a name="l00774"></a>00774 <span class="keywordtype">void</span> abortStream( <span class="keywordtype">void</span> );
  440. <a name="l00775"></a>00775 <span class="keywordtype">long</span> getStreamLatency( <span class="keywordtype">void</span> );
  441. <a name="l00776"></a>00776
  442. <a name="l00777"></a>00777 <span class="comment">// This function is intended for internal use only. It must be</span>
  443. <a name="l00778"></a>00778 <span class="comment">// public because it is called by the internal callback handler,</span>
  444. <a name="l00779"></a>00779 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
  445. <a name="l00780"></a>00780 <span class="comment">// will most likely produce highly undesireable results!</span>
  446. <a name="l00781"></a>00781 <span class="keywordtype">bool</span> callbackEvent( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> nframes );
  447. <a name="l00782"></a>00782
  448. <a name="l00783"></a>00783 <span class="keyword">private</span>:
  449. <a name="l00784"></a>00784
  450. <a name="l00785"></a>00785 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channels,
  451. <a name="l00786"></a>00786 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  452. <a name="l00787"></a>00787 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferSize,
  453. <a name="l00788"></a>00788 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options );
  454. <a name="l00789"></a>00789 };
  455. <a name="l00790"></a>00790
  456. <a name="l00791"></a>00791 <span class="preprocessor">#endif</span>
  457. <a name="l00792"></a>00792 <span class="preprocessor"></span>
  458. <a name="l00793"></a>00793 <span class="preprocessor">#if defined(__WINDOWS_ASIO__)</span>
  459. <a name="l00794"></a>00794 <span class="preprocessor"></span>
  460. <a name="l00795"></a>00795 <span class="keyword">class </span>RtApiAsio: <span class="keyword">public</span> RtApi
  461. <a name="l00796"></a>00796 {
  462. <a name="l00797"></a>00797 <span class="keyword">public</span>:
  463. <a name="l00798"></a>00798
  464. <a name="l00799"></a>00799 RtApiAsio();
  465. <a name="l00800"></a>00800 ~RtApiAsio();
  466. <a name="l00801"></a>00801 <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> getCurrentApi( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849219517d1df90f94d07758481155bd469">RtAudio::WINDOWS_ASIO</a>; };
  467. <a name="l00802"></a>00802 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDeviceCount( <span class="keywordtype">void</span> );
  468. <a name="l00803"></a>00803 <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> getDeviceInfo( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device );
  469. <a name="l00804"></a>00804 <span class="keywordtype">void</span> closeStream( <span class="keywordtype">void</span> );
  470. <a name="l00805"></a>00805 <span class="keywordtype">void</span> startStream( <span class="keywordtype">void</span> );
  471. <a name="l00806"></a>00806 <span class="keywordtype">void</span> stopStream( <span class="keywordtype">void</span> );
  472. <a name="l00807"></a>00807 <span class="keywordtype">void</span> abortStream( <span class="keywordtype">void</span> );
  473. <a name="l00808"></a>00808 <span class="keywordtype">long</span> getStreamLatency( <span class="keywordtype">void</span> );
  474. <a name="l00809"></a>00809
  475. <a name="l00810"></a>00810 <span class="comment">// This function is intended for internal use only. It must be</span>
  476. <a name="l00811"></a>00811 <span class="comment">// public because it is called by the internal callback handler,</span>
  477. <a name="l00812"></a>00812 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
  478. <a name="l00813"></a>00813 <span class="comment">// will most likely produce highly undesireable results!</span>
  479. <a name="l00814"></a>00814 <span class="keywordtype">bool</span> callbackEvent( <span class="keywordtype">long</span> bufferIndex );
  480. <a name="l00815"></a>00815
  481. <a name="l00816"></a>00816 <span class="keyword">private</span>:
  482. <a name="l00817"></a>00817
  483. <a name="l00818"></a>00818 std::vector&lt;RtAudio::DeviceInfo&gt; devices_;
  484. <a name="l00819"></a>00819 <span class="keywordtype">void</span> saveDeviceInfo( <span class="keywordtype">void</span> );
  485. <a name="l00820"></a>00820 <span class="keywordtype">bool</span> coInitialized_;
  486. <a name="l00821"></a>00821 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channels,
  487. <a name="l00822"></a>00822 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  488. <a name="l00823"></a>00823 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferSize,
  489. <a name="l00824"></a>00824 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options );
  490. <a name="l00825"></a>00825 };
  491. <a name="l00826"></a>00826
  492. <a name="l00827"></a>00827 <span class="preprocessor">#endif</span>
  493. <a name="l00828"></a>00828 <span class="preprocessor"></span>
  494. <a name="l00829"></a>00829 <span class="preprocessor">#if defined(__WINDOWS_DS__)</span>
  495. <a name="l00830"></a>00830 <span class="preprocessor"></span>
  496. <a name="l00831"></a>00831 <span class="keyword">class </span>RtApiDs: <span class="keyword">public</span> RtApi
  497. <a name="l00832"></a>00832 {
  498. <a name="l00833"></a>00833 <span class="keyword">public</span>:
  499. <a name="l00834"></a>00834
  500. <a name="l00835"></a>00835 RtApiDs();
  501. <a name="l00836"></a>00836 ~RtApiDs();
  502. <a name="l00837"></a>00837 <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> getCurrentApi( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d84928478830f42c2fd61e6c7ad498901931">RtAudio::WINDOWS_DS</a>; };
  503. <a name="l00838"></a>00838 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDeviceCount( <span class="keywordtype">void</span> );
  504. <a name="l00839"></a>00839 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDefaultOutputDevice( <span class="keywordtype">void</span> );
  505. <a name="l00840"></a>00840 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDefaultInputDevice( <span class="keywordtype">void</span> );
  506. <a name="l00841"></a>00841 <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> getDeviceInfo( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device );
  507. <a name="l00842"></a>00842 <span class="keywordtype">void</span> closeStream( <span class="keywordtype">void</span> );
  508. <a name="l00843"></a>00843 <span class="keywordtype">void</span> startStream( <span class="keywordtype">void</span> );
  509. <a name="l00844"></a>00844 <span class="keywordtype">void</span> stopStream( <span class="keywordtype">void</span> );
  510. <a name="l00845"></a>00845 <span class="keywordtype">void</span> abortStream( <span class="keywordtype">void</span> );
  511. <a name="l00846"></a>00846 <span class="keywordtype">long</span> getStreamLatency( <span class="keywordtype">void</span> );
  512. <a name="l00847"></a>00847
  513. <a name="l00848"></a>00848 <span class="comment">// This function is intended for internal use only. It must be</span>
  514. <a name="l00849"></a>00849 <span class="comment">// public because it is called by the internal callback handler,</span>
  515. <a name="l00850"></a>00850 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
  516. <a name="l00851"></a>00851 <span class="comment">// will most likely produce highly undesireable results!</span>
  517. <a name="l00852"></a>00852 <span class="keywordtype">void</span> callbackEvent( <span class="keywordtype">void</span> );
  518. <a name="l00853"></a>00853
  519. <a name="l00854"></a>00854 <span class="keyword">private</span>:
  520. <a name="l00855"></a>00855
  521. <a name="l00856"></a>00856 <span class="keywordtype">bool</span> coInitialized_;
  522. <a name="l00857"></a>00857 <span class="keywordtype">bool</span> buffersRolling;
  523. <a name="l00858"></a>00858 <span class="keywordtype">long</span> duplexPrerollBytes;
  524. <a name="l00859"></a>00859 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channels,
  525. <a name="l00860"></a>00860 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  526. <a name="l00861"></a>00861 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferSize,
  527. <a name="l00862"></a>00862 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options );
  528. <a name="l00863"></a>00863 };
  529. <a name="l00864"></a>00864
  530. <a name="l00865"></a>00865 <span class="preprocessor">#endif</span>
  531. <a name="l00866"></a>00866 <span class="preprocessor"></span>
  532. <a name="l00867"></a>00867 <span class="preprocessor">#if defined(__LINUX_ALSA__)</span>
  533. <a name="l00868"></a>00868 <span class="preprocessor"></span>
  534. <a name="l00869"></a>00869 <span class="keyword">class </span>RtApiAlsa: <span class="keyword">public</span> RtApi
  535. <a name="l00870"></a>00870 {
  536. <a name="l00871"></a>00871 <span class="keyword">public</span>:
  537. <a name="l00872"></a>00872
  538. <a name="l00873"></a>00873 RtApiAlsa();
  539. <a name="l00874"></a>00874 ~RtApiAlsa();
  540. <a name="l00875"></a>00875 <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> getCurrentApi() { <span class="keywordflow">return</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849a7a2ba095c2806caa893b6fb8fc3a1a8">RtAudio::LINUX_ALSA</a>; };
  541. <a name="l00876"></a>00876 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDeviceCount( <span class="keywordtype">void</span> );
  542. <a name="l00877"></a>00877 <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> getDeviceInfo( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device );
  543. <a name="l00878"></a>00878 <span class="keywordtype">void</span> closeStream( <span class="keywordtype">void</span> );
  544. <a name="l00879"></a>00879 <span class="keywordtype">void</span> startStream( <span class="keywordtype">void</span> );
  545. <a name="l00880"></a>00880 <span class="keywordtype">void</span> stopStream( <span class="keywordtype">void</span> );
  546. <a name="l00881"></a>00881 <span class="keywordtype">void</span> abortStream( <span class="keywordtype">void</span> );
  547. <a name="l00882"></a>00882
  548. <a name="l00883"></a>00883 <span class="comment">// This function is intended for internal use only. It must be</span>
  549. <a name="l00884"></a>00884 <span class="comment">// public because it is called by the internal callback handler,</span>
  550. <a name="l00885"></a>00885 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
  551. <a name="l00886"></a>00886 <span class="comment">// will most likely produce highly undesireable results!</span>
  552. <a name="l00887"></a>00887 <span class="keywordtype">void</span> callbackEvent( <span class="keywordtype">void</span> );
  553. <a name="l00888"></a>00888
  554. <a name="l00889"></a>00889 <span class="keyword">private</span>:
  555. <a name="l00890"></a>00890
  556. <a name="l00891"></a>00891 std::vector&lt;RtAudio::DeviceInfo&gt; devices_;
  557. <a name="l00892"></a>00892 <span class="keywordtype">void</span> saveDeviceInfo( <span class="keywordtype">void</span> );
  558. <a name="l00893"></a>00893 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channels,
  559. <a name="l00894"></a>00894 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  560. <a name="l00895"></a>00895 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferSize,
  561. <a name="l00896"></a>00896 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options );
  562. <a name="l00897"></a>00897 };
  563. <a name="l00898"></a>00898
  564. <a name="l00899"></a>00899 <span class="preprocessor">#endif</span>
  565. <a name="l00900"></a>00900 <span class="preprocessor"></span>
  566. <a name="l00901"></a>00901 <span class="preprocessor">#if defined(__LINUX_OSS__)</span>
  567. <a name="l00902"></a>00902 <span class="preprocessor"></span>
  568. <a name="l00903"></a>00903 <span class="keyword">class </span>RtApiOss: <span class="keyword">public</span> RtApi
  569. <a name="l00904"></a>00904 {
  570. <a name="l00905"></a>00905 <span class="keyword">public</span>:
  571. <a name="l00906"></a>00906
  572. <a name="l00907"></a>00907 RtApiOss();
  573. <a name="l00908"></a>00908 ~RtApiOss();
  574. <a name="l00909"></a>00909 <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> getCurrentApi() { <span class="keywordflow">return</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d84939c84615e61de75e6a4e865596d62c82">RtAudio::LINUX_OSS</a>; };
  575. <a name="l00910"></a>00910 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDeviceCount( <span class="keywordtype">void</span> );
  576. <a name="l00911"></a>00911 <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> getDeviceInfo( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device );
  577. <a name="l00912"></a>00912 <span class="keywordtype">void</span> closeStream( <span class="keywordtype">void</span> );
  578. <a name="l00913"></a>00913 <span class="keywordtype">void</span> startStream( <span class="keywordtype">void</span> );
  579. <a name="l00914"></a>00914 <span class="keywordtype">void</span> stopStream( <span class="keywordtype">void</span> );
  580. <a name="l00915"></a>00915 <span class="keywordtype">void</span> abortStream( <span class="keywordtype">void</span> );
  581. <a name="l00916"></a>00916
  582. <a name="l00917"></a>00917 <span class="comment">// This function is intended for internal use only. It must be</span>
  583. <a name="l00918"></a>00918 <span class="comment">// public because it is called by the internal callback handler,</span>
  584. <a name="l00919"></a>00919 <span class="comment">// which is not a member of RtAudio. External use of this function</span>
  585. <a name="l00920"></a>00920 <span class="comment">// will most likely produce highly undesireable results!</span>
  586. <a name="l00921"></a>00921 <span class="keywordtype">void</span> callbackEvent( <span class="keywordtype">void</span> );
  587. <a name="l00922"></a>00922
  588. <a name="l00923"></a>00923 <span class="keyword">private</span>:
  589. <a name="l00924"></a>00924
  590. <a name="l00925"></a>00925 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channels,
  591. <a name="l00926"></a>00926 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  592. <a name="l00927"></a>00927 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferSize,
  593. <a name="l00928"></a>00928 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options );
  594. <a name="l00929"></a>00929 };
  595. <a name="l00930"></a>00930
  596. <a name="l00931"></a>00931 <span class="preprocessor">#endif</span>
  597. <a name="l00932"></a>00932 <span class="preprocessor"></span>
  598. <a name="l00933"></a>00933 <span class="preprocessor">#if defined(__RTAUDIO_DUMMY__)</span>
  599. <a name="l00934"></a>00934 <span class="preprocessor"></span>
  600. <a name="l00935"></a>00935 <span class="keyword">class </span>RtApiDummy: <span class="keyword">public</span> RtApi
  601. <a name="l00936"></a>00936 {
  602. <a name="l00937"></a>00937 <span class="keyword">public</span>:
  603. <a name="l00938"></a>00938
  604. <a name="l00939"></a>00939 RtApiDummy() { errorText_ = <span class="stringliteral">"RtApiDummy: This class provides no functionality."</span>; error( <a class="code" href="classRtError.html#b04667aae01bffc354a9ac6bda6903ac3a1603c24a56cbdaf5f8ae4ddcb86398">RtError::WARNING</a> ); };
  605. <a name="l00940"></a>00940 <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849" title="Audio API specifier arguments.">RtAudio::Api</a> getCurrentApi( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> <a class="code" href="classRtAudio.html#c9b6f625da88249d08a8409a9db0d849b06b8fd88bf18c9a2b8271f6961ae2d1">RtAudio::RTAUDIO_DUMMY</a>; };
  606. <a name="l00941"></a>00941 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> getDeviceCount( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> 0; };
  607. <a name="l00942"></a>00942 <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> getDeviceInfo( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device ) { <a class="code" href="structRtAudio_1_1DeviceInfo.html" title="The public device information structure for returning queried values.">RtAudio::DeviceInfo</a> info; <span class="keywordflow">return</span> info; };
  608. <a name="l00943"></a>00943 <span class="keywordtype">void</span> closeStream( <span class="keywordtype">void</span> ) {};
  609. <a name="l00944"></a>00944 <span class="keywordtype">void</span> startStream( <span class="keywordtype">void</span> ) {};
  610. <a name="l00945"></a>00945 <span class="keywordtype">void</span> stopStream( <span class="keywordtype">void</span> ) {};
  611. <a name="l00946"></a>00946 <span class="keywordtype">void</span> abortStream( <span class="keywordtype">void</span> ) {};
  612. <a name="l00947"></a>00947
  613. <a name="l00948"></a>00948 <span class="keyword">private</span>:
  614. <a name="l00949"></a>00949
  615. <a name="l00950"></a>00950 <span class="keywordtype">bool</span> probeDeviceOpen( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> device, StreamMode mode, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channels,
  616. <a name="l00951"></a>00951 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> firstChannel, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate,
  617. <a name="l00952"></a>00952 <a class="code" href="RtAudio_8h.html#afca92882d25915560018873221e44b8" title="RtAudio data format type.">RtAudioFormat</a> format, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *bufferSize,
  618. <a name="l00953"></a>00953 <a class="code" href="structRtAudio_1_1StreamOptions.html" title="The structure for specifying stream options.">RtAudio::StreamOptions</a> *options ) { <span class="keywordflow">return</span> <span class="keyword">false</span>; };
  619. <a name="l00954"></a>00954 };
  620. <a name="l00955"></a>00955
  621. <a name="l00956"></a>00956 <span class="preprocessor">#endif</span>
  622. <a name="l00957"></a>00957 <span class="preprocessor"></span>
  623. <a name="l00958"></a>00958 <span class="preprocessor">#endif</span>
  624. <a name="l00959"></a>00959 <span class="preprocessor"></span>
  625. <a name="l00960"></a>00960 <span class="comment">// Indentation settings for Vim and Emacs</span>
  626. <a name="l00961"></a>00961 <span class="comment">//</span>
  627. <a name="l00962"></a>00962 <span class="comment">// Local Variables:</span>
  628. <a name="l00963"></a>00963 <span class="comment">// c-basic-offset: 2</span>
  629. <a name="l00964"></a>00964 <span class="comment">// indent-tabs-mode: nil</span>
  630. <a name="l00965"></a>00965 <span class="comment">// End:</span>
  631. <a name="l00966"></a>00966 <span class="comment">//</span>
  632. <a name="l00967"></a>00967 <span class="comment">// vim: et sts=2 sw=2</span>
  633. </pre></div></div>
  634. <HR>
  635. <table><tr><td><img src="../images/mcgill.gif" width=165></td>
  636. <td>&copy;2001-2009 Gary P. Scavone, McGill University. All Rights Reserved.<br>Maintained by <a href="http://www.music.mcgill.ca/~gary/">Gary P. Scavone</a>.</td></tr>
  637. </table>
  638. </BODY>
  639. </HTML>