mirror of
https://github.com/thestk/stk
synced 2026-01-14 21:41:53 +00:00
295 lines
24 KiB
HTML
295 lines
24 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
|
|
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
|
|
</HEAD>
|
|
<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="faq.html">FAQ</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
|
|
<HR>
|
|
<!-- Generated by Doxygen 1.6.2 -->
|
|
<div class="navpath"><a class="el" href="dir_221deb9bdff892d63ed1e409450a60d2.html">include</a>
|
|
</div>
|
|
<div class="contents">
|
|
<h1>Shakers.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef STK_SHAKERS_H</span>
|
|
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define STK_SHAKERS_H</span>
|
|
<a name="l00003"></a>00003 <span class="preprocessor"></span>
|
|
<a name="l00004"></a>00004 <span class="preprocessor">#include "Instrmnt.h"</span>
|
|
<a name="l00005"></a>00005 <span class="preprocessor">#include <cmath></span>
|
|
<a name="l00006"></a>00006 <span class="preprocessor">#include <stdlib.h></span>
|
|
<a name="l00007"></a>00007
|
|
<a name="l00008"></a>00008 <span class="keyword">namespace </span>stk {
|
|
<a name="l00009"></a>00009
|
|
<a name="l00010"></a>00010 <span class="comment">/***************************************************/</span>
|
|
<a name="l00058"></a>00058 <span class="comment">/***************************************************/</span>
|
|
<a name="l00059"></a>00059
|
|
<a name="l00060"></a><a class="code" href="classstk_1_1Shakers.html">00060</a> <span class="keyword">class </span><a class="code" href="classstk_1_1Shakers.html" title="PhISEM and PhOLIES class.">Shakers</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1Instrmnt.html" title="STK instrument abstract base class.">Instrmnt</a>
|
|
<a name="l00061"></a>00061 {
|
|
<a name="l00062"></a>00062 <span class="keyword">public</span>:
|
|
<a name="l00064"></a>00064 <a class="code" href="classstk_1_1Shakers.html#a0de428431174d08f6776ef141594d1b6" title="Class constructor taking instrument type argument.">Shakers</a>( <span class="keywordtype">int</span> type = 0 );
|
|
<a name="l00065"></a>00065
|
|
<a name="l00067"></a>00067
|
|
<a name="l00071"></a>00071 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Shakers.html#a81ffb0ad1e350993af10b2795ec01861" title="Start a note with the given instrument and amplitude.">noteOn</a>( StkFloat instrument, StkFloat amplitude );
|
|
<a name="l00072"></a>00072
|
|
<a name="l00074"></a>00074 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Shakers.html#ab63b4b57f8306eb7cf1adbf5a5cd1d05" title="Stop a note with the given amplitude (speed of decay).">noteOff</a>( StkFloat amplitude );
|
|
<a name="l00075"></a>00075
|
|
<a name="l00077"></a>00077 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Shakers.html#a688d9d8318e0c69779868079a7c64157" title="Perform the control change specified by number and value (0.0 - 128.0).">controlChange</a>( <span class="keywordtype">int</span> number, StkFloat value );
|
|
<a name="l00078"></a>00078
|
|
<a name="l00080"></a>00080 StkFloat <a class="code" href="classstk_1_1Shakers.html#ae06ebba276cef74cb8c83db4e33f21c2" title="Compute and return one output sample.">tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );
|
|
<a name="l00081"></a>00081
|
|
<a name="l00083"></a>00083
|
|
<a name="l00090"></a>00090 <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>& <a class="code" href="classstk_1_1Shakers.html#ae06ebba276cef74cb8c83db4e33f21c2" title="Compute and return one output sample.">tick</a>( <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>& frames, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );
|
|
<a name="l00091"></a>00091
|
|
<a name="l00092"></a>00092 <span class="keyword">struct </span>BiQuad {
|
|
<a name="l00093"></a>00093 StkFloat gain;
|
|
<a name="l00094"></a>00094 StkFloat b[3];
|
|
<a name="l00095"></a>00095 StkFloat a[3]; <span class="comment">// a0 term assumed equal to 1.0</span>
|
|
<a name="l00096"></a>00096 StkFloat inputs[3];
|
|
<a name="l00097"></a>00097 StkFloat outputs[3];
|
|
<a name="l00098"></a>00098
|
|
<a name="l00099"></a>00099 <span class="comment">// Default constructor.</span>
|
|
<a name="l00100"></a>00100 BiQuad()
|
|
<a name="l00101"></a>00101 {
|
|
<a name="l00102"></a>00102 gain = 0.0;
|
|
<a name="l00103"></a>00103 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i<3; i++ ) {
|
|
<a name="l00104"></a>00104 b[i] = 0.0;
|
|
<a name="l00105"></a>00105 a[i] = 0.0;
|
|
<a name="l00106"></a>00106 inputs[i] = 0.0;
|
|
<a name="l00107"></a>00107 outputs[i] = 0.0;
|
|
<a name="l00108"></a>00108 }
|
|
<a name="l00109"></a>00109 }
|
|
<a name="l00110"></a>00110 };
|
|
<a name="l00111"></a>00111
|
|
<a name="l00112"></a>00112 <span class="keyword">protected</span>:
|
|
<a name="l00113"></a>00113
|
|
<a name="l00114"></a>00114 <span class="keywordtype">void</span> setType( <span class="keywordtype">int</span> type );
|
|
<a name="l00115"></a>00115 <span class="keywordtype">void</span> setResonance( BiQuad &filter, StkFloat frequency, StkFloat radius );
|
|
<a name="l00116"></a>00116 StkFloat tickResonance( BiQuad &filter, StkFloat input );
|
|
<a name="l00117"></a>00117 <span class="keywordtype">void</span> setEqualization( StkFloat b0, StkFloat b1, StkFloat b2 );
|
|
<a name="l00118"></a>00118 StkFloat tickEqualize( StkFloat input );
|
|
<a name="l00119"></a>00119 <span class="keywordtype">int</span> randomInt( <span class="keywordtype">int</span> max );
|
|
<a name="l00120"></a>00120 StkFloat randomFloat( StkFloat max = 1.0 );
|
|
<a name="l00121"></a>00121 StkFloat noise( <span class="keywordtype">void</span> );
|
|
<a name="l00122"></a>00122 <span class="keywordtype">void</span> waterDrop( <span class="keywordtype">void</span> );
|
|
<a name="l00123"></a>00123
|
|
<a name="l00124"></a>00124 <span class="keywordtype">int</span> shakerType_;
|
|
<a name="l00125"></a>00125 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nResonances_;
|
|
<a name="l00126"></a>00126 StkFloat shakeEnergy_;
|
|
<a name="l00127"></a>00127 StkFloat soundDecay_;
|
|
<a name="l00128"></a>00128 StkFloat systemDecay_;
|
|
<a name="l00129"></a>00129 StkFloat nObjects_;
|
|
<a name="l00130"></a>00130 StkFloat sndLevel_;
|
|
<a name="l00131"></a>00131 StkFloat baseGain_;
|
|
<a name="l00132"></a>00132 StkFloat currentGain_;
|
|
<a name="l00133"></a>00133 StkFloat baseDecay_;
|
|
<a name="l00134"></a>00134 StkFloat baseObjects_;
|
|
<a name="l00135"></a>00135 StkFloat decayScale_;
|
|
<a name="l00136"></a>00136 BiQuad equalizer_;
|
|
<a name="l00137"></a>00137 StkFloat ratchetCount_;
|
|
<a name="l00138"></a>00138 StkFloat ratchetDelta_;
|
|
<a name="l00139"></a>00139 StkFloat baseRatchetDelta_;
|
|
<a name="l00140"></a>00140 <span class="keywordtype">int</span> lastRatchetValue_;
|
|
<a name="l00141"></a>00141
|
|
<a name="l00142"></a>00142 std::vector< BiQuad > filters_;
|
|
<a name="l00143"></a>00143 std::vector< StkFloat > baseFrequencies_;
|
|
<a name="l00144"></a>00144 std::vector< StkFloat > baseRadii_;
|
|
<a name="l00145"></a>00145 std::vector< bool > doVaryFrequency_;
|
|
<a name="l00146"></a>00146 std::vector< StkFloat > tempFrequencies_;
|
|
<a name="l00147"></a>00147 StkFloat varyFactor_;
|
|
<a name="l00148"></a>00148 };
|
|
<a name="l00149"></a>00149
|
|
<a name="l00150"></a>00150 <span class="keyword">inline</span> <span class="keywordtype">void</span> Shakers :: setResonance( <a class="code" href="classstk_1_1BiQuad.html" title="STK biquad (two-pole, two-zero) filter class.">BiQuad</a> &filter, StkFloat frequency, StkFloat radius )
|
|
<a name="l00151"></a>00151 {
|
|
<a name="l00152"></a>00152 filter.a[1] = -2.0 * radius * cos( TWO_PI * frequency / <a class="code" href="classstk_1_1Stk.html#a5fbe37000a611ce56075ee7d8936472d" title="Static method that returns the current STK sample rate.">Stk::sampleRate</a>());
|
|
<a name="l00153"></a>00153 filter.a[2] = radius * radius;
|
|
<a name="l00154"></a>00154 }
|
|
<a name="l00155"></a>00155
|
|
<a name="l00156"></a>00156 <span class="keyword">inline</span> StkFloat Shakers :: tickResonance( BiQuad &filter, StkFloat input )
|
|
<a name="l00157"></a>00157 {
|
|
<a name="l00158"></a>00158 filter.outputs[0] = input * filter.gain * currentGain_;
|
|
<a name="l00159"></a>00159 filter.outputs[0] -= filter.a[1] * filter.outputs[1] + filter.a[2] * filter.outputs[2];
|
|
<a name="l00160"></a>00160 filter.outputs[2] = filter.outputs[1];
|
|
<a name="l00161"></a>00161 filter.outputs[1] = filter.outputs[0];
|
|
<a name="l00162"></a>00162 <span class="keywordflow">return</span> filter.outputs[0];
|
|
<a name="l00163"></a>00163 }
|
|
<a name="l00164"></a>00164
|
|
<a name="l00165"></a>00165 <span class="keyword">inline</span> <span class="keywordtype">void</span> Shakers :: setEqualization( StkFloat b0, StkFloat b1, StkFloat b2 )
|
|
<a name="l00166"></a>00166 {
|
|
<a name="l00167"></a>00167 equalizer_.b[0] = b0;
|
|
<a name="l00168"></a>00168 equalizer_.b[1] = b1;
|
|
<a name="l00169"></a>00169 equalizer_.b[2] = b2;
|
|
<a name="l00170"></a>00170 }
|
|
<a name="l00171"></a>00171
|
|
<a name="l00172"></a>00172 <span class="keyword">inline</span> StkFloat Shakers :: tickEqualize( StkFloat input )
|
|
<a name="l00173"></a>00173 {
|
|
<a name="l00174"></a>00174 equalizer_.inputs[0] = input;
|
|
<a name="l00175"></a>00175 equalizer_.outputs[0] = equalizer_.b[0] * equalizer_.inputs[0] + equalizer_.b[1] * equalizer_.inputs[1] + equalizer_.b[2] * equalizer_.inputs[2];
|
|
<a name="l00176"></a>00176 equalizer_.inputs[2] = equalizer_.inputs[1];
|
|
<a name="l00177"></a>00177 equalizer_.inputs[1] = equalizer_.inputs[0];
|
|
<a name="l00178"></a>00178 <span class="keywordflow">return</span> equalizer_.outputs[0];
|
|
<a name="l00179"></a>00179 }
|
|
<a name="l00180"></a>00180
|
|
<a name="l00181"></a>00181 <span class="keyword">inline</span> <span class="keywordtype">int</span> Shakers :: randomInt( <span class="keywordtype">int</span> max ) <span class="comment">// Return random integer between 0 and max-1</span>
|
|
<a name="l00182"></a>00182 {
|
|
<a name="l00183"></a>00183 <span class="keywordflow">return</span> (<span class="keywordtype">int</span>) ((float)max * rand() / (RAND_MAX + 1.0) );
|
|
<a name="l00184"></a>00184 }
|
|
<a name="l00185"></a>00185
|
|
<a name="l00186"></a>00186 <span class="keyword">inline</span> StkFloat Shakers :: randomFloat( StkFloat max ) <span class="comment">// Return random float between 0.0 and max</span>
|
|
<a name="l00187"></a>00187 {
|
|
<a name="l00188"></a>00188 <span class="keywordflow">return</span> (StkFloat) (max * rand() / (RAND_MAX + 1.0) );
|
|
<a name="l00189"></a>00189 }
|
|
<a name="l00190"></a>00190
|
|
<a name="l00191"></a>00191 <span class="keyword">inline</span> StkFloat Shakers :: noise( <span class="keywordtype">void</span> ) <span class="comment">// Return random StkFloat float between -1.0 and 1.0</span>
|
|
<a name="l00192"></a>00192 {
|
|
<a name="l00193"></a>00193 <span class="keywordflow">return</span> ( (StkFloat) ( 2.0 * rand() / (RAND_MAX + 1.0) ) - 1.0 );
|
|
<a name="l00194"></a>00194 }
|
|
<a name="l00195"></a>00195
|
|
<a name="l00196"></a>00196 <span class="keyword">const</span> StkFloat MIN_ENERGY = 0.001;
|
|
<a name="l00197"></a>00197 <span class="keyword">const</span> StkFloat WATER_FREQ_SWEEP = 1.0001;
|
|
<a name="l00198"></a>00198
|
|
<a name="l00199"></a>00199 <span class="keyword">inline</span> <span class="keywordtype">void</span> Shakers :: waterDrop( <span class="keywordtype">void</span> )
|
|
<a name="l00200"></a>00200 {
|
|
<a name="l00201"></a>00201 <span class="keywordflow">if</span> ( randomInt( 32767 ) < nObjects_) {
|
|
<a name="l00202"></a>00202 sndLevel_ = shakeEnergy_;
|
|
<a name="l00203"></a>00203 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = randomInt( 3 );
|
|
<a name="l00204"></a>00204 <span class="keywordflow">if</span> ( j == 0 && filters_[0].gain == 0.0 ) { <span class="comment">// don't change unless fully decayed</span>
|
|
<a name="l00205"></a>00205 tempFrequencies_[0] = baseFrequencies_[1] * (0.75 + (0.25 * noise()));
|
|
<a name="l00206"></a>00206 filters_[0].gain = fabs( noise() );
|
|
<a name="l00207"></a>00207 }
|
|
<a name="l00208"></a>00208 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (j == 1 && filters_[1].gain == 0.0) {
|
|
<a name="l00209"></a>00209 tempFrequencies_[1] = baseFrequencies_[1] * (1.0 + (0.25 * noise()));
|
|
<a name="l00210"></a>00210 filters_[1].gain = fabs( noise() );
|
|
<a name="l00211"></a>00211 }
|
|
<a name="l00212"></a>00212 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( filters_[2].gain == 0.0 ) {
|
|
<a name="l00213"></a>00213 tempFrequencies_[2] = baseFrequencies_[1] * (1.25 + (0.25 * noise()));
|
|
<a name="l00214"></a>00214 filters_[2].gain = fabs( noise() );
|
|
<a name="l00215"></a>00215 }
|
|
<a name="l00216"></a>00216 }
|
|
<a name="l00217"></a>00217
|
|
<a name="l00218"></a>00218 <span class="comment">// Sweep center frequencies.</span>
|
|
<a name="l00219"></a>00219 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<3; i++ ) { <span class="comment">// WATER_RESONANCES = 3</span>
|
|
<a name="l00220"></a>00220 filters_[i].gain *= baseRadii_[i];
|
|
<a name="l00221"></a>00221 <span class="keywordflow">if</span> ( filters_[i].gain > 0.001 ) {
|
|
<a name="l00222"></a>00222 tempFrequencies_[i] *= WATER_FREQ_SWEEP;
|
|
<a name="l00223"></a>00223 filters_[i].a[1] = -2.0 * baseRadii_[i] * cos( TWO_PI * tempFrequencies_[i] / <a class="code" href="classstk_1_1Stk.html#a5fbe37000a611ce56075ee7d8936472d" title="Static method that returns the current STK sample rate.">Stk::sampleRate</a>() );
|
|
<a name="l00224"></a>00224 }
|
|
<a name="l00225"></a>00225 <span class="keywordflow">else</span>
|
|
<a name="l00226"></a>00226 filters_[i].gain = 0.0;
|
|
<a name="l00227"></a>00227 }
|
|
<a name="l00228"></a>00228 }
|
|
<a name="l00229"></a>00229
|
|
<a name="l00230"></a><a class="code" href="classstk_1_1Shakers.html#ae06ebba276cef74cb8c83db4e33f21c2">00230</a> <span class="keyword">inline</span> StkFloat <a class="code" href="classstk_1_1Shakers.html#ae06ebba276cef74cb8c83db4e33f21c2" title="Compute and return one output sample.">Shakers :: tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> )
|
|
<a name="l00231"></a>00231 {
|
|
<a name="l00232"></a>00232 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> iTube = 0;
|
|
<a name="l00233"></a>00233 StkFloat input = 0.0;
|
|
<a name="l00234"></a>00234 <span class="keywordflow">if</span> ( shakerType_ == 19 || shakerType_ == 20 ) {
|
|
<a name="l00235"></a>00235 <span class="keywordflow">if</span> ( ratchetCount_ <= 0 ) <span class="keywordflow">return</span> lastFrame_[0] = 0.0;
|
|
<a name="l00236"></a>00236
|
|
<a name="l00237"></a>00237 shakeEnergy_ -= ( ratchetDelta_ + ( 0.002 * shakeEnergy_ ) );
|
|
<a name="l00238"></a>00238 <span class="keywordflow">if</span> ( shakeEnergy_ < 0.0 ) {
|
|
<a name="l00239"></a>00239 shakeEnergy_ = 1.0;
|
|
<a name="l00240"></a>00240 ratchetCount_--;
|
|
<a name="l00241"></a>00241 }
|
|
<a name="l00242"></a>00242
|
|
<a name="l00243"></a>00243 <span class="keywordflow">if</span> ( randomFloat( 1024 ) < nObjects_ )
|
|
<a name="l00244"></a>00244 sndLevel_ += shakeEnergy_ * shakeEnergy_;
|
|
<a name="l00245"></a>00245
|
|
<a name="l00246"></a>00246 <span class="comment">// Sound is enveloped noise</span>
|
|
<a name="l00247"></a>00247 input = sndLevel_ * noise() * shakeEnergy_;
|
|
<a name="l00248"></a>00248 }
|
|
<a name="l00249"></a>00249 <span class="keywordflow">else</span> {
|
|
<a name="l00250"></a>00250 <span class="keywordflow">if</span> ( shakeEnergy_ < MIN_ENERGY ) <span class="keywordflow">return</span> lastFrame_[0] = 0.0;
|
|
<a name="l00251"></a>00251
|
|
<a name="l00252"></a>00252 <span class="comment">// Exponential system decay</span>
|
|
<a name="l00253"></a>00253 shakeEnergy_ *= systemDecay_;
|
|
<a name="l00254"></a>00254
|
|
<a name="l00255"></a>00255 <span class="comment">// Random events</span>
|
|
<a name="l00256"></a>00256 <span class="keywordflow">if</span> ( shakerType_ == 21 ) {
|
|
<a name="l00257"></a>00257 waterDrop();
|
|
<a name="l00258"></a>00258 input = sndLevel_;
|
|
<a name="l00259"></a>00259 }
|
|
<a name="l00260"></a>00260 <span class="keywordflow">else</span> {
|
|
<a name="l00261"></a>00261 <span class="keywordflow">if</span> ( randomFloat( 1024.0 ) < nObjects_ ) {
|
|
<a name="l00262"></a>00262 sndLevel_ += shakeEnergy_;
|
|
<a name="l00263"></a>00263 input = sndLevel_;
|
|
<a name="l00264"></a>00264 <span class="comment">// Vary resonance frequencies if specified.</span>
|
|
<a name="l00265"></a>00265 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<nResonances_; i++ ) {
|
|
<a name="l00266"></a>00266 <span class="keywordflow">if</span> ( doVaryFrequency_[i] ) {
|
|
<a name="l00267"></a>00267 StkFloat tempRand = baseFrequencies_[i] * ( 1.0 + ( varyFactor_ * noise() ) );
|
|
<a name="l00268"></a>00268 filters_[i].a[1] = -2.0 * baseRadii_[i] * cos( TWO_PI * tempRand / <a class="code" href="classstk_1_1Stk.html#a5fbe37000a611ce56075ee7d8936472d" title="Static method that returns the current STK sample rate.">Stk::sampleRate</a>() );
|
|
<a name="l00269"></a>00269 }
|
|
<a name="l00270"></a>00270 }
|
|
<a name="l00271"></a>00271 <span class="keywordflow">if</span> ( shakerType_ == 22 ) iTube = randomInt( 7 ); <span class="comment">// ANGKLUNG_RESONANCES</span>
|
|
<a name="l00272"></a>00272 }
|
|
<a name="l00273"></a>00273 }
|
|
<a name="l00274"></a>00274 }
|
|
<a name="l00275"></a>00275
|
|
<a name="l00276"></a>00276 <span class="comment">// Exponential sound decay</span>
|
|
<a name="l00277"></a>00277 sndLevel_ *= soundDecay_;
|
|
<a name="l00278"></a>00278
|
|
<a name="l00279"></a>00279 <span class="comment">// Do resonance filtering</span>
|
|
<a name="l00280"></a>00280 lastFrame_[0] = 0.0;
|
|
<a name="l00281"></a>00281 <span class="keywordflow">if</span> ( shakerType_ == 22 ) {
|
|
<a name="l00282"></a>00282 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<nResonances_; i++ ) {
|
|
<a name="l00283"></a>00283 <span class="keywordflow">if</span> ( i == iTube )
|
|
<a name="l00284"></a>00284 lastFrame_[0] += tickResonance( filters_[i], input );
|
|
<a name="l00285"></a>00285 <span class="keywordflow">else</span>
|
|
<a name="l00286"></a>00286 lastFrame_[0] += tickResonance( filters_[i], 0.0 );
|
|
<a name="l00287"></a>00287 }
|
|
<a name="l00288"></a>00288 }
|
|
<a name="l00289"></a>00289 <span class="keywordflow">else</span> {
|
|
<a name="l00290"></a>00290 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<nResonances_; i++ )
|
|
<a name="l00291"></a>00291 lastFrame_[0] += tickResonance( filters_[i], input );
|
|
<a name="l00292"></a>00292 }
|
|
<a name="l00293"></a>00293
|
|
<a name="l00294"></a>00294 <span class="comment">// Do final FIR filtering (lowpass or highpass)</span>
|
|
<a name="l00295"></a>00295 lastFrame_[0] = tickEqualize( lastFrame_[0] );
|
|
<a name="l00296"></a>00296
|
|
<a name="l00297"></a>00297 <span class="comment">//if ( std::abs(lastFrame_[0]) > 1.0 )</span>
|
|
<a name="l00298"></a>00298 <span class="comment">// std::cout << "lastOutput = " << lastFrame_[0] << std::endl;</span>
|
|
<a name="l00299"></a>00299
|
|
<a name="l00300"></a>00300 <span class="keywordflow">return</span> lastFrame_[0];
|
|
<a name="l00301"></a>00301 }
|
|
<a name="l00302"></a>00302
|
|
<a name="l00303"></a><a class="code" href="classstk_1_1Shakers.html#a655713b658ddeb065d755997cac4b62e">00303</a> <span class="keyword">inline</span> <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>& <a class="code" href="classstk_1_1Shakers.html#ae06ebba276cef74cb8c83db4e33f21c2" title="Compute and return one output sample.">Shakers :: tick</a>( <a class="code" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a>& frames, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel )
|
|
<a name="l00304"></a>00304 {
|
|
<a name="l00305"></a>00305 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nChannels = lastFrame_.<a class="code" href="classstk_1_1StkFrames.html#aec7ef9c46675a24111aa6e2fda3ba870" title="Return the number of channels represented by the data.">channels</a>();
|
|
<a name="l00306"></a>00306 <span class="preprocessor">#if defined(_STK_DEBUG_)</span>
|
|
<a name="l00307"></a>00307 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( channel > frames.<a class="code" href="classstk_1_1StkFrames.html#aec7ef9c46675a24111aa6e2fda3ba870" title="Return the number of channels represented by the data.">channels</a>() - nChannels ) {
|
|
<a name="l00308"></a>00308 oStream_ << <span class="stringliteral">"Shakers::tick(): channel and StkFrames arguments are incompatible!"</span>;
|
|
<a name="l00309"></a>00309 <a class="code" href="classstk_1_1Stk.html#a48ac73a0d8ca28445ba1a054e1f061ff" title="Static function for error reporting and handling using c-strings.">handleError</a>( StkError::FUNCTION_ARGUMENT );
|
|
<a name="l00310"></a>00310 }
|
|
<a name="l00311"></a>00311 <span class="preprocessor">#endif</span>
|
|
<a name="l00312"></a>00312 <span class="preprocessor"></span>
|
|
<a name="l00313"></a>00313 StkFloat *samples = &frames[channel];
|
|
<a name="l00314"></a>00314 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j, hop = frames.<a class="code" href="classstk_1_1StkFrames.html#aec7ef9c46675a24111aa6e2fda3ba870" title="Return the number of channels represented by the data.">channels</a>() - nChannels;
|
|
<a name="l00315"></a>00315 <span class="keywordflow">if</span> ( nChannels == 1 ) {
|
|
<a name="l00316"></a>00316 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<frames.<a class="code" href="classstk_1_1StkFrames.html#a05b1ab6fa750a8221a7d65c30e0cdab9" title="Return the number of sample frames represented by the data.">frames</a>(); i++, samples += hop )
|
|
<a name="l00317"></a>00317 *samples++ = <a class="code" href="classstk_1_1Shakers.html#ae06ebba276cef74cb8c83db4e33f21c2" title="Compute and return one output sample.">tick</a>();
|
|
<a name="l00318"></a>00318 }
|
|
<a name="l00319"></a>00319 <span class="keywordflow">else</span> {
|
|
<a name="l00320"></a>00320 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<frames.<a class="code" href="classstk_1_1StkFrames.html#a05b1ab6fa750a8221a7d65c30e0cdab9" title="Return the number of sample frames represented by the data.">frames</a>(); i++, samples += hop ) {
|
|
<a name="l00321"></a>00321 *samples++ = <a class="code" href="classstk_1_1Shakers.html#ae06ebba276cef74cb8c83db4e33f21c2" title="Compute and return one output sample.">tick</a>();
|
|
<a name="l00322"></a>00322 <span class="keywordflow">for</span> ( j=1; j<nChannels; j++ )
|
|
<a name="l00323"></a>00323 *samples++ = lastFrame_[j];
|
|
<a name="l00324"></a>00324 }
|
|
<a name="l00325"></a>00325 }
|
|
<a name="l00326"></a>00326
|
|
<a name="l00327"></a>00327 <span class="keywordflow">return</span> frames;
|
|
<a name="l00328"></a>00328 }
|
|
<a name="l00329"></a>00329
|
|
<a name="l00330"></a>00330 } <span class="comment">// stk namespace</span>
|
|
<a name="l00331"></a>00331
|
|
<a name="l00332"></a>00332 <span class="preprocessor">#endif</span>
|
|
</pre></div></div>
|
|
<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-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
|
</table>
|
|
|
|
</BODY>
|
|
</HTML>
|