Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > 866ae5f99ebc53131e4da7c8445c0009 > files > 217

portaudio-devel-19-16.fc18.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>PortAudio: Utility Functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">PortAudio
   &#160;<span id="projectnumber">2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Utility Functions </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>In addition to the functions described elsewhere in this tutorial, PortAudio provides a number of Utility functions that are useful in a variety of circumstances. You'll want to read the <a class="el" href="portaudio_8h.html" title="The portable PortAudio API.">portaudio.h</a> reference, which documents the entire V19 API for details, but we'll try to cover the basics here.</p>
<h1><a class="anchor" id="tut_util2"></a>
Version Information</h1>
<p>PortAudio offers two functions to determine the PortAudio Version. This is most useful when you are using PortAudio as a dynamic library, but it may also be useful at other times.</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span>             <a class="code" href="portaudio_8h.html#a66da08bcf908e0849c62a6b47f50d7b4">Pa_GetVersion</a> (<span class="keywordtype">void</span>)</div>
<div class="line">const <span class="keywordtype">char</span> *    <a class="code" href="portaudio_8h.html#a28f3fd9e6d9f933cc695abea71c4b445">Pa_GetVersionText</a> (<span class="keywordtype">void</span>)</div>
</div><!-- fragment --><h1><a class="anchor" id="tut_util3"></a>
Error Text</h1>
<p>PortAudio allows you to get error text from an error number.</p>
<div class="fragment"><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *    <a class="code" href="portaudio_8h.html#ae606855a611cf29c7d2d7421df5e3b5d">Pa_GetErrorText</a> (<a class="code" href="portaudio_8h.html#a4949e4a8ef9f9dbe8cbee414ce69841d">PaError</a> errorCode)</div>
</div><!-- fragment --><h1><a class="anchor" id="tut_util4"></a>
Stream State</h1>
<p>PortAudio Streams exist in 3 states: Active, Stopped, and Callback Stopped. If a stream is in callback stopped state, you'll need to stop it before you can start it again. If you need to query the state of a PortAudio stream, there are two functions for doing so:</p>
<div class="fragment"><div class="line"><a class="code" href="portaudio_8h.html#a4949e4a8ef9f9dbe8cbee414ce69841d">PaError</a>     <a class="code" href="portaudio_8h.html#a52d778c985ae9d566de7e13529cc771f">Pa_IsStreamStopped</a> (<a class="code" href="portaudio_8h.html#a19874734f89958fccf86785490d53b4c">PaStream</a> *stream)</div>
<div class="line"><a class="code" href="portaudio_8h.html#a4949e4a8ef9f9dbe8cbee414ce69841d">PaError</a>     <a class="code" href="portaudio_8h.html#a1f8709c4971932643681a6f374c4bb5a">Pa_IsStreamActive</a> (<a class="code" href="portaudio_8h.html#a19874734f89958fccf86785490d53b4c">PaStream</a> *stream)</div>
</div><!-- fragment --><h1><a class="anchor" id="tut_util5"></a>
Stream Info</h1>
<p>If you need to retrieve info about a given stream, such as latency, and sample rate info, there's a function for that too:</p>
<div class="fragment"><div class="line"><span class="keyword">const</span> <a class="code" href="structPaStreamInfo.html">PaStreamInfo</a> *    <a class="code" href="portaudio_8h.html#a3d9c4cbda4e9f381b76f287c3de8a758">Pa_GetStreamInfo</a> (<a class="code" href="portaudio_8h.html#a19874734f89958fccf86785490d53b4c">PaStream</a> *stream)</div>
</div><!-- fragment --><h1><a class="anchor" id="tut_util6"></a>
Stream Time</h1>
<p>If you need to synchronise other activities such as display updates or MIDI output with the PortAudio callback you need to know the current time according to the same timebase used by the stream callback timestamps.</p>
<div class="fragment"><div class="line"><a class="code" href="portaudio_8h.html#af17a7e6d0471a23071acf8dbd7bbe4bd">PaTime</a>  <a class="code" href="portaudio_8h.html#a2b3fb60e6949f37f7f134105ff425749">Pa_GetStreamTime</a> (<a class="code" href="portaudio_8h.html#a19874734f89958fccf86785490d53b4c">PaStream</a> *stream)</div>
</div><!-- fragment --><h1><a class="anchor" id="tut_util6CPU"></a>
Usage</h1>
<p>To determine how much CPU is being used by the callback, use these:</p>
<div class="fragment"><div class="line"><span class="keywordtype">double</span>  <a class="code" href="portaudio_8h.html#a83b8c624464dd7bb6a01b06ab596c115">Pa_GetStreamCpuLoad</a> (<a class="code" href="portaudio_8h.html#a19874734f89958fccf86785490d53b4c">PaStream</a> *stream)</div>
</div><!-- fragment --><h1><a class="anchor" id="tut_util7"></a>
Other utilities</h1>
<p>These functions allow you to determine the size of a sample from its format and sleep for a given amount of time. The sleep function should not be used for precise timing or synchronization because it makes few guarantees about the exact length of time it waits. It is most useful for testing.</p>
<div class="fragment"><div class="line"><a class="code" href="portaudio_8h.html#a4949e4a8ef9f9dbe8cbee414ce69841d">PaError</a> <a class="code" href="portaudio_8h.html#a541ed0b734df2631bc4c229acf92abc1">Pa_GetSampleSize</a> (<a class="code" href="portaudio_8h.html#a4582d93c2c2e60e12be3d74c5fe00b96">PaSampleFormat</a> format)</div>
<div class="line"><span class="keywordtype">void</span>    <a class="code" href="portaudio_8h.html#a1b3c20044c9401c42add29475636e83d">Pa_Sleep</a> (<span class="keywordtype">long</span> msec)</div>
</div><!-- fragment --><p>Previous: <a class="el" href="terminating_portaudio.html">Closing a Stream and Terminating PortAudio</a> | Next: <a class="el" href="querying_devices.html">Enumerating and Querying PortAudio Devices</a> </p>
</div></div><!-- contents -->
<hr size="1"><address style="text-align: right;"><small>Generated for PortAudio by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a>1.8.3.1</small></address>
</body>
</html>