mirror of
https://github.com/thestk/stk
synced 2026-01-17 14:41:53 +00:00
Release 4.2.0 tarball
This commit is contained in:
committed by
Stephen Sinclair
parent
fe20fe92a2
commit
de344668dd
@@ -12,163 +12,214 @@
|
||||
<h1>Stk.h</h1><div class="fragment"><pre>00001 <span class="comment">/***************************************************/</span>
|
||||
00013 <span class="comment">/***************************************************/</span>
|
||||
00014
|
||||
00015 <span class="preprocessor">#if !defined(__STK_H)</span>
|
||||
00016 <span class="preprocessor"></span><span class="preprocessor">#define __STK_H</span>
|
||||
00015 <span class="preprocessor">#ifndef STK_STK_H</span>
|
||||
00016 <span class="preprocessor"></span><span class="preprocessor">#define STK_STK_H</span>
|
||||
00017 <span class="preprocessor"></span>
|
||||
00018 <span class="preprocessor">#include <string></span>
|
||||
00019
|
||||
00020 <span class="comment">// Most data in STK is passed and calculated with the</span>
|
||||
00021 <span class="comment">// following user-definable floating-point type. You</span>
|
||||
00022 <span class="comment">// can change this to "float" if you prefer or perhaps</span>
|
||||
00023 <span class="comment">// a "long double" in the future.</span>
|
||||
00024 <span class="keyword">typedef</span> <span class="keywordtype">double</span> MY_FLOAT;
|
||||
00025
|
||||
00026 <span class="comment">// The "MY_FLOAT" type will be deprecated in STK</span>
|
||||
00027 <span class="comment">// versions higher than 4.1.2 and replaced with the variable</span>
|
||||
00028 <span class="comment">// "StkFloat".</span>
|
||||
00029 <span class="comment">//typedef double StkFloat;</span>
|
||||
00030 <span class="comment">//#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)</span>
|
||||
00031 <span class="comment">// #pragma deprecated(MY_FLOAT)</span>
|
||||
00032 <span class="comment">//#else</span>
|
||||
00033 <span class="comment">// typedef StkFloat MY_FLOAT __attribute__ ((deprecated));</span>
|
||||
00034 <span class="comment">//#endif</span>
|
||||
00035
|
||||
00037
|
||||
<a name="l00042"></a><a class="code" href="classStkError.html">00042</a> <span class="keyword">class </span><a class="code" href="classStkError.html">StkError</a>
|
||||
00043 {
|
||||
00044 <span class="keyword">public</span>:
|
||||
00045 <span class="keyword">enum</span> TYPE {
|
||||
00046 WARNING,
|
||||
00047 DEBUG_WARNING,
|
||||
00048 FUNCTION_ARGUMENT,
|
||||
00049 FILE_NOT_FOUND,
|
||||
00050 FILE_UNKNOWN_FORMAT,
|
||||
00051 FILE_ERROR,
|
||||
00052 PROCESS_THREAD,
|
||||
00053 PROCESS_SOCKET,
|
||||
00054 PROCESS_SOCKET_IPADDR,
|
||||
00055 AUDIO_SYSTEM,
|
||||
00056 MIDI_SYSTEM,
|
||||
00057 UNSPECIFIED
|
||||
00058 };
|
||||
00059
|
||||
00060 <span class="keyword">protected</span>:
|
||||
00061 <span class="keywordtype">char</span> message[256];
|
||||
00062 TYPE type;
|
||||
00063
|
||||
00064 <span class="keyword">public</span>:
|
||||
00066 <a class="code" href="classStkError.html#a0">StkError</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *p, TYPE tipe = StkError::UNSPECIFIED);
|
||||
00067
|
||||
00069 <span class="keyword">virtual</span> <a class="code" href="classStkError.html#a1">~StkError</a>(<span class="keywordtype">void</span>);
|
||||
00019 <span class="preprocessor">#include <iostream></span>
|
||||
00020 <span class="preprocessor">#include <sstream></span>
|
||||
00021 <span class="preprocessor">#include <valarray></span>
|
||||
00022
|
||||
00023 <span class="comment">// Most data in STK is passed and calculated with the</span>
|
||||
00024 <span class="comment">// following user-definable floating-point type. You</span>
|
||||
00025 <span class="comment">// can change this to "float" if you prefer or perhaps</span>
|
||||
00026 <span class="comment">// a "long double" in the future.</span>
|
||||
00027 <span class="keyword">typedef</span> <span class="keywordtype">double</span> StkFloat;
|
||||
00028
|
||||
00029 <span class="comment">// The "MY_FLOAT" type was deprecated in STK</span>
|
||||
00030 <span class="comment">// versions higher than 4.1.3 and replaced with the variable</span>
|
||||
00031 <span class="comment">// "StkFloat". </span>
|
||||
00032 <span class="preprocessor">#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)</span>
|
||||
00033 <span class="preprocessor"></span> <span class="keyword">typedef</span> StkFloat MY_FLOAT;
|
||||
00034 <span class="preprocessor"> #pragma deprecated(MY_FLOAT)</span>
|
||||
00035 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__GXX__) </span>
|
||||
00036 <span class="preprocessor"></span> <span class="keyword">typedef</span> StkFloat MY_FLOAT __attribute__ ((deprecated));
|
||||
00037 <span class="preprocessor">#else</span>
|
||||
00038 <span class="preprocessor"></span> <span class="keyword">typedef</span> StkFloat MY_FLOAT; <span class="comment">// temporary</span>
|
||||
00039 <span class="preprocessor">#endif</span>
|
||||
00040 <span class="preprocessor"></span>
|
||||
00041
|
||||
00043
|
||||
<a name="l00048"></a><a class="code" href="classStkError.html">00048</a> <span class="keyword">class </span><a class="code" href="classStkError.html">StkError</a>
|
||||
00049 {
|
||||
00050 <span class="keyword">public</span>:
|
||||
00051 <span class="keyword">enum</span> Type {
|
||||
00052 STATUS,
|
||||
00053 WARNING,
|
||||
00054 DEBUG_WARNING,
|
||||
00055 FUNCTION_ARGUMENT,
|
||||
00056 FILE_NOT_FOUND,
|
||||
00057 FILE_UNKNOWN_FORMAT,
|
||||
00058 FILE_ERROR,
|
||||
00059 PROCESS_THREAD,
|
||||
00060 PROCESS_SOCKET,
|
||||
00061 PROCESS_SOCKET_IPADDR,
|
||||
00062 AUDIO_SYSTEM,
|
||||
00063 MIDI_SYSTEM,
|
||||
00064 UNSPECIFIED
|
||||
00065 };
|
||||
00066
|
||||
00067 <span class="keyword">protected</span>:
|
||||
00068 std::string message_;
|
||||
00069 Type type_;
|
||||
00070
|
||||
00072 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classStkError.html#a2">printMessage</a>(<span class="keywordtype">void</span>);
|
||||
00073
|
||||
<a name="l00075"></a><a class="code" href="classStkError.html#a3">00075</a> <span class="keyword">virtual</span> <span class="keyword">const</span> TYPE& <a class="code" href="classStkError.html#a3">getType</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> type; }
|
||||
00076
|
||||
<a name="l00078"></a><a class="code" href="classStkError.html#a4">00078</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classStkError.html#a4">getMessage</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> message; }
|
||||
00079 };
|
||||
00071 <span class="keyword">public</span>:
|
||||
<a name="l00073"></a><a class="code" href="classStkError.html#a0">00073</a> <a class="code" href="classStkError.html#a0">StkError</a>(<span class="keyword">const</span> std::string& message, Type type = StkError::UNSPECIFIED) : message_(message), type_(type) {}
|
||||
00074
|
||||
<a name="l00076"></a><a class="code" href="classStkError.html#a1">00076</a> <span class="keyword">virtual</span> <a class="code" href="classStkError.html#a1">~StkError</a>(<span class="keywordtype">void</span>) {};
|
||||
00077
|
||||
<a name="l00079"></a><a class="code" href="classStkError.html#a2">00079</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classStkError.html#a2">printMessage</a>(<span class="keywordtype">void</span>) { std::cerr << <span class="charliteral">'\n'</span> << message_ << <span class="stringliteral">"\n\n"</span>; }
|
||||
00080
|
||||
00081
|
||||
<a name="l00082"></a><a class="code" href="classStk.html">00082</a> <span class="keyword">class </span><a class="code" href="classStk.html">Stk</a>
|
||||
00083 {
|
||||
00084 <span class="keyword">public</span>:
|
||||
00085
|
||||
00086 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> STK_FORMAT;
|
||||
<a name="l00087"></a><a class="code" href="classStk.html#s0">00087</a> <span class="keyword">static</span> <span class="keyword">const</span> STK_FORMAT <a class="code" href="classStk.html#s0">STK_SINT8</a>;
|
||||
<a name="l00088"></a><a class="code" href="classStk.html#s1">00088</a> <span class="keyword">static</span> <span class="keyword">const</span> STK_FORMAT <a class="code" href="classStk.html#s1">STK_SINT16</a>;
|
||||
<a name="l00089"></a><a class="code" href="classStk.html#s2">00089</a> <span class="keyword">static</span> <span class="keyword">const</span> STK_FORMAT <a class="code" href="classStk.html#s2">STK_SINT32</a>;
|
||||
<a name="l00090"></a><a class="code" href="classStk.html#s3">00090</a> <span class="keyword">static</span> <span class="keyword">const</span> STK_FORMAT <a class="code" href="classStk.html#s3">MY_FLOAT32</a>;
|
||||
<a name="l00091"></a><a class="code" href="classStk.html#s4">00091</a> <span class="keyword">static</span> <span class="keyword">const</span> STK_FORMAT <a class="code" href="classStk.html#s4">MY_FLOAT64</a>;
|
||||
00093
|
||||
00094 <span class="keyword">static</span> MY_FLOAT <a class="code" href="classStk.html#e0">sampleRate</a>(<span class="keywordtype">void</span>);
|
||||
<a name="l00082"></a><a class="code" href="classStkError.html#a3">00082</a> <span class="keyword">virtual</span> <span class="keyword">const</span> Type& <a class="code" href="classStkError.html#a3">getType</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> type_; }
|
||||
00083
|
||||
<a name="l00085"></a><a class="code" href="classStkError.html#a4">00085</a> <span class="keyword">virtual</span> <span class="keyword">const</span> std::string& <a class="code" href="classStkError.html#a4">getMessage</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> message_; }
|
||||
00086
|
||||
<a name="l00088"></a><a class="code" href="classStkError.html#a5">00088</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classStkError.html#a5">getMessageCString</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> message_.c_str(); }
|
||||
00089 };
|
||||
00090
|
||||
00091
|
||||
<a name="l00092"></a><a class="code" href="classStk.html">00092</a> <span class="keyword">class </span><a class="code" href="classStk.html">Stk</a>
|
||||
00093 {
|
||||
00094 <span class="keyword">public</span>:
|
||||
00095
|
||||
00097
|
||||
00105 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e1">setSampleRate</a>(MY_FLOAT newRate);
|
||||
00096 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> StkFormat;
|
||||
<a name="l00097"></a><a class="code" href="classStk.html#s0">00097</a> <span class="keyword">static</span> <span class="keyword">const</span> StkFormat <a class="code" href="classStk.html#s0">STK_SINT8</a>;
|
||||
<a name="l00098"></a><a class="code" href="classStk.html#s1">00098</a> <span class="keyword">static</span> <span class="keyword">const</span> StkFormat <a class="code" href="classStk.html#s1">STK_SINT16</a>;
|
||||
<a name="l00099"></a><a class="code" href="classStk.html#s2">00099</a> <span class="keyword">static</span> <span class="keyword">const</span> StkFormat <a class="code" href="classStk.html#s2">STK_SINT24</a>;
|
||||
<a name="l00100"></a><a class="code" href="classStk.html#s3">00100</a> <span class="keyword">static</span> <span class="keyword">const</span> StkFormat <a class="code" href="classStk.html#s3">STK_SINT32</a>;
|
||||
<a name="l00101"></a><a class="code" href="classStk.html#s4">00101</a> <span class="keyword">static</span> <span class="keyword">const</span> StkFormat <a class="code" href="classStk.html#s4">STK_FLOAT32</a>;
|
||||
<a name="l00102"></a><a class="code" href="classStk.html#s5">00102</a> <span class="keyword">static</span> <span class="keyword">const</span> StkFormat <a class="code" href="classStk.html#s5">STK_FLOAT64</a>;
|
||||
00104
|
||||
<a name="l00105"></a><a class="code" href="classStk.html#e0">00105</a> <span class="keyword">static</span> StkFloat <a class="code" href="classStk.html#e0">sampleRate</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> srate_; }
|
||||
00106
|
||||
00108 <span class="keyword">static</span> std::string <a class="code" href="classStk.html#e2">rawwavePath</a>(<span class="keywordtype">void</span>);
|
||||
00109
|
||||
00111 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e3">setRawwavePath</a>(std::string newPath);
|
||||
00112
|
||||
00114 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e4">swap16</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr);
|
||||
00115
|
||||
00117 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e5">swap32</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr);
|
||||
00118
|
||||
00120 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e6">swap64</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr);
|
||||
00121
|
||||
00123 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e7">sleep</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> milliseconds);
|
||||
00124
|
||||
00125 <span class="keyword">private</span>:
|
||||
00126 <span class="keyword">static</span> MY_FLOAT srate;
|
||||
00127 <span class="keyword">static</span> std::string rawwavepath;
|
||||
00128
|
||||
00129 <span class="keyword">protected</span>:
|
||||
00130
|
||||
00132 <a class="code" href="classStk.html#b0">Stk</a>(<span class="keywordtype">void</span>);
|
||||
00133
|
||||
00135 <span class="keyword">virtual</span> <a class="code" href="classStk.html#b1">~Stk</a>(<span class="keywordtype">void</span>);
|
||||
00136
|
||||
00138 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#f0">handleError</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> *message, StkError::TYPE type );
|
||||
00139
|
||||
00140 };
|
||||
00108
|
||||
<a name="l00116"></a><a class="code" href="classStk.html#e1">00116</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e1">setSampleRate</a>(StkFloat rate) { <span class="keywordflow">if</span> (rate > 0.0) srate_ = rate; }
|
||||
00117
|
||||
<a name="l00119"></a><a class="code" href="classStk.html#e2">00119</a> <span class="keyword">static</span> std::string <a class="code" href="classStk.html#e2">rawwavePath</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> rawwavepath_; }
|
||||
00120
|
||||
00122 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e3">setRawwavePath</a>(std::string path);
|
||||
00123
|
||||
00125 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e4">swap16</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr);
|
||||
00126
|
||||
00128 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e5">swap32</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr);
|
||||
00129
|
||||
00131 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e6">swap64</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ptr);
|
||||
00132
|
||||
00134 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e7">sleep</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> milliseconds);
|
||||
00135
|
||||
00137 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e8">handleError</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> *message, StkError::Type type );
|
||||
00138
|
||||
00140 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classStk.html#e8">handleError</a>( std::string message, StkError::Type type );
|
||||
00141
|
||||
00142 <span class="comment">// Here are a few other useful typedefs.</span>
|
||||
00143 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">short</span> SINT16;
|
||||
00144 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">int</span> SINT32;
|
||||
00145 <span class="keyword">typedef</span> <span class="keywordtype">float</span> FLOAT32;
|
||||
00146 <span class="keyword">typedef</span> <span class="keywordtype">double</span> FLOAT64;
|
||||
00142 <span class="keyword">private</span>:
|
||||
00143 <span class="keyword">static</span> StkFloat srate_;
|
||||
00144 <span class="keyword">static</span> std::string rawwavepath_;
|
||||
00145
|
||||
00146 <span class="keyword">protected</span>:
|
||||
00147
|
||||
00148 <span class="comment">// Boolean values</span>
|
||||
00149 <span class="preprocessor">#define FALSE 0</span>
|
||||
00150 <span class="preprocessor"></span><span class="preprocessor">#define TRUE 1</span>
|
||||
00151 <span class="preprocessor"></span>
|
||||
00152 <span class="comment">// The default sampling rate.</span>
|
||||
00153 <span class="preprocessor">#define SRATE (MY_FLOAT) 44100.0</span>
|
||||
00154 <span class="preprocessor"></span>
|
||||
00155 <span class="comment">// The default real-time audio input and output buffer size. If</span>
|
||||
00156 <span class="comment">// clicks are occuring in the input and/or output sound stream, a</span>
|
||||
00157 <span class="comment">// larger buffer size may help. Larger buffer sizes, however, produce</span>
|
||||
00158 <span class="comment">// more latency.</span>
|
||||
00159 <span class="preprocessor">#define RT_BUFFER_SIZE 512</span>
|
||||
00160 <span class="preprocessor"></span>
|
||||
00161 <span class="comment">// The default rawwave path value is set with the preprocessor</span>
|
||||
00162 <span class="comment">// definition RAWWAVE_PATH. This can be specified as an argument to</span>
|
||||
00163 <span class="comment">// the configure script, in an integrated development environment, or</span>
|
||||
00164 <span class="comment">// below. The global STK rawwave path variable can be dynamically set</span>
|
||||
00165 <span class="comment">// with the Stk::setRawwavePath() function. This value is</span>
|
||||
00166 <span class="comment">// concatenated to the beginning of all references to rawwave files in</span>
|
||||
00167 <span class="comment">// the various STK core classes (ex. Clarinet.cpp). If you wish to</span>
|
||||
00168 <span class="comment">// move the rawwaves directory to a different location in your file</span>
|
||||
00169 <span class="comment">// system, you will need to set this path definition appropriately.</span>
|
||||
00170 <span class="preprocessor">#if !defined(RAWWAVE_PATH)</span>
|
||||
00171 <span class="preprocessor"></span><span class="preprocessor"> #define RAWWAVE_PATH "../../rawwaves/"</span>
|
||||
00172 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
|
||||
00173 <span class="preprocessor"></span>
|
||||
00174 <span class="preprocessor">#define PI (MY_FLOAT) 3.14159265359</span>
|
||||
00175 <span class="preprocessor"></span><span class="preprocessor">#define TWO_PI (MY_FLOAT) (MY_FLOAT) (2 * PI)</span>
|
||||
00176 <span class="preprocessor"></span>
|
||||
00177 <span class="preprocessor">#define ONE_OVER_128 (MY_FLOAT) 0.0078125</span>
|
||||
00178 <span class="preprocessor"></span>
|
||||
00179 <span class="preprocessor">#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)</span>
|
||||
00180 <span class="preprocessor"></span><span class="preprocessor"> #define __OS_WINDOWS__</span>
|
||||
00181 <span class="preprocessor"></span><span class="preprocessor"> #define __STK_REALTIME__</span>
|
||||
00182 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__LINUX_JACK__)</span>
|
||||
00183 <span class="preprocessor"></span><span class="preprocessor"> #define __OS_LINUX__</span>
|
||||
00184 <span class="preprocessor"></span><span class="preprocessor"> #define __STK_REALTIME__</span>
|
||||
00185 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__IRIX_AL__)</span>
|
||||
00186 <span class="preprocessor"></span><span class="preprocessor"> #define __OS_IRIX__</span>
|
||||
00187 <span class="preprocessor"></span><span class="preprocessor"> #define __STK_REALTIME__</span>
|
||||
00188 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__MACOSX_CORE__)</span>
|
||||
00189 <span class="preprocessor"></span><span class="preprocessor"> #define __OS_MACOSX__</span>
|
||||
00190 <span class="preprocessor"></span><span class="preprocessor"> #define __STK_REALTIME__</span>
|
||||
00191 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
|
||||
00192 <span class="preprocessor"></span>
|
||||
00193 <span class="comment">//#define _STK_DEBUG_</span>
|
||||
00194
|
||||
00195 <span class="preprocessor">#endif</span>
|
||||
00148 std::ostringstream errorString_;
|
||||
00149
|
||||
00151 <a class="code" href="classStk.html#b0">Stk</a>(<span class="keywordtype">void</span>);
|
||||
00152
|
||||
00154 <span class="keyword">virtual</span> <a class="code" href="classStk.html#b1">~Stk</a>(<span class="keywordtype">void</span>);
|
||||
00155
|
||||
00157 <span class="keywordtype">void</span> <a class="code" href="classStk.html#e8">handleError</a>( StkError::Type type );
|
||||
00158 };
|
||||
00159
|
||||
00160
|
||||
00161 <span class="comment">/***************************************************/</span>
|
||||
00175 <span class="comment">/***************************************************/</span>
|
||||
00176
|
||||
<a name="l00177"></a><a class="code" href="classStkFrames.html">00177</a> <span class="keyword">class </span><a class="code" href="classStkFrames.html">StkFrames</a>
|
||||
00178 {
|
||||
00179 <span class="keyword">public</span>:
|
||||
00180
|
||||
00182 <a class="code" href="classStkFrames.html#a0">StkFrames</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nFrames = 0, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nChannels = 1, <span class="keywordtype">bool</span> <a class="code" href="classStkFrames.html#a8">interleaved</a> = <span class="keyword">true</span> );
|
||||
00183
|
||||
00185 <a class="code" href="classStkFrames.html#a0">StkFrames</a>( <span class="keyword">const</span> StkFloat& value, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nFrames, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nChannels, <span class="keywordtype">bool</span> <a class="code" href="classStkFrames.html#a8">interleaved</a> = <span class="keyword">true</span> );
|
||||
00186
|
||||
00188
|
||||
<a name="l00194"></a><a class="code" href="classStkFrames.html#a2">00194</a> StkFloat& <a class="code" href="classStkFrames.html#a2">operator[]</a>( size_t n ) { <span class="keywordflow">return</span> data_[n]; };
|
||||
00195
|
||||
00197
|
||||
<a name="l00201"></a><a class="code" href="classStkFrames.html#a3">00201</a> StkFloat <a class="code" href="classStkFrames.html#a2">operator[]</a>( size_t n )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> data_[n]; };
|
||||
00202
|
||||
<a name="l00204"></a><a class="code" href="classStkFrames.html#a4">00204</a> size_t <a class="code" href="classStkFrames.html#a4">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> size_; };
|
||||
00205
|
||||
00207
|
||||
00211 <span class="keywordtype">void</span> <a class="code" href="classStkFrames.html#a5">resize</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nFrames, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nChannels = 1, StkFloat value = 0.0 );
|
||||
00212
|
||||
<a name="l00214"></a><a class="code" href="classStkFrames.html#a6">00214</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classStkFrames.html#a6">channels</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> nChannels_; };
|
||||
00215
|
||||
<a name="l00217"></a><a class="code" href="classStkFrames.html#a7">00217</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classStkFrames.html#a7">frames</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> nFrames_; };
|
||||
00218
|
||||
<a name="l00220"></a><a class="code" href="classStkFrames.html#a8">00220</a> <span class="keywordtype">bool</span> <a class="code" href="classStkFrames.html#a8">interleaved</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> interleaved_; };
|
||||
00221
|
||||
<a name="l00223"></a><a class="code" href="classStkFrames.html#a9">00223</a> <span class="keywordtype">void</span> <a class="code" href="classStkFrames.html#a9">setInterleaved</a>( <span class="keywordtype">bool</span> isInterleaved ) { interleaved_ = isInterleaved; };
|
||||
00224
|
||||
00225 <span class="keyword">private</span>:
|
||||
00226 std::valarray<StkFloat> data_;
|
||||
00227 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nFrames_;
|
||||
00228 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nChannels_;
|
||||
00229 size_t size_;
|
||||
00230 <span class="keywordtype">bool</span> interleaved_;
|
||||
00231
|
||||
00232 };
|
||||
00233
|
||||
00234
|
||||
00235 <span class="comment">// Here are a few other useful typedefs.</span>
|
||||
00236 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">short</span> SINT16;
|
||||
00237 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">int</span> SINT32;
|
||||
00238 <span class="keyword">typedef</span> <span class="keywordtype">float</span> FLOAT32;
|
||||
00239 <span class="keyword">typedef</span> <span class="keywordtype">double</span> FLOAT64;
|
||||
00240
|
||||
00241 <span class="comment">// The default sampling rate.</span>
|
||||
00242 <span class="keyword">const</span> StkFloat SRATE = 44100.0;
|
||||
00243
|
||||
00244 <span class="comment">// The default real-time audio input and output buffer size. If</span>
|
||||
00245 <span class="comment">// clicks are occuring in the input and/or output sound stream, a</span>
|
||||
00246 <span class="comment">// larger buffer size may help. Larger buffer sizes, however, produce</span>
|
||||
00247 <span class="comment">// more latency.</span>
|
||||
00248 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> RT_BUFFER_SIZE = 512;
|
||||
00249
|
||||
00250 <span class="comment">// The default rawwave path value is set with the preprocessor</span>
|
||||
00251 <span class="comment">// definition RAWWAVE_PATH. This can be specified as an argument to</span>
|
||||
00252 <span class="comment">// the configure script, in an integrated development environment, or</span>
|
||||
00253 <span class="comment">// below. The global STK rawwave path variable can be dynamically set</span>
|
||||
00254 <span class="comment">// with the Stk::setRawwavePath() function. This value is</span>
|
||||
00255 <span class="comment">// concatenated to the beginning of all references to rawwave files in</span>
|
||||
00256 <span class="comment">// the various STK core classes (ex. Clarinet.cpp). If you wish to</span>
|
||||
00257 <span class="comment">// move the rawwaves directory to a different location in your file</span>
|
||||
00258 <span class="comment">// system, you will need to set this path definition appropriately.</span>
|
||||
00259 <span class="preprocessor">#if !defined(RAWWAVE_PATH)</span>
|
||||
00260 <span class="preprocessor"></span><span class="preprocessor"> #define RAWWAVE_PATH "../../rawwaves/"</span>
|
||||
00261 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
|
||||
00262 <span class="preprocessor"></span>
|
||||
00263 <span class="keyword">const</span> StkFloat PI = 3.14159265359;
|
||||
00264 <span class="keyword">const</span> StkFloat TWO_PI = 2 * PI;
|
||||
00265 <span class="keyword">const</span> StkFloat ONE_OVER_128 = 0.0078125;
|
||||
00266
|
||||
00267 <span class="preprocessor">#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)</span>
|
||||
00268 <span class="preprocessor"></span><span class="preprocessor"> #define __OS_WINDOWS__</span>
|
||||
00269 <span class="preprocessor"></span><span class="preprocessor"> #define __STK_REALTIME__</span>
|
||||
00270 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__LINUX_JACK__)</span>
|
||||
00271 <span class="preprocessor"></span><span class="preprocessor"> #define __OS_LINUX__</span>
|
||||
00272 <span class="preprocessor"></span><span class="preprocessor"> #define __STK_REALTIME__</span>
|
||||
00273 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__IRIX_AL__)</span>
|
||||
00274 <span class="preprocessor"></span><span class="preprocessor"> #define __OS_IRIX__</span>
|
||||
00275 <span class="preprocessor"></span><span class="preprocessor"> #define __STK_REALTIME__</span>
|
||||
00276 <span class="preprocessor"></span><span class="preprocessor">#elif defined(__MACOSX_CORE__)</span>
|
||||
00277 <span class="preprocessor"></span><span class="preprocessor"> #define __OS_MACOSX__</span>
|
||||
00278 <span class="preprocessor"></span><span class="preprocessor"> #define __STK_REALTIME__</span>
|
||||
00279 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
|
||||
00280 <span class="preprocessor"></span>
|
||||
00281 <span class="comment">//#define _STK_DEBUG_</span>
|
||||
00282
|
||||
00283 <span class="preprocessor">#endif</span>
|
||||
</pre></div><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><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
|
||||
<tr><td>©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user