Sophie

Sophie

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

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: Opening a Stream Using Defaults</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">Opening a Stream Using Defaults </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The next step is to open a stream, which is similar to opening a file. You can specify whether you want audio input and/or output, how many channels, the data format, sample rate, etc. Opening a ''default'' stream means opening the default input and output devices, which saves you the trouble of getting a list of devices and choosing one from the list. (We'll see how to do that later.) </p>
<div class="fragment"><div class="line"><span class="preprocessor">#define SAMPLE_RATE (44100)</span></div>
<div class="line"><span class="preprocessor"></span><span class="keyword">static</span> <a class="code" href="structpaTestData.html">paTestData</a> data;</div>
<div class="line"></div>
<div class="line">.....</div>
<div class="line"></div>
<div class="line">    <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> err;</div>
<div class="line"></div>
<div class="line">    <span class="comment">/* Open an audio I/O stream. */</span></div>
<div class="line">    err = <a class="code" href="portaudio_8h.html#a0a12735ac191200f696a43b87667b714">Pa_OpenDefaultStream</a>( &amp;stream,</div>
<div class="line">                                0,          <span class="comment">/* no input channels */</span></div>
<div class="line">                                2,          <span class="comment">/* stereo output */</span></div>
<div class="line">                                <a class="code" href="portaudio_8h.html#a2f16d29916725b8791eae60ab9e0b081">paFloat32</a>,  <span class="comment">/* 32 bit floating point output */</span></div>
<div class="line">                                SAMPLE_RATE,</div>
<div class="line">                                256,        <span class="comment">/* frames per buffer, i.e. the number</span></div>
<div class="line"><span class="comment">                                                   of sample frames that PortAudio will</span></div>
<div class="line"><span class="comment">                                                   request from the callback. Many apps</span></div>
<div class="line"><span class="comment">                                                   may want to use</span></div>
<div class="line"><span class="comment">                                                   paFramesPerBufferUnspecified, which</span></div>
<div class="line"><span class="comment">                                                   tells PortAudio to pick the best,</span></div>
<div class="line"><span class="comment">                                                   possibly changing, buffer size.*/</span></div>
<div class="line">                                patestCallback, <span class="comment">/* this is your callback function */</span></div>
<div class="line">                                &amp;data ); <span class="comment">/*This is a pointer that will be passed to</span></div>
<div class="line"><span class="comment">                                                   your callback*/</span></div>
<div class="line">    <span class="keywordflow">if</span>( err != paNoError ) <span class="keywordflow">goto</span> error;</div>
</div><!-- fragment --><p>The data structure and callback are described in <a class="el" href="writing_a_callback.html">Writing a Callback Function</a>.</p>
<p>The above example opens the stream for writing, which is sufficient for playback. It is also possible to open a stream for reading, to do recording, or both reading and writing, for simultaneous recording and playback or even real-time audio processing. If you plan to do playback and recording at the same time, open only one stream with valid input and output parameters.</p>
<p>There are some caveats to note about simultaneous read/write:</p>
<ul>
<li>Some platforms can only open a read/write stream using the same device.</li>
<li>Although multiple streams can be opened, it is difficult to synchronize them.</li>
<li>Some platforms don't support opening multiple streams on the same device.</li>
<li>Using multiple streams may not be as well tested as other features.</li>
<li>The PortAudio library calls must be made from the same thread or synchronized by the user.</li>
</ul>
<p>Previous: <a class="el" href="initializing_portaudio.html">Initializing PortAudio</a> | Next: <a class="el" href="start_stop_abort.html">Starting, Stopping and Aborting a Stream</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>