Files
stk/doc/html/FMVoices_8h-source.html
2013-09-29 23:47:43 +02:00

86 lines
7.0 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"> &nbsp; <img src="ccrma.gif"> &nbsp; <img src="mcgill.gif"><P>
<a class="qindex" href="index.html">Home</a> &nbsp; <a class="qindex" href="information.html">Information</a> &nbsp; <a class="qindex" href="classes.html">Classes</a> &nbsp; <a class="qindex" href="download.html">Download</a> &nbsp; <a class="qindex" href="usage.html">Usage</a> &nbsp; <a class="qindex" href="maillist.html">Mail List</a> &nbsp; <a class="qindex" href="system.html">Requirements</a> &nbsp; <a class="qindex" href="links.html">Links</a> &nbsp; <a class="qindex" href="faq.html">FAQ</a> &nbsp; <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>FMVoices.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef STK_FMVOICES_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define STK_FMVOICES_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include "FM.h"</span>
<a name="l00005"></a>00005
<a name="l00006"></a>00006 <span class="keyword">namespace </span>stk {
<a name="l00007"></a>00007
<a name="l00008"></a>00008 <span class="comment">/***************************************************/</span>
<a name="l00038"></a>00038 <span class="comment">/***************************************************/</span>
<a name="l00039"></a>00039
<a name="l00040"></a><a class="code" href="classstk_1_1FMVoices.html">00040</a> <span class="keyword">class </span><a class="code" href="classstk_1_1FMVoices.html" title="STK singing FM synthesis instrument.">FMVoices</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1FM.html" title="STK abstract FM synthesis base class.">FM</a>
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042 <span class="keyword">public</span>:
<a name="l00044"></a>00044
<a name="l00047"></a>00047 <a class="code" href="classstk_1_1FMVoices.html#27d5570c83cad660a53f04d86d01c888" title="Class constructor.">FMVoices</a>( <span class="keywordtype">void</span> );
<a name="l00048"></a>00048
<a name="l00050"></a>00050 <a class="code" href="classstk_1_1FMVoices.html#8ff218d379ec020a38e1bc7203409e37" title="Class destructor.">~FMVoices</a>( <span class="keywordtype">void</span> );
<a name="l00051"></a>00051
<a name="l00053"></a>00053 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FMVoices.html#f47a92f6892f3a5bef5226d4772fc8cb" title="Set instrument parameters for a particular frequency.">setFrequency</a>( StkFloat frequency );
<a name="l00054"></a>00054
<a name="l00056"></a>00056 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FMVoices.html#f2fd5dd9af61db94ff1cb556e8e5cf4c" title="Start a note with the given frequency and amplitude.">noteOn</a>( StkFloat frequency, StkFloat amplitude );
<a name="l00057"></a>00057
<a name="l00059"></a>00059 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1FMVoices.html#24e17888ff4e01edff96d81461d670a8" 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="l00060"></a>00060
<a name="l00062"></a>00062 StkFloat <a class="code" href="classstk_1_1FMVoices.html#31111029e36d00230586250df7b4d887" title="Compute and return one output sample.">tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> channel = 0 );
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="keyword">protected</span>:
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keywordtype">int</span> currentVowel_;
<a name="l00067"></a>00067 StkFloat tilt_[3];
<a name="l00068"></a>00068 StkFloat mods_[3];
<a name="l00069"></a>00069 };
<a name="l00070"></a>00070
<a name="l00071"></a><a class="code" href="classstk_1_1FMVoices.html#31111029e36d00230586250df7b4d887">00071</a> <span class="keyword">inline</span> StkFloat <a class="code" href="classstk_1_1FMVoices.html#31111029e36d00230586250df7b4d887" title="Compute and return one output sample.">FMVoices :: tick</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> )
<a name="l00072"></a>00072 {
<a name="l00073"></a>00073 <span class="keyword">register</span> StkFloat temp, temp2;
<a name="l00074"></a>00074
<a name="l00075"></a>00075 temp = gains_[3] * adsr_[3]-&gt;tick() * waves_[3]-&gt;tick();
<a name="l00076"></a>00076 temp2 = vibrato_.<a class="code" href="classstk_1_1SineWave.html#31a55627bf8064919b5e063059260eda" title="Compute and return one output sample.">tick</a>() * modDepth_ * 0.1;
<a name="l00077"></a>00077
<a name="l00078"></a>00078 waves_[0]-&gt;setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[0]);
<a name="l00079"></a>00079 waves_[1]-&gt;setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[1]);
<a name="l00080"></a>00080 waves_[2]-&gt;setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[2]);
<a name="l00081"></a>00081 waves_[3]-&gt;setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[3]);
<a name="l00082"></a>00082
<a name="l00083"></a>00083 waves_[0]-&gt;addPhaseOffset(temp * mods_[0]);
<a name="l00084"></a>00084 waves_[1]-&gt;addPhaseOffset(temp * mods_[1]);
<a name="l00085"></a>00085 waves_[2]-&gt;addPhaseOffset(temp * mods_[2]);
<a name="l00086"></a>00086 waves_[3]-&gt;addPhaseOffset( twozero_.<a class="code" href="classstk_1_1TwoZero.html#e9808b0152902d0067ea24ccfba0b4ba" title="Return the last computed output value.">lastOut</a>() );
<a name="l00087"></a>00087 twozero_.<a class="code" href="classstk_1_1TwoZero.html#cf92a66aeb2024cfcdb9d71ecadf3d82" title="Input one sample to the filter and return one output.">tick</a>( temp );
<a name="l00088"></a>00088 temp = gains_[0] * tilt_[0] * adsr_[0]-&gt;tick() * waves_[0]-&gt;tick();
<a name="l00089"></a>00089 temp += gains_[1] * tilt_[1] * adsr_[1]-&gt;tick() * waves_[1]-&gt;tick();
<a name="l00090"></a>00090 temp += gains_[2] * tilt_[2] * adsr_[2]-&gt;tick() * waves_[2]-&gt;tick();
<a name="l00091"></a>00091
<a name="l00092"></a>00092 lastFrame_[0] = temp * 0.33;
<a name="l00093"></a>00093 <span class="keywordflow">return</span> lastFrame_[0];
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095
<a name="l00096"></a>00096 } <span class="comment">// stk namespace</span>
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <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>&copy;1995-2009 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>