Files
stk/doc/html/classstk_1_1OnePole.html
2013-09-29 23:49:37 +02:00

219 lines
17 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.6.2 -->
<div class="navpath"><a class="el" href="namespacestk.html">stk</a>::<a class="el" href="classstk_1_1OnePole.html">OnePole</a>
</div>
<div class="contents">
<h1>stk::OnePole Class Reference</h1><!-- doxytag: class="stk::OnePole" --><!-- doxytag: inherits="stk::Filter" -->
<p>STK one-pole filter class.
<a href="#_details">More...</a></p>
<p><code>#include &lt;<a class="el" href="OnePole_8h_source.html">OnePole.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for stk::OnePole:</div>
<div class="dynsection">
<div class="center">
<img src="classstk_1_1OnePole.png" usemap="#stk::OnePole_map" alt=""/>
<map id="stk::OnePole_map" name="stk::OnePole_map">
<area href="classstk_1_1Filter.html" alt="stk::Filter" shape="rect" coords="0,56,82,80"/>
<area href="classstk_1_1Stk.html" alt="stk::Stk" shape="rect" coords="0,0,82,24"/>
</map>
</div>
</div>
<p><a href="classstk_1_1OnePole-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="ad0d322987780778e9f53f34837bea4b8"></a><!-- doxytag: member="stk::OnePole::OnePole" ref="ad0d322987780778e9f53f34837bea4b8" args="(StkFloat thePole=0.9)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#ad0d322987780778e9f53f34837bea4b8">OnePole</a> (StkFloat thePole=0.9)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The default constructor creates a low-pass filter (pole at z = 0.9). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a03ac84c397620180090d86f2ecafccc5"></a><!-- doxytag: member="stk::OnePole::~OnePole" ref="a03ac84c397620180090d86f2ecafccc5" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#a03ac84c397620180090d86f2ecafccc5">~OnePole</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Class destructor. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aff587fbf5ba36b3dd24b2fb8d66b7e00"></a><!-- doxytag: member="stk::OnePole::setB0" ref="aff587fbf5ba36b3dd24b2fb8d66b7e00" args="(StkFloat b0)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#aff587fbf5ba36b3dd24b2fb8d66b7e00">setB0</a> (StkFloat b0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the b[0] coefficient value. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1f99beebd9c4fbdfce6478e40d7625d8"></a><!-- doxytag: member="stk::OnePole::setA1" ref="a1f99beebd9c4fbdfce6478e40d7625d8" args="(StkFloat a1)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#a1f99beebd9c4fbdfce6478e40d7625d8">setA1</a> (StkFloat a1)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the a[1] coefficient value. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa92dd54382721d5151ef29b291ba6cb5"></a><!-- doxytag: member="stk::OnePole::setCoefficients" ref="aa92dd54382721d5151ef29b291ba6cb5" args="(StkFloat b0, StkFloat a1, bool clearState=false)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#aa92dd54382721d5151ef29b291ba6cb5">setCoefficients</a> (StkFloat b0, StkFloat a1, bool clearState=false)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set all filter coefficients. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#acc1aaa35c6d5ffbbebfe0c4bfa7d1132">setPole</a> (StkFloat thePole)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the pole position in the z-plane. <a href="#acc1aaa35c6d5ffbbebfe0c4bfa7d1132"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad1ad906374102791a01bfd60844028ec"></a><!-- doxytag: member="stk::OnePole::lastOut" ref="ad1ad906374102791a01bfd60844028ec" args="(void) const " -->
StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#ad1ad906374102791a01bfd60844028ec">lastOut</a> (void) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the last computed output value. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3c83b6d43f76bec06f11caa9de76881e"></a><!-- doxytag: member="stk::OnePole::tick" ref="a3c83b6d43f76bec06f11caa9de76881e" args="(StkFloat input)" -->
StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#a3c83b6d43f76bec06f11caa9de76881e">tick</a> (StkFloat input)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Input one sample to the filter and return one output. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#af6611322a3c17f728cf6d57a4f932a1f">tick</a> (<a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;frames, unsigned int channel=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</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="#af6611322a3c17f728cf6d57a4f932a1f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1OnePole.html#a495943f1659f2da6208703a24275defb">tick</a> (<a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;iFrames, <a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;oFrames, unsigned int iChannel=0, unsigned int oChannel=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Take a channel of the <code>iFrames</code> object as inputs to the filter and write outputs to the <code>oFrames</code> object. <a href="#a495943f1659f2da6208703a24275defb"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>STK one-pole filter class. </p>
<p>This class implements a one-pole digital filter. A method is provided for setting the pole position along the real axis of the z-plane while maintaining a constant peak filter gain.</p>
<p>by Perry R. Cook and Gary P. Scavone, 1995-2011. </p>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="acc1aaa35c6d5ffbbebfe0c4bfa7d1132"></a><!-- doxytag: member="stk::OnePole::setPole" ref="acc1aaa35c6d5ffbbebfe0c4bfa7d1132" args="(StkFloat thePole)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::OnePole::setPole </td>
<td>(</td>
<td class="paramtype">StkFloat&nbsp;</td>
<td class="paramname"> <em>thePole</em></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the pole position in the z-plane. </p>
<p>This method sets the pole position along the real-axis of the z-plane and normalizes the coefficients for a maximum gain of one. A positive pole value produces a low-pass filter, while a negative pole value produces a high-pass filter. This method does not affect the filter <em>gain</em> value. The argument magnitude should be less than one to maintain filter stability. </p>
</div>
</div>
<a class="anchor" id="af6611322a3c17f728cf6d57a4f932a1f"></a><!-- doxytag: member="stk::OnePole::tick" ref="af6611322a3c17f728cf6d57a4f932a1f" args="(StkFrames &amp;frames, unsigned int channel=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp; stk::OnePole::tick </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;&nbsp;</td>
<td class="paramname"> <em>frames</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>channel</em> = <code>0</code></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [inline, 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>Implements <a class="el" href="classstk_1_1Filter.html#a3260a238824c4a748ac057b84b7d3f21">stk::Filter</a>.</p>
<p><div class="fragment"><pre class="fragment"><a name="l00090"></a>00090 {
<a name="l00091"></a>00091 <span class="preprocessor">#if defined(_STK_DEBUG_)</span>
<a name="l00092"></a>00092 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( channel &gt;= frames.channels() ) {
<a name="l00093"></a>00093 oStream_ &lt;&lt; <span class="stringliteral">&quot;OnePole::tick(): channel and StkFrames arguments are incompatible!&quot;</span>;
<a name="l00094"></a>00094 <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="l00095"></a>00095 }
<a name="l00096"></a>00096 <span class="preprocessor">#endif</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span>
<a name="l00098"></a>00098 StkFloat *samples = &amp;frames[channel];
<a name="l00099"></a>00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hop = frames.channels();
<a name="l00100"></a>00100 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;frames.frames(); i++, samples += hop ) {
<a name="l00101"></a>00101 inputs_[0] = gain_ * *samples;
<a name="l00102"></a>00102 *samples = b_[0] * inputs_[0] - a_[1] * outputs_[1];
<a name="l00103"></a>00103 outputs_[1] = *samples;
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105
<a name="l00106"></a>00106 lastFrame_[0] = outputs_[1];
<a name="l00107"></a>00107 <span class="keywordflow">return</span> frames;
<a name="l00108"></a>00108 }
</pre></div></p>
</div>
</div>
<a class="anchor" id="a495943f1659f2da6208703a24275defb"></a><!-- doxytag: member="stk::OnePole::tick" ref="a495943f1659f2da6208703a24275defb" args="(StkFrames &amp;iFrames, StkFrames &amp;oFrames, unsigned int iChannel=0, unsigned int oChannel=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp; stk::OnePole::tick </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;&nbsp;</td>
<td class="paramname"> <em>iFrames</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &amp;&nbsp;</td>
<td class="paramname"> <em>oFrames</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>iChannel</em> = <code>0</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>oChannel</em> = <code>0</code></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Take a channel of the <code>iFrames</code> object as inputs to the filter and write outputs to the <code>oFrames</code> object. </p>
<p>The <code>iFrames</code> object reference is returned. Each channel argument must be less than the number of channels in the corresponding <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><div class="fragment"><pre class="fragment"><a name="l00111"></a>00111 {
<a name="l00112"></a>00112 <span class="preprocessor">#if defined(_STK_DEBUG_)</span>
<a name="l00113"></a>00113 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( iChannel &gt;= iFrames.channels() || oChannel &gt;= oFrames.channels() ) {
<a name="l00114"></a>00114 oStream_ &lt;&lt; <span class="stringliteral">&quot;OnePole::tick(): channel and StkFrames arguments are incompatible!&quot;</span>;
<a name="l00115"></a>00115 <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="l00116"></a>00116 }
<a name="l00117"></a>00117 <span class="preprocessor">#endif</span>
<a name="l00118"></a>00118 <span class="preprocessor"></span>
<a name="l00119"></a>00119 StkFloat *iSamples = &amp;iFrames[iChannel];
<a name="l00120"></a>00120 StkFloat *oSamples = &amp;oFrames[oChannel];
<a name="l00121"></a>00121 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> iHop = iFrames.channels(), oHop = oFrames.channels();
<a name="l00122"></a>00122 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;iFrames.frames(); i++, iSamples += iHop, oSamples += oHop ) {
<a name="l00123"></a>00123 inputs_[0] = gain_ * *iSamples;
<a name="l00124"></a>00124 *oSamples = b_[0] * inputs_[0] - a_[1] * outputs_[1];
<a name="l00125"></a>00125 outputs_[1] = *oSamples;
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127
<a name="l00128"></a>00128 lastFrame_[0] = outputs_[1];
<a name="l00129"></a>00129 <span class="keywordflow">return</span> iFrames;
<a name="l00130"></a>00130 }
</pre></div></p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="OnePole_8h_source.html">OnePole.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>&copy;1995-2011 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>