<?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>ftgen</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="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="ftfree.html" title="ftfree" /> <link rel="next" href="ftgenonce.html" title="ftgenonce" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">ftgen</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="ftfree.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="ftgenonce.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="ftgen"> <a id="ftgen"></a> <div class="titlepage"></div> <a id="IndexFtgen" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">ftgen</span> </h2> <p>ftgen — Generate a score function table from within the orchestra. </p> </div> <div class="refsect1" title="Description"> <a id="idp24638048"></a> <h2>Description</h2> <p>Generate a score function table from within the orchestra.</p> </div> <div class="refsect1" title="Syntax"> <a id="idp24638720"></a> <h2>Syntax</h2> <pre class="synopsis">gir <span class="command"><strong>ftgen</strong></span> ifn, itime, isize, igen, iarga [, iargb ] [...]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp24666192"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>gir</em></span> -- either a requested or automatically assigned table number above 100. </p> <p> <span class="emphasis"><em>ifn</em></span> -- requested table number If <span class="emphasis"><em>ifn</em></span> is zero, the number is assigned automatically and the value placed in <span class="emphasis"><em>gir</em></span>. Any other value is used as the table number </p> <p> <span class="emphasis"><em>itime</em></span> -- is ignored, but otherwise corresponds to p2 in the score <span class="emphasis"><em>f statement</em></span>. </p> <p> <span class="emphasis"><em>isize</em></span> -- table size. Corresponds to p3 of the score <span class="emphasis"><em>f statement</em></span>. </p> <p> <span class="emphasis"><em>igen</em></span> -- function table <span class="emphasis"><em>GEN</em></span> routine. Corresponds to p4 of the score <span class="emphasis"><em>f statement</em></span>. </p> <p> <span class="emphasis"><em>iarga, iargb, ...</em></span> -- function table arguments. Correspond to p5 through p<span class="emphasis"><em>n</em></span> of the score <span class="emphasis"><em>f statement</em></span>. </p> </div> <div class="refsect1" title="Performance"> <a id="idp24671456"></a> <h2>Performance</h2> <p> This is equivalent to table generation in the score with the <span class="emphasis"><em>f statement</em></span>. </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="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>Csound was originally designed to support tables with power of two sizes only. Though this has changed in recent versions (you can use any size by using a negative number), many opcodes will not accept them.</p> </td> </tr> </table> </div> <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Warning: Warning"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Warning]" src="images/warning.png" /> </td> <th align="left">Warning</th> </tr> <tr> <td align="left" valign="top"> <p> Although Csound will not protest if ftgen is used inside instr-endin statements, this is not the intended or supported use, and must be handled with care as it has global effects. (In particular, a different size usually leads to relocation of the table, which may cause a crash or otherwise erratic behaviour. </p> </td> </tr> </table> </div> </div> <div class="refsect1" title="Examples"> <a id="idp24674248"></a> <h2>Examples</h2> <p> Here is an example of the ftgen opcode. It uses the file <a class="ulink" href="examples/ftgen.csd" target="_top"><em class="citetitle">ftgen.csd</em></a>. </p> <div class="example"> <a id="idp24675224"></a> <p class="title"> <strong>Example 305. Example of the ftgen 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 ftgen.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 gisine <span class="ohdr">ftgen</span> 1, 0, 16384, 10, 1 <span class="comment">;sine wave</span> gisquare <span class="ohdr">ftgen</span> 2, 0, 16384, 10, 1, 0 , .33, 0, .2 , 0, .14, 0 , .11, 0, .09 <span class="comment">;odd harmonics</span> gisaw <span class="ohdr">ftgen</span> 3, 0, 16384, 10, 0, .2, 0, .4, 0, .6, 0, .8, 0, 1, 0, .8, 0, .6, 0, .4, 0,.2 <span class="comment">;even harmonics</span> <span class="oblock">instr</span> 1 ifn <span class="op">=</span> p4 asig <span class="opc">poscil</span> .6, 200, ifn <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">i</span> 1 0 2 1 <span class="comment">;sine wave</span> <span class="stamnt">i</span> 1 3 2 2 <span class="comment">;odd harmonics</span> <span class="stamnt">i</span> 1 6 2 3 <span class="comment">;even harmonics</span> <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> <p> Here is another example of the ftgen opcode. It uses the file <a class="ulink" href="examples/ftgen-2.csd" target="_top"><em class="citetitle">ftgen-2.csd</em></a>. </p> <div class="example"> <a id="idp24678072"></a> <p class="title"> <strong>Example 306. Example of the ftgen opcode.</strong> </p> <div class="example-contents"> <p> This example queries a file for it length to create an f-table of the appropriate size. </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> <span class="comment">; Audio out Audio in</span> -odac -iadc <span class="comment">;;;RT audio I/O</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o ftgen-2.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> 48000 <span class="ohdr">ksmps</span> <span class="op">=</span> 16 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="comment">;Example by Jonathan Murphy 2007</span> <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="oblock">instr</span> 1 Sfile <span class="op">=</span> "beats.wav" ilen <span class="opc">filelen</span> Sfile <span class="comment">; Find length</span> isr <span class="opc">filesr</span> Sfile <span class="comment">; Find sample rate</span> isamps <span class="op">=</span> ilen <span class="op">*</span> isr <span class="comment">; Total number of samples</span> isize <span class="opc">init</span> 1 <span class="olabel">loop</span><span class="op">:</span> isize <span class="op">=</span> isize <span class="op">*</span> 2 <span class="comment">; Loop until isize is greater than number of samples</span> <span class="octrl">if</span> (isize <span class="op"><</span> isamps) <span class="octrl">igoto</span> <span class="olabel">loop</span> itab <span class="ohdr">ftgen</span> 0, 0, isize, 1, Sfile, 0, 0, 0 <span class="opc">print</span> isize <span class="opc">print</span> isamps <span class="opc">turnoff</span> <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">i</span>1 0 10 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="See also"> <a id="idp24679480"></a> <h2>See also</h2> <p> <a class="link" href="ScoreGenRef.html" title="GEN Routines"><em class="citetitle">GEN routine overview</em></a>, <a class="link" href="ftgentmp.html" title="ftgentmp"><em class="citetitle">ftgentmp</em></a> </p> </div> <div class="refsect1" title="Credits"> <a id="idp24680976"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Barry L. Vercoe</td> </tr> <tr> <td>M.I.T., Cambridge, Mass</td> </tr> <tr> <td>1997</td> </tr> </table> <p> </p> <p>Added warning April 2002 by Rasmus Ekman</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="ftfree.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="ftgenonce.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">ftfree </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> ftgenonce</td> </tr> </table> </div> </body> </html>