1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
<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="namespacestk.html">stk</a>::<a class="el" href="classstk_1_1Filter.html">Filter</a>
</div>
<div class="contents">
<h1>stk::Filter Class Reference</h1><!-- doxytag: class="stk::Filter" --><!-- doxytag: inherits="stk::Stk" -->
<p>STK abstract filter class.
<a href="#_details">More...</a></p>
<p><code>#include <<a class="el" href="Filter_8h_source.html">Filter.h</a>></code></p>
<div class="dynheader">
Inheritance diagram for stk::Filter:</div>
<div class="dynsection">
<div class="center">
<img src="classstk_1_1Filter.png" usemap="#stk::Filter_map" alt=""/>
<map id="stk::Filter_map" name="stk::Filter_map">
<area href="classstk_1_1Stk.html" alt="stk::Stk" shape="rect" coords="0,0,93,24"/>
<area href="classstk_1_1BiQuad.html" alt="stk::BiQuad" shape="rect" coords="103,112,196,136"/>
<area href="classstk_1_1Delay.html" alt="stk::Delay" shape="rect" coords="103,168,196,192"/>
<area href="classstk_1_1DelayA.html" alt="stk::DelayA" shape="rect" coords="103,224,196,248"/>
<area href="classstk_1_1DelayL.html" alt="stk::DelayL" shape="rect" coords="103,280,196,304"/>
<area href="classstk_1_1Fir.html" alt="stk::Fir" shape="rect" coords="103,336,196,360"/>
<area href="classstk_1_1FormSwep.html" alt="stk::FormSwep" shape="rect" coords="103,392,196,416"/>
<area href="classstk_1_1Iir.html" alt="stk::Iir" shape="rect" coords="103,448,196,472"/>
<area href="classstk_1_1OnePole.html" alt="stk::OnePole" shape="rect" coords="103,504,196,528"/>
<area href="classstk_1_1OneZero.html" alt="stk::OneZero" shape="rect" coords="103,560,196,584"/>
<area href="classstk_1_1PoleZero.html" alt="stk::PoleZero" shape="rect" coords="103,616,196,640"/>
<area href="classstk_1_1TapDelay.html" alt="stk::TapDelay" shape="rect" coords="103,672,196,696"/>
<area href="classstk_1_1TwoPole.html" alt="stk::TwoPole" shape="rect" coords="103,728,196,752"/>
<area href="classstk_1_1TwoZero.html" alt="stk::TwoZero" shape="rect" coords="103,784,196,808"/>
</map>
</div>
</div>
<p><a href="classstk_1_1Filter-members.html">List of all members.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afc70117c0133d4a5d9a651ceb691d7c0"></a><!-- doxytag: member="stk::Filter::Filter" ref="afc70117c0133d4a5d9a651ceb691d7c0" args="(void)" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#afc70117c0133d4a5d9a651ceb691d7c0">Filter</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Class constructor. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a48f23ab6613be35e3be8aceaf5adfdd7"></a><!-- doxytag: member="stk::Filter::channelsIn" ref="a48f23ab6613be35e3be8aceaf5adfdd7" args="(void) const " -->
unsigned int </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#a48f23ab6613be35e3be8aceaf5adfdd7">channelsIn</a> (void) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the number of input channels for the class. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4f1ed97c9ad8aef32e54b48da03f5275"></a><!-- doxytag: member="stk::Filter::channelsOut" ref="a4f1ed97c9ad8aef32e54b48da03f5275" args="(void) const " -->
unsigned int </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#a4f1ed97c9ad8aef32e54b48da03f5275">channelsOut</a> (void) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the number of output channels for the class. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a670b9cc23ac798d3239cb819e801363c"></a><!-- doxytag: member="stk::Filter::clear" ref="a670b9cc23ac798d3239cb819e801363c" args="(void)" -->
virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#a670b9cc23ac798d3239cb819e801363c">clear</a> (void)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Clears all internal states of the filter. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#a827b1bd3a99fa9af408cbd4eb559d212">setGain</a> (StkFloat gain)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the filter gain. <a href="#a827b1bd3a99fa9af408cbd4eb559d212"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af21e11b72ea59af4585c59600a0980c2"></a><!-- doxytag: member="stk::Filter::getGain" ref="af21e11b72ea59af4585c59600a0980c2" args="(void) const " -->
StkFloat </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#af21e11b72ea59af4585c59600a0980c2">getGain</a> (void) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the current filter gain. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">StkFloat </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#a6453c68dca60f87053c888b3635b7220">phaseDelay</a> (StkFloat frequency)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the filter phase delay at the specified frequency. <a href="#a6453c68dca60f87053c888b3635b7220"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab2d944f649693511dced1df249f0abe6"></a><!-- doxytag: member="stk::Filter::lastFrame" ref="ab2d944f649693511dced1df249f0abe6" args="(void) const " -->
const <a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#ab2d944f649693511dced1df249f0abe6">lastFrame</a> (void) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return an <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> reference to the last output sample frame. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Filter.html#a3260a238824c4a748ac057b84b7d3f21">tick</a> (<a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &frames, unsigned int channel=0)=0</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Take a channel of the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object as inputs to the filter and replace with corresponding outputs. <a href="#a3260a238824c4a748ac057b84b7d3f21"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>STK abstract filter class. </p>
<p>This class provides limited common functionality for STK digital filter subclasses. It is general enough to support both monophonic and polyphonic input/output classes.</p>
<p>by Perry R. Cook and Gary P. Scavone, 1995-2012. </p>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a827b1bd3a99fa9af408cbd4eb559d212"></a><!-- doxytag: member="stk::Filter::setGain" ref="a827b1bd3a99fa9af408cbd4eb559d212" args="(StkFloat gain)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::Filter::setGain </td>
<td>(</td>
<td class="paramtype">StkFloat </td>
<td class="paramname"> <em>gain</em></td>
<td> ) </td>
<td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the filter gain. </p>
<p>The gain is applied at the filter input and does not affect the coefficient values. The default gain value is 1.0. </p>
<p><div class="fragment"><pre class="fragment"><a name="l00042"></a>00042 { gain_ = gain; };
</pre></div></p>
</div>
</div>
<a class="anchor" id="a6453c68dca60f87053c888b3635b7220"></a><!-- doxytag: member="stk::Filter::phaseDelay" ref="a6453c68dca60f87053c888b3635b7220" args="(StkFloat frequency)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">StkFloat stk::Filter::phaseDelay </td>
<td>(</td>
<td class="paramtype">StkFloat </td>
<td class="paramname"> <em>frequency</em></td>
<td> ) </td>
<td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Return the filter phase delay at the specified frequency. </p>
<p>Note that the phase delay calculation accounts for the filter gain. The frequency value should be greater than 0.0 and less than or equal to one-half the sample rate. </p>
<p><div class="fragment"><pre class="fragment"><a name="l00094"></a>00094 {
<a name="l00095"></a>00095 <span class="keywordflow">if</span> ( frequency <= 0.0 || frequency > 0.5 * <a class="code" href="classstk_1_1Stk.html#a5fbe37000a611ce56075ee7d8936472d" title="Static method that returns the current STK sample rate.">Stk::sampleRate</a>() ) {
<a name="l00096"></a>00096 oStream_ << <span class="stringliteral">"Filter::phaseDelay: argument ("</span> << frequency << <span class="stringliteral">") is out of range!"</span>;
<a name="l00097"></a>00097 <a class="code" href="classstk_1_1Stk.html#a48ac73a0d8ca28445ba1a054e1f061ff" title="Static function for error reporting and handling using c-strings.">handleError</a>( StkError::WARNING ); <span class="keywordflow">return</span> 0.0;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099
<a name="l00100"></a>00100 StkFloat omegaT = 2 * 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="l00101"></a>00101 StkFloat real = 0.0, imag = 0.0;
<a name="l00102"></a>00102 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<b_.size(); i++ ) {
<a name="l00103"></a>00103 real += b_[i] * std::cos( i * omegaT );
<a name="l00104"></a>00104 imag -= b_[i] * std::sin( i * omegaT );
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106 real *= gain_;
<a name="l00107"></a>00107 imag *= gain_;
<a name="l00108"></a>00108
<a name="l00109"></a>00109 StkFloat phase = atan2( imag, real );
<a name="l00110"></a>00110
<a name="l00111"></a>00111 real = 0.0, imag = 0.0;
<a name="l00112"></a>00112 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<a_.size(); i++ ) {
<a name="l00113"></a>00113 real += a_[i] * std::cos( i * omegaT );
<a name="l00114"></a>00114 imag -= a_[i] * std::sin( i * omegaT );
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116
<a name="l00117"></a>00117 phase -= std::atan2( imag, real );
<a name="l00118"></a>00118 phase = std::fmod( -phase, 2 * PI );
<a name="l00119"></a>00119 <span class="keywordflow">return</span> phase / omegaT;
<a name="l00120"></a>00120 }
</pre></div></p>
</div>
</div>
<a class="anchor" id="a3260a238824c4a748ac057b84b7d3f21"></a><!-- doxytag: member="stk::Filter::tick" ref="a3260a238824c4a748ac057b84b7d3f21" args="(StkFrames &frames, unsigned int channel=0)=0" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual <a class="el" href="classstk_1_1StkFrames.html">StkFrames</a>& stk::Filter::tick </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> & </td>
<td class="paramname"> <em>frames</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int </td>
<td class="paramname"> <em>channel</em> = <code>0</code></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [pure virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Take a channel of the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object as inputs to the filter and replace with corresponding outputs. </p>
<p>The <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> argument reference is returned. The <code>channel</code> argument must be less than the number of channels in the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> argument (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception. </p>
<p>Implemented in <a class="el" href="classstk_1_1BiQuad.html#af903e41217838470a5f267a20b905a12">stk::BiQuad</a>, <a class="el" href="classstk_1_1Delay.html#a93fe8e45acb933889be812f35810f977">stk::Delay</a>, <a class="el" href="classstk_1_1DelayA.html#a57c568d56e5ed35926cfc23f83d48d98">stk::DelayA</a>, <a class="el" href="classstk_1_1DelayL.html#acdc5d41de53c53d9d4b39ee8a46fb96c">stk::DelayL</a>, <a class="el" href="classstk_1_1Fir.html#a602e5ce0cd93f5103796ffd50ed8c988">stk::Fir</a>, <a class="el" href="classstk_1_1FormSwep.html#a27f68dc2bb3fa41322ae49cf59cc9884">stk::FormSwep</a>, <a class="el" href="classstk_1_1Iir.html#ad03f40e022b2adfe942d30908ec34793">stk::Iir</a>, <a class="el" href="classstk_1_1OnePole.html#af6611322a3c17f728cf6d57a4f932a1f">stk::OnePole</a>, <a class="el" href="classstk_1_1OneZero.html#a2ca42a158bed919d8578c4a2dd184b3d">stk::OneZero</a>, <a class="el" href="classstk_1_1PoleZero.html#a1b5e97a13c582d97cfaa7fcbd4211b47">stk::PoleZero</a>, <a class="el" href="classstk_1_1TapDelay.html#a9255a00f0d7588ba5b51a12ba5db08c0">stk::TapDelay</a>, <a class="el" href="classstk_1_1TwoPole.html#a9e8bd9ed925a1c4966fbc0b0799ce46b">stk::TwoPole</a>, and <a class="el" href="classstk_1_1TwoZero.html#a26e2a1e21831ccb414dbede864afc63c">stk::TwoZero</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="Filter_8h_source.html">Filter.h</a></li>
</ul>
</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>
|