<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>GEN14</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="ScoregensTop.html" title="Score Statements and GEN Routines" /> <link rel="prev" href="GEN13.html" title="GEN13" /> <link rel="next" href="GEN15.html" title="GEN15" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">GEN14</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="GEN13.html">Prev</a> </td> <th width="60%" align="center">Score Statements and GEN Routines</th> <td width="20%" align="right"> <a accesskey="n" href="GEN15.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="GEN14"> <a id="GEN14"></a> <div class="titlepage"></div> <a id="IndexGEN14" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">GEN14</span> </h2> <p>GEN14 — Stores a polynomial whose coefficients derive from Chebyshevs of the second kind. </p> </div> <div class="refsect1" title="Description"> <a id="idp77632000"></a> <h2>Description</h2> <p> Uses Chebyshev coefficients to generate stored polynomial functions which, under waveshaping, can be used to split a sinusoid into harmonic partials having a pre-definable spectrum. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp77665072"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size 14 xint xamp h0 h1 h2 ...</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp77666120"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>size</em></span> -- number of points in the table. Must be a power of 2 or a power-of-2 plus 1 (see <a class="link" href="f.html" title="f Statement (or Function Table Statement)"><em class="citetitle">f statement</em></a>). The normal value is power-of-2 plus 1. </p> <p> <span class="emphasis"><em>xint</em></span> -- provides the left and right values [<span class="emphasis"><em>-xint, +xint</em></span>] of the x interval over which the polynomial is to be drawn. These subroutines both call <a class="link" href="GEN03.html" title="GEN03"><em class="citetitle">GEN03</em></a> to draw their functions; the p5 value here is therefore expanded to a negative-positive p5, p6 pair before <span class="emphasis"><em>GEN03</em></span> is actually called. The normal value is 1. </p> <p> <span class="emphasis"><em>xamp </em></span> -- amplitude scaling factor of the sinusoid input that is expected to produce the following spectrum. </p> <p> <span class="emphasis"><em>h0, h1, h2,</em></span> etc. -- relative strength of partials 0 (DC), 1 (fundamental), 2 ... that will result when a sinusoid of amplitude </p> <div class="literallayout"> <p><br /> xamp * int(size/2)/xint<br /> </p> </div> <p> is waveshaped using this function table. These values thus describe a frequency spectrum associated with a particular factor <span class="emphasis"><em>xamp</em></span> of the input signal. </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note: Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p> </p> <div class="itemizedlist"> <ul class="itemizedlist" type="disc"> <li class="listitem"> <p> <a class="link" href="GEN13.html" title="GEN13"><em class="citetitle">GEN13</em></a> is the function generator normally employed in standard waveshaping. It stores a polynomial whose coefficients derive from the Chebyshev polynomials of the first kind, so that a driving sinusoid of strength <span class="emphasis"><em>xamp</em></span> will exhibit the specified spectrum at output. Note that the evolution of this spectrum is generally not linear with varying <span class="emphasis"><em>xamp</em></span>. However, it is bandlimited (the only partials to appear will be those specified at generation time); and the partials will tend to occur and to develop in ascending order (the lower partials dominating at low <span class="emphasis"><em>xamp</em></span>, and the spectral richness increasing for higher values of <span class="emphasis"><em>xamp</em></span>). A negative <span class="emphasis"><em>hn</em></span> value implies a 180 degree phase shift of that partial; the requested full-amplitude spectrum will not be affected by this shift, although the evolution of several of its component partials may be. The pattern +,+,-,-,+,+,... for <span class="emphasis"><em>h0,h1,h2..</em></span>. will minimize the normalization problem for low <span class="emphasis"><em>xamp</em></span> values (see above), but does not necessarily provide the smoothest pattern of evolution. </p> </li> <li class="listitem"> <p> <span class="emphasis"><em>GEN14</em></span> stores a polynomial whose coefficients derive from Chebyshevs of the second kind. </p> </li> </ul> </div> <p> </p> </td> </tr> </table> </div> </div> <div class="refsect1" title="Examples"> <a id="idp77676616"></a> <h2>Examples</h2> <p> Here is an example of the GEN14 opcode. It uses the file <a class="ulink" href="examples/gen14.csd" target="_top"><em class="citetitle">gen14.csd</em></a>. </p> <div class="example"> <a id="idp77677600"></a> <p class="title"> <strong>Example 1050. Example of the GEN14 opcode.</strong> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select audio/midi flags here according to platform</span> -odac <span class="comment">;;;realtime audio out</span> <span class="comment">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o gen14.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">ksmps</span> <span class="op">=</span> 32 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="comment">;after the example from The Csound Book, page 83</span> <span class="oblock">instr</span> 1 <span class="comment">;compare results from GEN13 & GEN14</span> iwshpfn <span class="op">=</span> p6 inrmfn <span class="op">=</span> p7 aswp <span class="opc">linseg</span> 0.01, p3<span class="op">*</span>.5, .49, p3<span class="op">*</span>.5, 0.01 <span class="comment">;index sweep function</span> aindex <span class="opc">poscil</span> aswp, p5, 2 <span class="comment">;sound to waveshape</span> atable <span class="opc">tablei</span> aindex, iwshpfn, 1, .5 <span class="comment">;waveshape index</span> anrm <span class="opc">tablei</span> aswp<span class="op">*</span>2, inrmfn, 1 <span class="comment">;normalization </span> aenv <span class="opc">linen</span> p4, .01, p3, .02 <span class="comment">;amplitude envelope</span> asig <span class="op">=</span> (atable<span class="op">*</span>anrm)<span class="op">*</span>aenv <span class="comment">;normalize and impose envelope</span> asig <span class="opc">dcblock2</span> asig <span class="comment">;get rid of DC</span> <span class="opc">outs</span> asig, asig <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span> 2 0 8192 10 1 <span class="comment">;sine wave</span> <span class="stamnt">f</span> 28 0 4097 13 1 1 1 0 .8 0 .5 0 .2 <span class="comment">;waveshaping function: GEN13 - odd harmonics</span> <span class="stamnt">f</span> 280 0 2049 4 28 1 <span class="comment">;normalization function for f28</span> <span class="stamnt">f</span> 29 0 4097 14 1 1 1 0 .8 0 .5 0 .2 <span class="comment">;waveshaping function: GEN14 - same harmonics</span> <span class="stamnt">f</span> 290 0 2049 4 29 1 <span class="comment">;normalization function for f29</span> <span class="stamnt">f</span> 30 0 4097 13 1 1 0 1 0 .6 0 .4 0 .1 <span class="comment">;waveshaping function: GEN13 - even harmonics</span> <span class="stamnt">f</span> 301 0 2049 4 30 1 <span class="comment">;normalization function for f30</span> <span class="stamnt">f</span> 31 0 4097 14 1 1 0 1 0 .6 0 .4 0 .1 <span class="comment">;waveshaping function: GEN13 - even harmonics</span> <span class="stamnt">f</span> 310 0 2049 4 31 1 <span class="comment">;normalization function for 31</span> <span class="stamnt">s</span> <span class="stamnt">i</span>1 0 3 .7 440 28 280 <span class="stamnt">i</span>1 4 . .7 . 29 290 <span class="stamnt">i</span>1 8 . .7 . 30 301 <span class="stamnt">i</span>1 12 3 .7 . 31 310 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> <span>These are the diagrams of the waveforms of the GEN14 routines, as used in the example:</span> </p> <div class="mediaobject"> <img src="images/gen14_1.png" alt="f28 0 4097 13 1 1 1 0 .8 0 .5 0 .2 - waveshaping function: GEN13, odd harmonics" /> <div class="caption"> <p>f28 0 4097 13 1 1 1 0 .8 0 .5 0 .2 - waveshaping function: GEN13, odd harmonics</p> </div> </div> <p> </p> <div class="mediaobject"> <img src="images/gen14_2.png" alt="f29 0 4097 14 1 1 1 0 .8 0 .5 0 .2 - waveshaping function: GEN14, the same odd harmonics" /> <div class="caption"> <p>f29 0 4097 14 1 1 1 0 .8 0 .5 0 .2 - waveshaping function: GEN14, the same odd harmonics</p> </div> </div> <p> </p> <div class="mediaobject"> <img src="images/gen14_3.png" alt="f30 0 4097 13 1 1 0 1 0 .6 0 .4 0 .1 - waveshaping function: GEN13, even harmonics" /> <div class="caption"> <p>f30 0 4097 13 1 1 0 1 0 .6 0 .4 0 .1 - waveshaping function: GEN13, even harmonics</p> </div> </div> <p> </p> <div class="mediaobject"> <img src="images/gen14_4.png" alt="f31 0 4097 14 1 1 0 1 0 .6 0 .4 0 .1 - waveshaping function: GEN14, the same even harmonics" /> <div class="caption"> <p>f31 0 4097 14 1 1 0 1 0 .6 0 .4 0 .1 - waveshaping function: GEN14, the same even harmonics</p> </div> </div> <p> </p> </div> <div class="refsect1" title="See Also"> <a id="idp77687496"></a> <h2>See Also</h2> <p> <a class="link" href="GEN03.html" title="GEN03"><em class="citetitle">GEN03</em></a>, <a class="link" href="GEN13.html" title="GEN13"><em class="citetitle">GEN13</em></a>, and <a class="link" href="GEN15.html" title="GEN15"><em class="citetitle">GEN15</em></a>. </p> <p> Information about the Chebyshev polynomials on Wikipedia: <a class="ulink" href="http://en.wikipedia.org/wiki/Chebyshev_polynomials" target="_top"><em class="citetitle">http://en.wikipedia.org/wiki/Chebyshev_polynomials</em></a></p> <p> </p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="GEN13.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="ScoregensTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="GEN15.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">GEN13 </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> GEN15</td> </tr> </table> </div> </body> </html>