mirror of
https://github.com/thestk/stk
synced 2026-04-19 22:16:54 +00:00
Release 4.3.0 tarball
This commit is contained in:
committed by
Stephen Sinclair
parent
554a74374b
commit
1a8403e203
@@ -6,7 +6,7 @@
|
||||
<BODY BGCOLOR="#FFFFFF">
|
||||
<CENTER>
|
||||
<img src="princeton.gif"> <img src="ccrma.gif"> <img src="mcgill.gif"><P>
|
||||
<a class="qindex" href="index.html">Home</a> <a class="qindex" href="information.html">Information</a> <a class="qindex" href="classes.html">Classes</a> <a class="qindex" href="download.html">Download</a> <a class="qindex" href="usage.html">Usage</a> <a class="qindex" href="maillist.html">Mail List</a> <a class="qindex" href="system.html">Requirements</a> <a class="qindex" href="links.html">Links</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
|
||||
<a class="qindex" href="index.html">Home</a> <a class="qindex" href="information.html">Information</a> <a class="qindex" href="classes.html">Classes</a> <a class="qindex" href="download.html">Download</a> <a class="qindex" href="usage.html">Usage</a> <a class="qindex" href="maillist.html">Mail List</a> <a class="qindex" href="system.html">Requirements</a> <a class="qindex" href="links.html">Links</a> <a class="qindex" href="faq.html">FAQ</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
|
||||
<HR>
|
||||
<!-- Generated by Doxygen 1.4.4 -->
|
||||
<h1><a class="anchor" name="realtime">Realtime Audio (blocking)</a></h1>In this section, we modify the <code>sineosc.cpp</code> program in order to send the output to the default audio playback device on your computer system. We also make use of the <a class="el" href="classSineWave.html">SineWave</a> class as a sine-wave oscillator. <a class="el" href="classSineWave.html">SineWave</a> computes an internal, static sine-wave table when its first instance is created. Subsequent instances make use of the same table. The default table length, specified in <a class="el" href="SineWave_8h-source.html">SineWave.h</a>, is 2048 samples.<p>
|
||||
@@ -19,27 +19,27 @@
|
||||
{
|
||||
<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 );
|
||||
<a class="code" href="classStk.html#e10">Stk::showWarnings</a>( <span class="keyword">true</span> );
|
||||
|
||||
<a class="code" href="classSineWave.html">SineWave</a> sine;
|
||||
<a class="code" href="classRtWvOut.html">RtWvOut</a> *dac = 0;
|
||||
|
||||
<span class="keywordflow">try</span> {
|
||||
<span class="comment">// Define and open the default realtime output device for one-channel playback</span>
|
||||
dac = <span class="keyword">new</span> <a class="code" href="classRtWvOut.html">RtWvOut</a>(1);
|
||||
dac = <span class="keyword">new</span> <a class="code" href="classRtWvOut.html">RtWvOut</a>( 1 );
|
||||
}
|
||||
<span class="keywordflow">catch</span> (<a class="code" href="classStkError.html">StkError</a> &) {
|
||||
<span class="keywordflow">catch</span> ( <a class="code" href="classStkError.html">StkError</a> & ) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
sine.<a class="code" href="classSineWave.html#a4">setFrequency</a>(440.0);
|
||||
sine.<a class="code" href="classSineWave.html#a4">setFrequency</a>( 441.0 );
|
||||
|
||||
<span class="comment">// Play the oscillator for 40000 samples</span>
|
||||
<span class="keywordtype">int</span> i;
|
||||
<span class="keywordflow">for</span> ( i=0; i<40000; i++ ) {
|
||||
<span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i<40000; i++ ) {
|
||||
<span class="keywordflow">try</span> {
|
||||
dac-><a class="code" href="classWvOut.html#a6">tick</a>( sine.<a class="code" href="classGenerator.html#a3">tick</a>() );
|
||||
}
|
||||
<span class="keywordflow">catch</span> (<a class="code" href="classStkError.html">StkError</a> &) {
|
||||
}
|
||||
<span class="keywordflow">catch</span> ( <a class="code" href="classStkError.html">StkError</a> & ) {
|
||||
<span class="keywordflow">goto</span> cleanup;
|
||||
}
|
||||
}
|
||||
@@ -50,10 +50,10 @@
|
||||
<span class="keywordflow">return</span> 0;
|
||||
}
|
||||
</pre></div><p>
|
||||
The class <a class="el" href="classRtWvOut.html">RtWvOut</a> is a protected subclass of <a class="el" href="classWvOut.html">WvOut</a>. A number of optional constructor arguments can be used to fine tune its performance for a given system. <a class="el" href="classRtWvOut.html">RtWvOut</a> provides a "single-sample" interface to the <a class="el" href="classRtAudio.html">RtAudio</a> class. Note that <a class="el" href="classRtWvOut.html">RtWvOut</a> (as well as the <a class="el" href="classRtWvIn.html">RtWvIn</a> and <a class="el" href="classRtDuplex.html">RtDuplex</a> classes described below) make use of RtAudio's blocking input/output functionality. On systems that implement an inherently callback-based audio API (Linux Jack, Windows ASIO, OS-X CoreAudio), this blocking functionality will be less robust. An example of audio output using a callback scheme will be discussed in a subsequent tutorial section.<p>
|
||||
The class <a class="el" href="classRtWvOut.html">RtWvOut</a> is a protected subclass of <a class="el" href="classWvOut.html">WvOut</a>. A number of optional constructor arguments can be used to fine tune its performance for a given system. <a class="el" href="classRtWvOut.html">RtWvOut</a> provides a "single-sample", blocking interface to the <a class="el" href="classRtAudio.html">RtAudio</a> class. Note that <a class="el" href="classRtWvOut.html">RtWvOut</a> (as well as the <a class="el" href="classRtWvIn.html">RtWvIn</a> class described below) makes use of RtAudio's callback input/output functionality by creating a large ring-buffer into which data is written. These classes should not be used when low-latency and robust performance is necessary<p>
|
||||
Though not used here, an <a class="el" href="classRtWvIn.html">RtWvIn</a> class exists as well that can be used to read realtime audio data from an input device. See the <code>record.cpp</code> example program in the <code>examples</code> project for more information.<p>
|
||||
It may be possible to use an instance of <a class="el" href="classRtWvOut.html">RtWvOut</a> and an instance of <a class="el" href="classRtWvIn.html">RtWvIn</a> to simultaneously read and write realtime audio to and from a hardware device or devices. However, it is recommended to instead use a single instance of <a class="el" href="classRtDuplex.html">RtDuplex</a> to achieve this behavior, in that it guarantees better synchronization between the input and output data. See the <code>effects</code> project or the <code>io.cpp</code> example program in the <code>examples</code> project for more information.<p>
|
||||
When using any realtime STK class (<a class="el" href="classRtAudio.html">RtAudio</a>, <a class="el" href="classRtWvOut.html">RtWvOut</a>, <a class="el" href="classRtWvIn.html">RtWvIn</a>, <a class="el" href="classRtDuplex.html">RtDuplex</a>, <a class="el" href="classRtMidi.html">RtMidi</a>, <a class="el" href="classInetWvIn.html">InetWvIn</a>, <a class="el" href="classInetWvOut.html">InetWvOut</a>, <a class="el" href="classSocket.html">Socket</a>, <a class="el" href="classUdpSocket.html">UdpSocket</a>, <a class="el" href="classTcpServer.html">TcpServer</a>, <a class="el" href="classTcpClient.html">TcpClient</a>, and <a class="el" href="classThread.html">Thread</a>), it is necessary to specify an audio/MIDI API preprocessor definition and link with the appropriate libraries or frameworks. For example, the above program could be compiled on a Linux system using the GNU g++ compiler and the ALSA audio API as follows (assuming all necessary files exist in the project directory):<p>
|
||||
It may be possible to use an instance of <a class="el" href="classRtWvOut.html">RtWvOut</a> and an instance of <a class="el" href="classRtWvIn.html">RtWvIn</a> to simultaneously read and write realtime audio to and from a hardware device or devices. However, it is recommended to instead use a single instance of <a class="el" href="classRtAudio.html">RtAudio</a> to achieve this behavior, as described in the next section. See the <code>effects</code> project or the <code>duplex.cpp</code> example program in the <code>examples</code> project for more information.<p>
|
||||
When using any realtime STK class (<a class="el" href="classRtAudio.html">RtAudio</a>, <a class="el" href="classRtWvOut.html">RtWvOut</a>, <a class="el" href="classRtWvIn.html">RtWvIn</a>, RtDuplex, <a class="el" href="classRtMidi.html">RtMidi</a>, <a class="el" href="classInetWvIn.html">InetWvIn</a>, <a class="el" href="classInetWvOut.html">InetWvOut</a>, <a class="el" href="classSocket.html">Socket</a>, <a class="el" href="classUdpSocket.html">UdpSocket</a>, <a class="el" href="classTcpServer.html">TcpServer</a>, <a class="el" href="classTcpClient.html">TcpClient</a>, and <a class="el" href="classThread.html">Thread</a>), it is necessary to specify an audio/MIDI API preprocessor definition and link with the appropriate libraries or frameworks. For example, the above program could be compiled on a Linux system using the GNU g++ compiler and the ALSA audio API as follows (assuming all necessary files exist in the project directory):<p>
|
||||
<div class="fragment"><pre class="fragment">g++ -Wall -D__LINUX_ALSA__ -D__LITTLE_ENDIAN__ -o rtsine <a class="code" href="classStk.html">Stk</a>.cpp <a class="code" href="classGenerator.html">Generator</a>.cpp <a class="code" href="classSineWave.html">SineWave</a>.cpp <a class="code" href="classWvOut.html">WvOut</a>.cpp \
|
||||
<a class="code" href="classRtWvOut.html">RtWvOut</a>.cpp <a class="code" href="classRtAudio.html">RtAudio</a>.cpp rtsine.cpp -lpthread -lasound
|
||||
</pre></div><p>
|
||||
@@ -65,7 +65,7 @@ On a Macintosh OS X system, the syntax would be:<p>
|
||||
|
||||
<table>
|
||||
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
|
||||
<tr><td>©1995-2005 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
||||
<tr><td>©1995-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
||||
</table>
|
||||
|
||||
</BODY>
|
||||
|
||||
Reference in New Issue
Block a user