mirror of
https://github.com/thestk/stk
synced 2026-04-20 06:26:55 +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="polyvoices">Voice Management</a></h1>The previous tutorial chapters were concerned only with monophonic ToolKit instrument playback and control. At this point, it should be relatively clear that one can instantiate multiple instruments and perhaps sum together their outputs or even direct their outputs to separate channels. It is less clear how one might go about controlling a group of instruments. The <a class="el" href="classVoicer.html">Voicer</a> class is designed to serve just this purpose.<p>
|
||||
@@ -15,7 +15,7 @@ In the following example, we modify the <code>controlbee.cpp</code> program to m
|
||||
<div class="fragment"><pre class="fragment"><span class="comment">// threebees.cpp STK tutorial program</span>
|
||||
|
||||
<span class="preprocessor">#include "BeeThree.h"</span>
|
||||
<span class="preprocessor">#include "RtAudio.h"</span>
|
||||
<span class="preprocessor">#include "<a class="code" href="RtAudio_8h.html">RtAudio.h</a>"</span>
|
||||
<span class="preprocessor">#include "Messager.h"</span>
|
||||
<span class="preprocessor">#include "Voicer.h"</span>
|
||||
<span class="preprocessor">#include "SKINI.msg"</span>
|
||||
@@ -91,11 +91,12 @@ In the following example, we modify the <code>controlbee.cpp</code> program to m
|
||||
<span class="comment">// This tick() function handles sample computation and scheduling of</span>
|
||||
<span class="comment">// control updates. It will be called automatically when the system</span>
|
||||
<span class="comment">// needs a new buffer of audio samples.</span>
|
||||
<span class="keywordtype">int</span> tick(<span class="keywordtype">char</span> *buffer, <span class="keywordtype">int</span> bufferSize, <span class="keywordtype">void</span> *dataPointer)
|
||||
<span class="keywordtype">int</span> tick( <span class="keywordtype">void</span> *outputBuffer, <span class="keywordtype">void</span> *inputBuffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nBufferFrames,
|
||||
<span class="keywordtype">double</span> streamTime, <a class="code" href="RtAudio_8h.html#a11">RtAudioStreamStatus</a> status, <span class="keywordtype">void</span> *dataPointer )
|
||||
{
|
||||
TickData *data = (TickData *) dataPointer;
|
||||
<span class="keyword">register</span> StkFloat *samples = (StkFloat *) buffer;
|
||||
<span class="keywordtype">int</span> counter, nTicks = bufferSize;
|
||||
<span class="keyword">register</span> StkFloat *samples = (StkFloat *) outputBuffer;
|
||||
<span class="keywordtype">int</span> counter, nTicks = (int) nBufferFrames;
|
||||
|
||||
<span class="keywordflow">while</span> ( nTicks > 0 && !data->done ) {
|
||||
|
||||
@@ -133,17 +134,20 @@ In the following example, we modify the <code>controlbee.cpp</code> program to m
|
||||
|
||||
<span class="keywordtype">int</span> i;
|
||||
TickData data;
|
||||
<a class="code" href="classRtAudio.html">RtAudio</a> *dac = 0;
|
||||
<a class="code" href="classRtAudio.html">RtAudio</a> dac;
|
||||
<a class="code" href="classInstrmnt.html">Instrmnt</a> *instrument[3];
|
||||
<span class="keywordflow">for</span> ( i=0; i<3; i++ ) instrument[i] = 0;
|
||||
|
||||
<span class="comment">// Figure out how many bytes in an StkFloat and setup the RtAudio object.</span>
|
||||
RtAudioFormat format = ( <span class="keyword">sizeof</span>(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
|
||||
<span class="keywordtype">int</span> bufferSize = RT_BUFFER_SIZE;
|
||||
<span class="comment">// Figure out how many bytes in an StkFloat and setup the RtAudio stream.</span>
|
||||
<a class="code" href="structRtAudio_1_1StreamParameters.html">RtAudio::StreamParameters</a> parameters;
|
||||
parameters.<a class="code" href="structRtAudio_1_1StreamParameters.html#o0">deviceId</a> = dac.<a class="code" href="classRtAudio.html#a5">getDefaultOutputDevice</a>();
|
||||
parameters.<a class="code" href="structRtAudio_1_1StreamParameters.html#o1">nChannels</a> = 1;
|
||||
<a class="code" href="RtAudio_8h.html#a0">RtAudioFormat</a> format = ( <span class="keyword">sizeof</span>(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
|
||||
<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bufferFrames = RT_BUFFER_SIZE;
|
||||
<span class="keywordflow">try</span> {
|
||||
dac = <span class="keyword">new</span> <a class="code" href="classRtAudio.html">RtAudio</a>(0, 1, 0, 0, format, (<span class="keywordtype">int</span>)<a class="code" href="classStk.html#e0">Stk::sampleRate</a>(), &bufferSize, 4);
|
||||
dac.<a class="code" href="classRtAudio.html#a7">openStream</a>( &parameters, NULL, format, (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)Stk::sampleRate(), &bufferFrames, &tick, (<span class="keywordtype">void</span> *)&data );
|
||||
}
|
||||
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a>& error) {
|
||||
<span class="keywordflow">catch</span> ( <a class="code" href="classRtError.html">RtError</a> &error ) {
|
||||
error.<a class="code" href="classRtError.html#a2">printMessage</a>();
|
||||
<span class="keywordflow">goto</span> cleanup;
|
||||
}
|
||||
@@ -153,7 +157,7 @@ In the following example, we modify the <code>controlbee.cpp</code> program to m
|
||||
<span class="keywordflow">for</span> ( i=0; i<3; i++ )
|
||||
instrument[i] = <span class="keyword">new</span> <a class="code" href="classBeeThree.html">BeeThree</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;
|
||||
}
|
||||
|
||||
@@ -165,10 +169,9 @@ In the following example, we modify the <code>controlbee.cpp</code> program to m
|
||||
<span class="keywordflow">goto</span> cleanup;
|
||||
|
||||
<span class="keywordflow">try</span> {
|
||||
dac-><a class="code" href="classRtAudio.html#a6">setStreamCallback</a>(&tick, (<span class="keywordtype">void</span> *)&data);
|
||||
dac-><a class="code" href="classRtAudio.html#a13">startStream</a>();
|
||||
dac.<a class="code" href="classRtAudio.html#a9">startStream</a>();
|
||||
}
|
||||
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &error) {
|
||||
<span class="keywordflow">catch</span> ( <a class="code" href="classRtError.html">RtError</a> &error ) {
|
||||
error.<a class="code" href="classRtError.html#a2">printMessage</a>();
|
||||
<span class="keywordflow">goto</span> cleanup;
|
||||
}
|
||||
@@ -179,16 +182,14 @@ In the following example, we modify the <code>controlbee.cpp</code> program to m
|
||||
|
||||
<span class="comment">// Shut down the callback and output stream.</span>
|
||||
<span class="keywordflow">try</span> {
|
||||
dac-><a class="code" href="classRtAudio.html#a7">cancelStreamCallback</a>();
|
||||
dac-><a class="code" href="classRtAudio.html#a12">closeStream</a>();
|
||||
dac.<a class="code" href="classRtAudio.html#a8">closeStream</a>();
|
||||
}
|
||||
<span class="keywordflow">catch</span> (<a class="code" href="classRtError.html">RtError</a> &error) {
|
||||
<span class="keywordflow">catch</span> ( <a class="code" href="classRtError.html">RtError</a> &error ) {
|
||||
error.<a class="code" href="classRtError.html#a2">printMessage</a>();
|
||||
}
|
||||
|
||||
cleanup:
|
||||
<span class="keywordflow">for</span> ( i=0; i<3; i++ ) <span class="keyword">delete</span> instrument[i];
|
||||
<span class="keyword">delete</span> dac;
|
||||
|
||||
<span class="keywordflow">return</span> 0;
|
||||
}
|
||||
@@ -196,13 +197,13 @@ In the following example, we modify the <code>controlbee.cpp</code> program to m
|
||||
We have written this program to accept control messages from <code>STDIN</code>. Assuming the program is compiled as <code>threebees</code>, the three-voice SKINI scorefile <a href="tutorial/bachfugue.ski"><code>bachfugue.ski</code></a> (located in the <code>scores</code> directory with the examples) can be redirected to the program as:<p>
|
||||
<div class="fragment"><pre class="fragment">threebees < scores/bachfugue.ski
|
||||
</pre></div><p>
|
||||
For more fun, surf to <a href="http://kern.humdrum.net/">Kern Scores</a> for a huge assortment of other scorefiles which can be downloaded in the SKINI format.<p>
|
||||
For more fun, surf to <a href="http://kern.humdrum.net/">Kern Scores</a> for a huge assortment of other scorefiles that can be downloaded in the SKINI format.<p>
|
||||
Another easy extension would be to add the <code><a class="el" href="classMessager.html#a7">Messager::startMidiInput()</a></code> function to the program and then play the instruments via a MIDI keyboard.<p>
|
||||
[<a href="tutorial.html">Main tutorial page</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>©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