mirror of
https://github.com/thestk/stk
synced 2026-04-20 06:26:55 +00:00
Release 4.1.2 tarball
This commit is contained in:
committed by
Stephen Sinclair
parent
d12ef806ac
commit
5d63b50e85
@@ -5,16 +5,13 @@
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#FFFFFF">
|
||||
<CENTER>
|
||||
<img src="princeton.gif"> <img src="ccrma.gif"><P>
|
||||
<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>
|
||||
<HR>
|
||||
<!-- Generated by Doxygen 1.2.8.1 -->
|
||||
<a name="controlin"><h2>Control Input</h2></a>
|
||||
Each Synthesis ToolKit instrument exposes its relevant control parameters via public functions such as setFrequency() and controlChange(). Programmers are free to implement the control scheme of their choice in exposing those parameters to the user.
|
||||
<p>
|
||||
A text-based control protocol called <a href="skini.html">SKINI</a> is provided with the Synthesis ToolKit. <a class="el" href="classSKINI.html">SKINI</a> extends the MIDI protocol in incremental ways, providing a text-based messaging scheme in human-readable format and making use of floating-point numbers wherever possible. Each <a class="el" href="classSKINI.html">SKINI</a> message consists of a message type (e.g., NoteOn, PitchBend), a time specification (absolute or delta), a channel number (scanned as a long integer), and a maximum of two subsequent message-specific field values. Knowing this, it should be relatively clear what the following <a class="el" href="classSKINI.html">SKINI</a> "scorefile" specifies:
|
||||
<p>
|
||||
<div class="fragment"><pre>NoteOn 0.000082 2 55.0 82.3
|
||||
<!-- Generated by Doxygen 1.3.6 -->
|
||||
<h1><a class="anchor" name="controlin">Control Input</a></h1>Each Synthesis ToolKit instrument exposes its relevant control parameters via public functions such as setFrequency() and controlChange(). Programmers are free to implement the control scheme of their choice in exposing those parameters to the user.<p>
|
||||
A text-based control protocol called <a href="skini.html">SKINI</a> is provided with the Synthesis ToolKit. <a class="el" href="classSKINI.html">SKINI</a> extends the MIDI protocol in incremental ways, providing a text-based messaging scheme in human-readable format and making use of floating-point numbers wherever possible. Each <a class="el" href="classSKINI.html">SKINI</a> message consists of a message type (e.g., NoteOn, PitchBend), a time specification (absolute or delta), a channel number (scanned as a long integer), and a maximum of two subsequent message-specific field values. Knowing this, it should be relatively clear what the following <a class="el" href="classSKINI.html">SKINI</a> "scorefile" specifies:<p>
|
||||
<pre class="fragment"><div>NoteOn 0.000082 2 55.0 82.3
|
||||
NoteOff 1.000000 2 55.0 64.0
|
||||
NoteOn 0.000082 2 69.0 82.8
|
||||
StringDetune 0.100000 2 10.0
|
||||
@@ -23,120 +20,112 @@ StringDetune 0.100000 2 50.0
|
||||
StringDetune 0.100000 2 40.0
|
||||
StringDetune 0.100000 2 22.0
|
||||
StringDetune 0.100000 2 12.0
|
||||
NoteOff 1.000000 2 69.0 64.0</pre></div>
|
||||
<p>
|
||||
MIDI messages (with the exception of Sysex) are easily represented within the <a class="el" href="classSKINI.html">SKINI</a> protocol.
|
||||
<p>
|
||||
The class <a class="el" href="classMessager.html">Messager</a> can be used to acquire and parse MIDI messages from a MIDI device and <a class="el" href="classSKINI.html">SKINI</a> messages from STDIN and socket connections. Many of the example programs included with the ToolKit distribution use a <a class="el" href="classMessager.html">Messager</a> instance to accept control input from the accompanying tcl/tk graphical user interfaces, from external MIDI devices, or from <a class="el" href="classSKINI.html">SKINI</a> scorefiles.
|
||||
<p>
|
||||
In the following example, we'll modify the <code>bethree.cpp</code> program from the previous tutorial chapter and incorporate a <a class="el" href="classMessager.html">Messager</a> class to allow control via a <a class="el" href="classSKINI.html">SKINI</a> scorefile.
|
||||
<p>
|
||||
<div class="fragment"><pre><font class="comment">// controlbee.cpp</font>
|
||||
NoteOff 1.000000 2 69.0 64.0
|
||||
</div></pre><p>
|
||||
MIDI messages (with the exception of Sysex) are easily represented within the <a class="el" href="classSKINI.html">SKINI</a> protocol.<p>
|
||||
The class <a class="el" href="classMessager.html">Messager</a> can be used to acquire and parse MIDI messages from a MIDI device and <a class="el" href="classSKINI.html">SKINI</a> messages from STDIN and socket connections. Many of the example programs included with the ToolKit distribution use a <a class="el" href="classMessager.html">Messager</a> instance to accept control input from the accompanying tcl/tk graphical user interfaces, from external MIDI devices, or from <a class="el" href="classSKINI.html">SKINI</a> scorefiles.<p>
|
||||
In the following example, we'll modify the <code>bethree.cpp</code> program from the previous tutorial chapter and incorporate a <a class="el" href="classMessager.html">Messager</a> class to allow control via a <a class="el" href="classSKINI.html">SKINI</a> scorefile.<p>
|
||||
<pre class="fragment"><div><span class="comment">// controlbee.cpp</span>
|
||||
|
||||
<font class="preprocessor">#include "BeeThree.h"</font>
|
||||
<font class="preprocessor">#include "RtWvOut.h"</font>
|
||||
<font class="preprocessor">#include "Messager.h"</font>
|
||||
<font class="preprocessor">#include "SKINI.msg"</font>
|
||||
<font class="preprocessor">#include <math.h></font>
|
||||
<span class="preprocessor">#include "BeeThree.h"</span>
|
||||
<span class="preprocessor">#include "RtWvOut.h"</span>
|
||||
<span class="preprocessor">#include "Messager.h"</span>
|
||||
<span class="preprocessor">#include "SKINI.msg"</span>
|
||||
<span class="preprocessor">#include <math.h></span>
|
||||
|
||||
<font class="keywordtype">int</font> main()<font class="keyword"></font>
|
||||
<font class="keyword"></font>{
|
||||
<font class="comment">// Set the global sample rate before creating class instances.</font>
|
||||
<a class="code" href="classStk.html#d1">Stk::setSampleRate</a>( 44100.0 );
|
||||
<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 );
|
||||
|
||||
<a class="code" href="classInstrmnt.html">Instrmnt</a> *instrument = 0;
|
||||
<a class="code" href="classRtWvOut.html">RtWvOut</a> *output = 0;
|
||||
<a class="code" href="classMessager.html">Messager</a> *messager = 0;
|
||||
<font class="keywordtype">bool</font> done = FALSE;
|
||||
<span class="keywordtype">bool</span> done = FALSE;
|
||||
|
||||
<font class="keywordflow">try</font> {
|
||||
<font class="comment">// Define and load the BeeThree instrument</font>
|
||||
instrument = <font class="keyword">new</font> BeeThree();
|
||||
<span class="keywordflow">try</span> {
|
||||
<span class="comment">// Define and load the BeeThree instrument</span>
|
||||
instrument = <span class="keyword">new</span> <a class="code" href="classBeeThree.html">BeeThree</a>();
|
||||
|
||||
<font class="comment">// Define and open the default realtime output device for one-channel playback</font>
|
||||
output = <font class="keyword">new</font> RtWvOut(1);
|
||||
<span class="comment">// Define and open the default realtime output device for one-channel playback</span>
|
||||
output = <span class="keyword">new</span> <a class="code" href="classRtWvOut.html">RtWvOut</a>(1);
|
||||
}
|
||||
<font class="keywordflow">catch</font> (<a class="code" href="classStkError.html">StkError</a> &) {
|
||||
<font class="keywordflow">goto</font> cleanup;
|
||||
<span class="keywordflow">catch</span> (<a class="code" href="classStkError.html">StkError</a> &) {
|
||||
<span class="keywordflow">goto</span> cleanup;
|
||||
}
|
||||
|
||||
<font class="keywordflow">try</font> {
|
||||
<font class="comment">// Create a Messager instance to read from a redirected SKINI scorefile.</font>
|
||||
messager = <font class="keyword">new</font> Messager();
|
||||
<span class="keywordflow">try</span> {
|
||||
<span class="comment">// Create a Messager instance to read from a redirected SKINI scorefile.</span>
|
||||
messager = <span class="keyword">new</span> <a class="code" href="classMessager.html">Messager</a>();
|
||||
}
|
||||
<font class="keywordflow">catch</font> (<a class="code" href="classStkError.html">StkError</a> &) {
|
||||
<font class="keywordflow">goto</font> cleanup;
|
||||
<span class="keywordflow">catch</span> (<a class="code" href="classStkError.html">StkError</a> &) {
|
||||
<span class="keywordflow">goto</span> cleanup;
|
||||
}
|
||||
|
||||
<font class="comment">// Play the instrument until the end of the scorefile.</font>
|
||||
<font class="keywordtype">int</font> i, nTicks, type;
|
||||
<span class="comment">// Play the instrument until the end of the scorefile.</span>
|
||||
<span class="keywordtype">int</span> i, nTicks, type;
|
||||
MY_FLOAT byte2, byte3, frequency;
|
||||
<font class="keywordflow">while</font> (!done) {
|
||||
<span class="keywordflow">while</span> (!done) {
|
||||
|
||||
<font class="comment">// Look for new messages and return a delta time (in samples).</font>
|
||||
<span class="comment">// Look for new messages and return a delta time (in samples).</span>
|
||||
type = messager-><a class="code" href="classMessager.html#a2">nextMessage</a>();
|
||||
<font class="keywordflow">if</font> (type < 0)
|
||||
<span class="keywordflow">if</span> (type < 0)
|
||||
done = TRUE;
|
||||
|
||||
nTicks = messager-><a class="code" href="classMessager.html#a4">getDelta</a>();
|
||||
<font class="keywordflow">try</font> {
|
||||
<font class="keywordflow">for</font> ( i=0; i<nTicks; i++ )
|
||||
output-><a class="code" href="classRtWvOut.html#a6">tick</a>( instrument-><a class="code" href="classInstrmnt.html#a6">tick</a>() );
|
||||
<span class="keywordflow">try</span> {
|
||||
<span class="keywordflow">for</span> ( i=0; i<nTicks; i++ )
|
||||
output-><a class="code" href="classRtWvOut.html#a6">tick</a>( instrument-><a class="code" href="classInstrmnt.html#a8">tick</a>() );
|
||||
}
|
||||
<font class="keywordflow">catch</font> (<a class="code" href="classStkError.html">StkError</a> &) {
|
||||
<font class="keywordflow">goto</font> cleanup;
|
||||
<span class="keywordflow">catch</span> (<a class="code" href="classStkError.html">StkError</a> &) {
|
||||
<span class="keywordflow">goto</span> cleanup;
|
||||
}
|
||||
|
||||
<font class="keywordflow">if</font> ( type > 0 ) {
|
||||
<font class="comment">// Process the new control message.</font>
|
||||
<span class="keywordflow">if</span> ( type > 0 ) {
|
||||
<span class="comment">// Process the new control message.</span>
|
||||
byte2 = messager-><a class="code" href="classMessager.html#a6">getByteTwo</a>();
|
||||
byte3 = messager-><a class="code" href="classMessager.html#a7">getByteThree</a>();
|
||||
|
||||
<font class="keywordflow">switch</font>(type) {
|
||||
<span class="keywordflow">switch</span>(type) {
|
||||
|
||||
<font class="keywordflow">case</font> __SK_NoteOn_:
|
||||
<span class="keywordflow">case</span> __SK_NoteOn_:
|
||||
frequency = (MY_FLOAT) 220.0 * pow( 2.0, (byte2 - 57.0) / 12.0 );
|
||||
instrument-><a class="code" href="classInstrmnt.html#a2">noteOn</a>( frequency, byte3 * ONE_OVER_128 );
|
||||
<font class="keywordflow">break</font>;
|
||||
<span class="keywordflow">break</span>;
|
||||
|
||||
<font class="keywordflow">case</font> __SK_NoteOff_:
|
||||
<span class="keywordflow">case</span> __SK_NoteOff_:
|
||||
instrument-><a class="code" href="classInstrmnt.html#a3">noteOff</a>( byte3 * ONE_OVER_128 );
|
||||
<font class="keywordflow">break</font>;
|
||||
<span class="keywordflow">break</span>;
|
||||
|
||||
<font class="keywordflow">case</font> __SK_ControlChange_:
|
||||
instrument-><a class="code" href="classInstrmnt.html#a8">controlChange</a>( (<font class="keywordtype">int</font>) byte2, byte3 );
|
||||
<font class="keywordflow">break</font>;
|
||||
<span class="keywordflow">case</span> __SK_ControlChange_:
|
||||
instrument-><a class="code" href="classInstrmnt.html#a10">controlChange</a>( (<span class="keywordtype">int</span>) byte2, byte3 );
|
||||
<span class="keywordflow">break</span>;
|
||||
|
||||
<font class="keywordflow">case</font> __SK_AfterTouch_:
|
||||
instrument-><a class="code" href="classInstrmnt.html#a8">controlChange</a>( 128, byte2 );
|
||||
<font class="keywordflow">break</font>;
|
||||
<span class="keywordflow">case</span> __SK_AfterTouch_:
|
||||
instrument-><a class="code" href="classInstrmnt.html#a10">controlChange</a>( 128, byte2 );
|
||||
<span class="keywordflow">break</span>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
<font class="keyword">delete</font> instrument;
|
||||
<font class="keyword">delete</font> output;
|
||||
<font class="keyword">delete</font> messager;
|
||||
<span class="keyword">delete</span> instrument;
|
||||
<span class="keyword">delete</span> output;
|
||||
<span class="keyword">delete</span> messager;
|
||||
|
||||
<font class="keywordflow">return</font> 0;
|
||||
}</pre></div>
|
||||
<p>
|
||||
Assuming the program is compiled as <code>controlbee</code> and the <a class="el" href="classSKINI.html">SKINI</a> scorefile <a href="tutorial/bookert.ski"><code>bookert.ski</code></a> is in the <code>scores</code> directory, the scorefile could be redirected to the program as:
|
||||
<p>
|
||||
<div class="fragment"><pre>controlbee < scores/bookert.ski</pre></div>
|
||||
<p>
|
||||
Only a few basic <a class="el" href="classSKINI.html">SKINI</a> message type case statements are included in this example. It is easy to extend the program to support a much more elaborate set of instrument control parameters.
|
||||
<p>
|
||||
This example could also be easily extended to accept "realtime" control input messages via STDIN, socket, or MIDI connections. The <a class="el" href="classMessager.html">Messager</a> class constructor takes an optional argument consisting of a bitmask of the following options: <code>STK_PIPE</code>, <code>STK_SOCKET</code>, and/or <code>STK_MIDI</code>.
|
||||
<p>
|
||||
[<a href="multichannel.html">Next tutorial</a>] [<a href="tutorial.html">Main tutorial page</a>]
|
||||
<p>
|
||||
<HR>
|
||||
<span class="keywordflow">return</span> 0;
|
||||
}
|
||||
</div></pre><p>
|
||||
Assuming the program is compiled as <code>controlbee</code> and the <a class="el" href="classSKINI.html">SKINI</a> scorefile <a href="tutorial/bookert.ski"><code>bookert.ski</code></a> is in the <code>scores</code> directory, the scorefile could be redirected to the program as:<p>
|
||||
<pre class="fragment"><div>controlbee < scores/bookert.ski
|
||||
</div></pre><p>
|
||||
Only a few basic <a class="el" href="classSKINI.html">SKINI</a> message type case statements are included in this example. It is easy to extend the program to support a much more elaborate set of instrument control parameters.<p>
|
||||
This example could also be easily extended to accept "realtime" control input messages via STDIN, socket, or MIDI connections. The <a class="el" href="classMessager.html">Messager</a> class constructor takes an optional argument consisting of a bitmask of the following options: <code>STK_PIPE</code>, <code>STK_SOCKET</code>, and/or <code>STK_MIDI</code>.<p>
|
||||
[<a href="multichannel.html">Next tutorial</a>] [<a href="tutorial.html">Main tutorial page</a>] <HR>
|
||||
|
||||
<table>
|
||||
<tr><td><A HREF="http://www-ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
|
||||
<tr><td>©1995-2002 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
||||
<tr><td>©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
||||
</table>
|
||||
|
||||
</BODY>
|
||||
|
||||
Reference in New Issue
Block a user