mirror of
https://github.com/thestk/stk
synced 2026-01-11 20:11:52 +00:00
96 lines
10 KiB
HTML
96 lines
10 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.5.8 -->
|
|
<div class="navpath"><a class="el" href="dir_c28bfe24b93fcab464ea84f988cb34ef.html">include</a>
|
|
</div>
|
|
<div class="contents">
|
|
<h1>Mandolin.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef STK_MANDOLIN_H</span>
|
|
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define STK_MANDOLIN_H</span>
|
|
<a name="l00003"></a>00003 <span class="preprocessor"></span>
|
|
<a name="l00004"></a>00004 <span class="preprocessor">#include "PluckTwo.h"</span>
|
|
<a name="l00005"></a>00005 <span class="preprocessor">#include "FileWvIn.h"</span>
|
|
<a name="l00006"></a>00006
|
|
<a name="l00007"></a>00007 <span class="keyword">namespace </span>stk {
|
|
<a name="l00008"></a>00008
|
|
<a name="l00009"></a>00009 <span class="comment">/***************************************************/</span>
|
|
<a name="l00036"></a>00036 <span class="comment">/***************************************************/</span>
|
|
<a name="l00037"></a>00037
|
|
<a name="l00038"></a><a class="code" href="classstk_1_1Mandolin.html">00038</a> <span class="keyword">class </span><a class="code" href="classstk_1_1Mandolin.html" title="STK mandolin instrument model class.">Mandolin</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1PluckTwo.html" title="STK enhanced plucked string model class.">PluckTwo</a>
|
|
<a name="l00039"></a>00039 {
|
|
<a name="l00040"></a>00040 <span class="keyword">public</span>:
|
|
<a name="l00042"></a>00042 <a class="code" href="classstk_1_1Mandolin.html#5b2aaaf5697cbe57df62b568982f6300" title="Class constructor, taking the lowest desired playing frequency.">Mandolin</a>( StkFloat lowestFrequency );
|
|
<a name="l00043"></a>00043
|
|
<a name="l00045"></a>00045 <a class="code" href="classstk_1_1Mandolin.html#92d50a0f0c1c974683bf4685cfc6ff86" title="Class destructor.">~Mandolin</a>( <span class="keywordtype">void</span> );
|
|
<a name="l00046"></a>00046
|
|
<a name="l00048"></a>00048 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Mandolin.html#3a2398d39b72e1c330f81f6545ac0f5c" title="Pluck the strings with the given amplitude (0.0 - 1.0) using the current frequency...">pluck</a>( StkFloat amplitude );
|
|
<a name="l00049"></a>00049
|
|
<a name="l00051"></a>00051 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Mandolin.html#3a2398d39b72e1c330f81f6545ac0f5c" title="Pluck the strings with the given amplitude (0.0 - 1.0) using the current frequency...">pluck</a>( StkFloat amplitude,StkFloat position );
|
|
<a name="l00052"></a>00052
|
|
<a name="l00054"></a>00054 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Mandolin.html#8b60733652e54f1d6c93d63c915c9ca7" title="Start a note with the given frequency and amplitude (0.0 - 1.0).">noteOn</a>( StkFloat frequency, StkFloat amplitude );
|
|
<a name="l00055"></a>00055
|
|
<a name="l00057"></a>00057 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Mandolin.html#21a5b0669b013cfd9c7142174530f629" title="Set the body size (a value of 1.0 produces the &quot;default&quot; size).">setBodySize</a>( StkFloat size );
|
|
<a name="l00058"></a>00058
|
|
<a name="l00060"></a>00060 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Mandolin.html#bf341aa5e7d751012178ff7b853b73a1" 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="l00061"></a>00061
|
|
<a name="l00063"></a>00063 StkFloat <a class="code" href="classstk_1_1Mandolin.html#99f5b51e76c97299dd8c58f27a6d0e62" title="Compute and return one output sample.">tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );
|
|
<a name="l00064"></a>00064
|
|
<a name="l00065"></a>00065 <span class="keyword">protected</span>:
|
|
<a name="l00066"></a>00066
|
|
<a name="l00067"></a>00067 <a class="code" href="classstk_1_1FileWvIn.html" title="STK audio file input class.">FileWvIn</a> *soundfile_[12];
|
|
<a name="l00068"></a>00068 <span class="keywordtype">int</span> mic_;
|
|
<a name="l00069"></a>00069 <span class="keywordtype">long</span> dampTime_;
|
|
<a name="l00070"></a>00070 <span class="keywordtype">bool</span> waveDone_;
|
|
<a name="l00071"></a>00071 };
|
|
<a name="l00072"></a>00072
|
|
<a name="l00073"></a><a class="code" href="classstk_1_1Mandolin.html#99f5b51e76c97299dd8c58f27a6d0e62">00073</a> <span class="keyword">inline</span> StkFloat <a class="code" href="classstk_1_1Mandolin.html#99f5b51e76c97299dd8c58f27a6d0e62" title="Compute and return one output sample.">Mandolin :: tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> )
|
|
<a name="l00074"></a>00074 {
|
|
<a name="l00075"></a>00075 StkFloat temp = 0.0;
|
|
<a name="l00076"></a>00076 <span class="keywordflow">if</span> ( !waveDone_ ) {
|
|
<a name="l00077"></a>00077 <span class="comment">// Scale the pluck excitation with comb</span>
|
|
<a name="l00078"></a>00078 <span class="comment">// filtering for the duration of the file.</span>
|
|
<a name="l00079"></a>00079 temp = soundfile_[mic_]-><a class="code" href="classstk_1_1FileWvIn.html#da668a0bc0bf89e155ef341de00babc2" title="Compute a sample frame and return the specified channel value.">tick</a>() * pluckAmplitude_;
|
|
<a name="l00080"></a>00080 temp = temp - combDelay_.<a class="code" href="classstk_1_1DelayL.html#1d01bbaf40cc20a0b70241bb8072da7f" title="Input one sample to the filter and return one output.">tick</a>(temp);
|
|
<a name="l00081"></a>00081 waveDone_ = soundfile_[mic_]-><a class="code" href="classstk_1_1FileWvIn.html#ca9ad0c12af3323e7bbf877513b0d10b" title="Query whether reading is complete.">isFinished</a>();
|
|
<a name="l00082"></a>00082 }
|
|
<a name="l00083"></a>00083
|
|
<a name="l00084"></a>00084 <span class="comment">// Damping hack to help avoid overflow on re-plucking.</span>
|
|
<a name="l00085"></a>00085 <span class="keywordflow">if</span> ( dampTime_ >=0 ) {
|
|
<a name="l00086"></a>00086 dampTime_ -= 1;
|
|
<a name="l00087"></a>00087 <span class="comment">// Calculate 1st delay filtered reflection plus pluck excitation.</span>
|
|
<a name="l00088"></a>00088 lastFrame_[0] = delayLine_.<a class="code" href="classstk_1_1DelayA.html#e602abe91560fb5f141db52333359b74" title="Input one sample to the filter and return one output.">tick</a>( filter_.<a class="code" href="classstk_1_1OneZero.html#9f52fa395257b15cb7351c6ccb2199da" title="Input one sample to the filter and return one output.">tick</a>( temp + (delayLine_.<a class="code" href="classstk_1_1DelayA.html#4372d0e178af1cb6ca465affddfb1566" title="Return the last computed output value.">lastOut</a>() * 0.7) ) );
|
|
<a name="l00089"></a>00089 <span class="comment">// Calculate 2nd delay just like the 1st.</span>
|
|
<a name="l00090"></a>00090 lastFrame_[0] += delayLine2_.<a class="code" href="classstk_1_1DelayA.html#e602abe91560fb5f141db52333359b74" title="Input one sample to the filter and return one output.">tick</a>( filter2_.<a class="code" href="classstk_1_1OneZero.html#9f52fa395257b15cb7351c6ccb2199da" title="Input one sample to the filter and return one output.">tick</a>( temp + (delayLine2_.<a class="code" href="classstk_1_1DelayA.html#4372d0e178af1cb6ca465affddfb1566" title="Return the last computed output value.">lastOut</a>() * 0.7) ) );
|
|
<a name="l00091"></a>00091 }
|
|
<a name="l00092"></a>00092 <span class="keywordflow">else</span> { <span class="comment">// No damping hack after 1 period.</span>
|
|
<a name="l00093"></a>00093 <span class="comment">// Calculate 1st delay filtered reflection plus pluck excitation.</span>
|
|
<a name="l00094"></a>00094 lastFrame_[0] = delayLine_.<a class="code" href="classstk_1_1DelayA.html#e602abe91560fb5f141db52333359b74" title="Input one sample to the filter and return one output.">tick</a>( filter_.<a class="code" href="classstk_1_1OneZero.html#9f52fa395257b15cb7351c6ccb2199da" title="Input one sample to the filter and return one output.">tick</a>( temp + (delayLine_.<a class="code" href="classstk_1_1DelayA.html#4372d0e178af1cb6ca465affddfb1566" title="Return the last computed output value.">lastOut</a>() * loopGain_) ) );
|
|
<a name="l00095"></a>00095 <span class="comment">// Calculate 2nd delay just like the 1st.</span>
|
|
<a name="l00096"></a>00096 lastFrame_[0] += delayLine2_.<a class="code" href="classstk_1_1DelayA.html#e602abe91560fb5f141db52333359b74" title="Input one sample to the filter and return one output.">tick</a>( filter2_.<a class="code" href="classstk_1_1OneZero.html#9f52fa395257b15cb7351c6ccb2199da" title="Input one sample to the filter and return one output.">tick</a>( temp + (delayLine2_.<a class="code" href="classstk_1_1DelayA.html#4372d0e178af1cb6ca465affddfb1566" title="Return the last computed output value.">lastOut</a>() * loopGain_) ) );
|
|
<a name="l00097"></a>00097 }
|
|
<a name="l00098"></a>00098
|
|
<a name="l00099"></a>00099 lastFrame_[0] *= 0.3;
|
|
<a name="l00100"></a>00100 <span class="keywordflow">return</span> lastFrame_[0];
|
|
<a name="l00101"></a>00101 }
|
|
<a name="l00102"></a>00102
|
|
<a name="l00103"></a>00103 } <span class="comment">// stk namespace</span>
|
|
<a name="l00104"></a>00104
|
|
<a name="l00105"></a>00105 <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-2009 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
|
</table>
|
|
|
|
</BODY>
|
|
</HTML>
|