Files
stk/doc/html/classstk_1_1BlitSquare.html
2013-09-29 23:48:48 +02:00

176 lines
13 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_1BlitSquare.html">BlitSquare</a>
</div>
<div class="contents">
<h1>stk::BlitSquare Class Reference</h1><!-- doxytag: class="stk::BlitSquare" --><!-- doxytag: inherits="stk::Generator" -->
<p>STK band-limited square wave class.
<a href="#_details">More...</a></p>
<p><code>#include &lt;<a class="el" href="BlitSquare_8h_source.html">BlitSquare.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for stk::BlitSquare:</div>
<div class="dynsection">
<div class="center">
<img src="classstk_1_1BlitSquare.png" usemap="#stk::BlitSquare_map" alt=""/>
<map id="stk::BlitSquare_map" name="stk::BlitSquare_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_1BlitSquare-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="a2cb3aee415a6ee75fa85b01e4e85d70b"></a><!-- doxytag: member="stk::BlitSquare::BlitSquare" ref="a2cb3aee415a6ee75fa85b01e4e85d70b" args="(StkFloat frequency=220.0)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1BlitSquare.html#a2cb3aee415a6ee75fa85b01e4e85d70b">BlitSquare</a> (StkFloat frequency=220.0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor that initializes BLIT frequency to 220 Hz. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4bc6e424ca1631f353f55846084634ef"></a><!-- doxytag: member="stk::BlitSquare::~BlitSquare" ref="a4bc6e424ca1631f353f55846084634ef" args="()" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1BlitSquare.html#a4bc6e424ca1631f353f55846084634ef">~BlitSquare</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="a8f6dbe07d7f64b24cc9a41f6208dd6c4"></a><!-- doxytag: member="stk::BlitSquare::reset" ref="a8f6dbe07d7f64b24cc9a41f6208dd6c4" args="()" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1BlitSquare.html#a8f6dbe07d7f64b24cc9a41f6208dd6c4">reset</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Resets the oscillator state and phase to 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_1BlitSquare.html#aeface58980a3ec865131f3cad59bbbef">setPhase</a> (StkFloat phase)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the phase of the signal. <a href="#aeface58980a3ec865131f3cad59bbbef"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1BlitSquare.html#abbda8cb84bcd36fc6d96130e9832a6af">getPhase</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the current phase of the signal. <a href="#abbda8cb84bcd36fc6d96130e9832a6af"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8d0d8e0a12987ebccc56c09c7e7dbd6a"></a><!-- doxytag: member="stk::BlitSquare::setFrequency" ref="a8d0d8e0a12987ebccc56c09c7e7dbd6a" args="(StkFloat frequency)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1BlitSquare.html#a8d0d8e0a12987ebccc56c09c7e7dbd6a">setFrequency</a> (StkFloat frequency)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the impulse train rate in terms of a frequency in Hz. <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_1BlitSquare.html#a94521b4224d0873f5e783c721c123b21">setHarmonics</a> (unsigned int nHarmonics=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the number of harmonics generated in the signal. <a href="#a94521b4224d0873f5e783c721c123b21"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a77972e4e1c53600bf80cf692601ccae1"></a><!-- doxytag: member="stk::BlitSquare::lastOut" ref="a77972e4e1c53600bf80cf692601ccae1" args="(void) const " -->
StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1BlitSquare.html#a77972e4e1c53600bf80cf692601ccae1">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="a04366d55cecb4c8a726ea0519683d817"></a><!-- doxytag: member="stk::BlitSquare::tick" ref="a04366d55cecb4c8a726ea0519683d817" args="(void)" -->
StkFloat&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1BlitSquare.html#a04366d55cecb4c8a726ea0519683d817">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_1BlitSquare.html#a7df894d40b3d6effbb2a09819356258d">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="#a7df894d40b3d6effbb2a09819356258d"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>STK band-limited square wave class. </p>
<p>This class generates a band-limited square wave signal. It is derived in part from the approach reported by Stilson and Smith in "Alias-Free Digital Synthesis of Classic Analog Waveforms", 1996. The algorithm implemented in this class uses a SincM function with an even M value to achieve a bipolar bandlimited impulse train. This signal is then integrated to achieve a square waveform. The integration process has an associated DC offset so a DC blocking filter is applied at the output.</p>
<p>The user can specify both the fundamental frequency of the waveform and the number of harmonics contained in the resulting signal.</p>
<p>If nHarmonics is 0, then the signal will contain all harmonics up to half the sample rate. Note, however, that this setting may produce aliasing in the signal when the frequency is changing (no automatic modification of the number of harmonics is performed by the <a class="el" href="classstk_1_1BlitSquare.html#a8d0d8e0a12987ebccc56c09c7e7dbd6a" title="Set the impulse train rate in terms of a frequency in Hz.">setFrequency()</a> function). Also note that the harmonics of a square wave fall at odd integer multiples of the fundamental, so aliasing will happen with a lower fundamental than with the other <a class="el" href="classstk_1_1Blit.html" title="STK band-limited impulse train class.">Blit</a> waveforms. This class is not guaranteed to be well behaved in the presence of significant aliasing.</p>
<p>Based on initial code of Robin Davies, 2005. Modified algorithm code by Gary Scavone, 2005 - 2006. </p>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aeface58980a3ec865131f3cad59bbbef"></a><!-- doxytag: member="stk::BlitSquare::setPhase" ref="aeface58980a3ec865131f3cad59bbbef" args="(StkFloat phase)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::BlitSquare::setPhase </td>
<td>(</td>
<td class="paramtype">StkFloat&nbsp;</td>
<td class="paramname"> <em>phase</em></td>
<td>&nbsp;)&nbsp;</td>
<td><code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the phase of the signal. </p>
<p>Set the phase of the signal, in the range 0 to 1. </p>
</div>
</div>
<a class="anchor" id="abbda8cb84bcd36fc6d96130e9832a6af"></a><!-- doxytag: member="stk::BlitSquare::getPhase" ref="abbda8cb84bcd36fc6d96130e9832a6af" args="() const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">StkFloat stk::BlitSquare::getPhase </td>
<td>(</td>
<td class="paramname"></td>
<td>&nbsp;)&nbsp;</td>
<td> const<code> [inline]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Get the current phase of the signal. </p>
<p>Get the phase of the signal, in the range [0 to 1.0). </p>
</div>
</div>
<a class="anchor" id="a94521b4224d0873f5e783c721c123b21"></a><!-- doxytag: member="stk::BlitSquare::setHarmonics" ref="a94521b4224d0873f5e783c721c123b21" args="(unsigned int nHarmonics=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stk::BlitSquare::setHarmonics </td>
<td>(</td>
<td class="paramtype">unsigned int&nbsp;</td>
<td class="paramname"> <em>nHarmonics</em> = <code>0</code></td>
<td>&nbsp;)&nbsp;</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Set the number of harmonics generated in the signal. </p>
<p>This function sets the number of harmonics contained in the resulting signal. It is equivalent to (2 * M) + 1 in the BLIT algorithm. The default value of 0 sets the algorithm for maximum harmonic content (harmonics up to half the sample rate). This parameter is not checked against the current sample rate and fundamental frequency. Thus, aliasing can result if one or more harmonics for a given fundamental frequency exceeds fs / 2. This behavior was chosen over the potentially more problematic solution of automatically modifying the M parameter, which can produce audible clicks in the signal. </p>
</div>
</div>
<a class="anchor" id="a7df894d40b3d6effbb2a09819356258d"></a><!-- doxytag: member="stk::BlitSquare::tick" ref="a7df894d40b3d6effbb2a09819356258d" 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::BlitSquare::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>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="BlitSquare_8h_source.html">BlitSquare.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-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>