Release 4.2.1 tarball

This commit is contained in:
Gary Scavone
2013-09-29 23:40:35 +02:00
committed by Stephen Sinclair
parent 11cf5faa0a
commit 21b93795e7
1041 changed files with 23984 additions and 16348 deletions

View File

@@ -8,71 +8,57 @@
<img src="princeton.gif"> &nbsp; <img src="ccrma.gif"> &nbsp; <img src="mcgill.gif"><P>
<a class="qindex" href="index.html">Home</a> &nbsp; <a class="qindex" href="information.html">Information</a> &nbsp; <a class="qindex" href="classes.html">Classes</a> &nbsp; <a class="qindex" href="download.html">Download</a> &nbsp; <a class="qindex" href="usage.html">Usage</a> &nbsp; <a class="qindex" href="maillist.html">Mail List</a> &nbsp; <a class="qindex" href="system.html">Requirements</a> &nbsp; <a class="qindex" href="links.html">Links</a> &nbsp; <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
<HR>
<!-- Generated by Doxygen 1.3.4 -->
<!-- Generated by Doxygen 1.4.4 -->
<h1><a class="anchor" name="multichannel">Multi-Channel I/O</a></h1>The ToolKit <a class="el" href="classWvIn.html">WvIn</a> and <a class="el" href="classWvOut.html">WvOut</a> classes (and their subclasses) support multi-channel audio data input and output. A set of interleaved audio samples representing a single time "slice" is referred to as a <em>sample frame</em>. At a sample rate of 44.1 kHz, a four-channel audio stream will have 44100 sample frames per second and a total of 176400 individual samples per second.<p>
Most STK classes process single-sample data streams via their <code>tick()</code> function. In order to distinguish single-sample and sample frame calculations, the <a class="el" href="classWvIn.html">WvIn</a> and <a class="el" href="classWvOut.html">WvOut</a> classes implement both <code>tick()</code> and <code>tickFrame()</code> functions. The <code>tickFrame()</code> functions take or return a pointer to an array of audio data representing one or more sample frames. For single-channel streams, the <code>tick()</code> and <code>tickFrame()</code> functions produce equivalent results. When <code>tick()</code> is called for a multi-channel stream, however, the function either returns a sample frame average (<a class="el" href="classWvIn.html">WvIn</a>) or writes a single sample argument to all channels (<a class="el" href="classWvOut.html">WvOut</a>).<p>
Most STK classes process single-sample data streams via their <code>tick()</code> function. In order to distinguish single-sample and sample frame calculations, the <a class="el" href="classWvIn.html">WvIn</a> and <a class="el" href="classWvOut.html">WvOut</a> classes implement both <code>tick()</code> and <code>tickFrame()</code> functions. The <code>tickFrame()</code> functions take or return a reference to an <a class="el" href="classStkFrames.html">StkFrames</a> object representing one or more sample frames. For single-channel streams, the <code>tick()</code> and <code>tickFrame()</code> functions produce equivalent results. When <code>tick()</code> is called for a multi-channel stream, however, the function either returns a sample frame average (<a class="el" href="classWvIn.html">WvIn</a>) or writes a single sample argument to all channels (<a class="el" href="classWvOut.html">WvOut</a>).<p>
Multi-channel support for realtime audio input and output is dependent on the audio device(s) available on your system.<p>
The following example demonstrates the use of the <a class="el" href="classWvOut.html">WvOut</a> class for creating a four channel, 16-bit AIFF formatted audio file. We will use four sinewaves of different frequencies for the first two seconds and then a single sinewave for the last two seconds.<p>
<div class="fragment"><pre><span class="comment">// foursine.cpp STK tutorial program</span>
The following example demonstrates the use of the <a class="el" href="classFileWvOut.html">FileWvOut</a> class for creating a four channel, 16-bit AIFF formatted audio file. We will use four sinewaves of different frequencies for the first two seconds and then a single sinewave for the last two seconds.<p>
<div class="fragment"><pre class="fragment"><span class="comment">// foursine.cpp STK tutorial program</span>
<span class="preprocessor">#include "WaveLoop.h"</span>
<span class="preprocessor">#include "WvOut.h"</span>
<span class="preprocessor">#include "SineWave.h"</span>
<span class="preprocessor">#include "FileWvOut.h"</span>
<span class="keywordtype">int</span> main()
{
<span class="comment">// Set the global sample rate before creating class instances.</span>
<a class="code" href="classStk.html#e1">Stk::setSampleRate</a>( 44100.0 );
<span class="keywordtype">int</span> i, j;
<a class="code" href="classWvOut.html">WvOut</a> *output = 0;
<a class="code" href="classWaveLoop.html">WaveLoop</a> *inputs[4];
<span class="keywordflow">for</span> ( i=0; i&lt;4; i++ ) inputs[i] = 0;
<span class="keywordtype">int</span> i;
<a class="code" href="classFileWvOut.html">FileWvOut</a> output;
<a class="code" href="classSineWave.html">SineWave</a> inputs[4];
<span class="comment">// Define and load the sine waves</span>
<span class="keywordflow">try</span> {
<span class="keywordflow">for</span> ( i=0; i&lt;4; i++ ) {
inputs[i] = <span class="keyword">new</span> <a class="code" href="classWaveLoop.html">WaveLoop</a>( <span class="stringliteral">"rawwaves/sinewave.raw"</span>, <span class="keyword">true</span> );
inputs[i]-&gt;<a class="code" href="classWaveLoop.html#a2">setFrequency</a>( 220.0 * (i+1) );
}
}
<span class="keywordflow">catch</span> (<a class="code" href="classStkError.html">StkError</a> &amp;) {
<span class="keywordflow">goto</span> cleanup;
}
<span class="comment">// Set the sine wave frequencies.</span>
<span class="keywordflow">for</span> ( i=0; i&lt;4; i++ )
inputs[i].<a class="code" href="classSineWave.html#a4">setFrequency</a>( 220.0 * (i+1) );
<span class="comment">// Define and open a 16-bit, four-channel AIFF formatted output file</span>
<span class="keywordflow">try</span> {
output = <span class="keyword">new</span> <a class="code" href="classWvOut.html">WvOut</a>( <span class="stringliteral">"foursine.aif"</span>, 4, WvOut::WVOUT_AIF, Stk::STK_SINT16 );
output.<a class="code" href="classFileWvOut.html#a3">openFile</a>( <span class="stringliteral">"foursine.aif"</span>, 4, <a class="code" href="classFileWrite.html#s3">FileWrite::FILE_AIF</a>, <a class="code" href="classStk.html#s1">Stk::STK_SINT16</a> );
}
<span class="keywordflow">catch</span> (<a class="code" href="classStkError.html">StkError</a> &amp;) {
<span class="keywordflow">goto</span> cleanup;
exit(0);
}
<span class="comment">// Write two seconds of four sines to the output file</span>
StkFloat frame[4];
<span class="keywordflow">for</span> ( j=0; j&lt;88200; j++ ) {
<span class="keywordflow">for</span> ( i=0; i&lt;4; i++ )
frame[i] = inputs[i]-&gt;<a class="code" href="classWvIn.html#a16">tick</a>();
<a class="code" href="classStkFrames.html">StkFrames</a> frames( 88200, 4 );
<span class="keywordflow">for</span> ( i=0; i&lt;4; i++ )
inputs[i].<a class="code" href="classGenerator.html#a3">tick</a>( frames, i );
output-&gt;<a class="code" href="classWvOut.html#a12">tickFrame</a>( frame );
}
output.<a class="code" href="classWvOut.html#a8">tickFrame</a>( frames );
<span class="comment">// Now write the first sine to all four channels for two seconds</span>
<span class="keywordflow">for</span> ( j=0; j&lt;88200; j++ ) {
output-&gt;<a class="code" href="classWvOut.html#a9">tick</a>( inputs[0]-&gt;tick() );
<span class="keywordflow">for</span> ( i=0; i&lt;88200; i++ ) {
output.<a class="code" href="classWvOut.html#a6">tick</a>( inputs[0].tick() );
}
cleanup:
<span class="keywordflow">for</span> ( i=0; i&lt;4; i++ ) <span class="keyword">delete</span> inputs[i];
<span class="keyword">delete</span> output;
<span class="keywordflow">return</span> 0;
}
</pre></div><p>
[<a href="polyvoices.html">Next tutorial</a>] &nbsp; [<a href="tutorial.html">Main tutorial page</a>] <HR>
[<a href="tutorial.html">Main tutorial page</a>] &nbsp; [<a href="polyvoices.html">Next tutorial</a>] <HR>
<table>
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
<tr><td>&copy;1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
<tr><td>&copy;1995-2005 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>