File: classstk_1_1Asymp.html

package info (click to toggle)
stk 4.4.4-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 24,856 kB
  • sloc: cpp: 33,976; tcl: 2,375; sh: 2,319; ansic: 163; perl: 114; makefile: 37
file content (162 lines) | stat: -rw-r--r-- 14,210 bytes parent folder | download | duplicates (2)
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
<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_1Asymp.html">Asymp</a>
  </div>
<div class="contents">
<h1>stk::Asymp Class Reference</h1><!-- doxytag: class="stk::Asymp" --><!-- doxytag: inherits="stk::Generator" -->
<p>STK asymptotic curve envelope class.  
<a href="#_details">More...</a></p>

<p><code>#include &lt;<a class="el" href="Asymp_8h_source.html">Asymp.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for stk::Asymp:</div>
<div class="dynsection">
 <div class="center">
  <img src="classstk_1_1Asymp.png" usemap="#stk::Asymp_map" alt=""/>
  <map id="stk::Asymp_map" name="stk::Asymp_map">
<area href="classstk_1_1Generator.html" alt="stk::Generator" shape="rect" coords="0,56,90,80"/>
<area href="classstk_1_1Stk.html" alt="stk::Stk" shape="rect" coords="0,0,90,24"/>
</map>
 </div>
</div>

<p><a href="classstk_1_1Asymp-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="ad8ea9fc5621a1d8b81001d459de265a0"></a><!-- doxytag: member="stk::Asymp::Asymp" ref="ad8ea9fc5621a1d8b81001d459de265a0" args="(void)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#ad8ea9fc5621a1d8b81001d459de265a0">Asymp</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad869abbd938c263a2c177de636f5a57c"></a><!-- doxytag: member="stk::Asymp::~Asymp" ref="ad869abbd938c263a2c177de636f5a57c" args="(void)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#ad869abbd938c263a2c177de636f5a57c">~Asymp</a> (void)</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="a51f0aad846eb6bda4c20eb63534786e2"></a><!-- doxytag: member="stk::Asymp::keyOn" ref="a51f0aad846eb6bda4c20eb63534786e2" args="(void)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#a51f0aad846eb6bda4c20eb63534786e2">keyOn</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set target = 1. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a082e765dc3bd6b452e92b602af7a1042"></a><!-- doxytag: member="stk::Asymp::keyOff" ref="a082e765dc3bd6b452e92b602af7a1042" args="(void)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#a082e765dc3bd6b452e92b602af7a1042">keyOff</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set target = 0. <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_1Asymp.html#aebd8ebaf6f6c9570d3ee78e1bcbbcbd2">setTau</a> (StkFloat tau)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the asymptotic rate via the time factor <em>tau</em> (must be &gt; 0).  <a href="#aebd8ebaf6f6c9570d3ee78e1bcbbcbd2"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aca998e9c4ae86b4958da59fc9433268c"></a><!-- doxytag: member="stk::Asymp::setTime" ref="aca998e9c4ae86b4958da59fc9433268c" args="(StkFloat time)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#aca998e9c4ae86b4958da59fc9433268c">setTime</a> (StkFloat time)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the asymptotic rate based on a time duration (must be &gt; 0). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="afa6fcf4bf3060c0c6092701e409d5fbf"></a><!-- doxytag: member="stk::Asymp::setT60" ref="afa6fcf4bf3060c0c6092701e409d5fbf" args="(StkFloat t60)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#afa6fcf4bf3060c0c6092701e409d5fbf">setT60</a> (StkFloat t60)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the asymptotic rate such that the target value is perceptually reached (to within -60dB of the target) in <em>t60</em> seconds. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7b0f7025ba5f268f1e5ce097b209f0ec"></a><!-- doxytag: member="stk::Asymp::setTarget" ref="a7b0f7025ba5f268f1e5ce097b209f0ec" args="(StkFloat target)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#a7b0f7025ba5f268f1e5ce097b209f0ec">setTarget</a> (StkFloat target)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the target value. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a81881bb8aca615f69bbbfd56267f971c"></a><!-- doxytag: member="stk::Asymp::setValue" ref="a81881bb8aca615f69bbbfd56267f971c" args="(StkFloat value)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#a81881bb8aca615f69bbbfd56267f971c">setValue</a> (StkFloat value)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set current and target values to <em>value</em>. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aaba01ef0ac1a493a14a73c3b29259bde"></a><!-- doxytag: member="stk::Asymp::getState" ref="aaba01ef0ac1a493a14a73c3b29259bde" args="(void) const " -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#aaba01ef0ac1a493a14a73c3b29259bde">getState</a> (void) const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the current envelope <em>state</em> (0 = at target, 1 otherwise). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aeb868c171e07206e2d5d30f8ce8f4436"></a><!-- doxytag: member="stk::Asymp::lastOut" ref="aeb868c171e07206e2d5d30f8ce8f4436" args="(void) const " -->
StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#aeb868c171e07206e2d5d30f8ce8f4436">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="a64df3b44aa1033b642d7a8a93659580e"></a><!-- doxytag: member="stk::Asymp::tick" ref="a64df3b44aa1033b642d7a8a93659580e" args="(void)" -->
StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Asymp.html#a64df3b44aa1033b642d7a8a93659580e">tick</a> (void)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Compute and return one output sample. <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_1Asymp.html#a2647bc013816f026915b1e92ddd6a322">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">Fill a channel of the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object with computed outputs.  <a href="#a2647bc013816f026915b1e92ddd6a322"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>STK asymptotic curve envelope class. </p>
<p>This class implements a simple envelope generator which asymptotically approaches a target value. The algorithm used is of the form:</p>
<p>y[n] = a y[n-1] + (1-a) target,</p>
<p>where a = exp(-T/tau), T is the sample period, and tau is a time constant. The user can set the time constant (default value = 0.3) and target value. Theoretically, this recursion never reaches its target, though the calculations in this class are stopped when the current value gets within a small threshold value of the target (at which time the current value is set to the target). It responds to <em>keyOn</em> and <em>keyOff</em> messages by ramping to 1.0 on keyOn and to 0.0 on keyOff.</p>
<p>by Perry R. Cook and Gary P. Scavone, 1995-2012. </p>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aebd8ebaf6f6c9570d3ee78e1bcbbcbd2"></a><!-- doxytag: member="stk::Asymp::setTau" ref="aebd8ebaf6f6c9570d3ee78e1bcbbcbd2" args="(StkFloat tau)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void stk::Asymp::setTau </td>
          <td>(</td>
          <td class="paramtype">StkFloat&nbsp;</td>
          <td class="paramname"> <em>tau</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Set the asymptotic rate via the time factor <em>tau</em> (must be &gt; 0). </p>
<p>The rate is computed as described above. The value of <em>tau</em> must be greater than zero. Values of <em>tau</em> close to zero produce fast approach rates, while values greater than 1.0 produce rather slow rates. </p>

</div>
</div>
<a class="anchor" id="a2647bc013816f026915b1e92ddd6a322"></a><!-- doxytag: member="stk::Asymp::tick" ref="a2647bc013816f026915b1e92ddd6a322" 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::Asymp::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>Fill a channel of the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object with computed outputs. </p>
<p>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_1Generator.html#a86bb0421223cf27e25704d5f27b97425">stk::Generator</a>.</p>

<p><div class="fragment"><pre class="fragment"><a name="l00128"></a>00128 {
<a name="l00129"></a>00129 <span class="preprocessor">#if defined(_STK_DEBUG_)</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span>  <span class="keywordflow">if</span> ( channel &gt;= frames.channels() ) {
<a name="l00131"></a>00131     oStream_ &lt;&lt; <span class="stringliteral">&quot;Asymp::tick(): channel and StkFrames arguments are incompatible!&quot;</span>;
<a name="l00132"></a>00132     <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="l00133"></a>00133   }
<a name="l00134"></a>00134 <span class="preprocessor">#endif</span>
<a name="l00135"></a>00135 <span class="preprocessor"></span>
<a name="l00136"></a>00136   StkFloat *samples = &amp;frames[channel];
<a name="l00137"></a>00137   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hop = frames.channels();
<a name="l00138"></a>00138   <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="l00139"></a>00139     *samples = <a class="code" href="classstk_1_1Asymp.html#a64df3b44aa1033b642d7a8a93659580e" title="Compute and return one output sample.">Asymp::tick</a>();
<a name="l00140"></a>00140 
<a name="l00141"></a>00141   <span class="keywordflow">return</span> frames;
<a name="l00142"></a>00142 }
</pre></div></p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="Asymp_8h_source.html">Asymp.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-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>

</BODY>
</HTML>