<!-- Converted to DocBook/SGML by Kevin Conder -->
<refentry id="GEN03">
  <refmeta>
    <refentrytitle>GEN03</refentrytitle>
  </refmeta>
 
  <refnamediv>
    <refname>GEN03</refname>
    <refpurpose>
      Generates a stored function table by evaluating a polynomial.
      <indexterm id="IndexGEN03"><primary>GEN03</primary></indexterm>
    </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      This subroutine generates a stored function table by evaluating a polynomial in x over a fixed interval and with specified coefficients.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis><command>f</command>  #  time  size  3  xval1  xval2  c0  c1  c2  ...  cn</synopsis>
  </refsect1>
 
  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>size </emphasis> -- number of points in the table. Must be a power of 2 or a power-of-2 plus 1.
    </para>

    <para>
      <emphasis>xval1, xval2 </emphasis> -- left and right values of the x interval over which the polynomial is defined (<emphasis>xval1</emphasis> &lt; <emphasis>xval2</emphasis>). These will produce the 1st stored value and the (power-of-2 plus l)th stored value respectively in the generated function table.
    </para>

    <para>
      <emphasis>c0, c1, c2, ... cn</emphasis> -- coefficients of the nth-order polynomial
    </para>

    <para>
      <emphasis>c0 + c1x + c2x2 + . . . + cnxn</emphasis>
    </para>

    <para>
      Coefficients may be positive or negative real numbers; a zero denotes a missing term in the polynomial. The coefficient list begins in p7, providing a current upper limit of 144 terms.
    </para>

    <note>
      <title>Note</title>
      <para>
        <itemizedlist>
          <listitem>
            <para>
              The defined segment [fn(<emphasis>xval1</emphasis>), fn(<emphasis>xval2</emphasis>)] is evenly distributed. Thus a 512-point table over the interval [-1,1] will have its origin at location 257 (at the start of the 2nd half). Provided the extended guard point is requested, both fn(-1) and fn(1) will exist in the table.
            </para>
          </listitem>

          <listitem>
            <para>
              <emphasis>GEN03</emphasis> is useful in conjunction with <link linkend="table"><citetitle>table</citetitle></link> or <link linkend="tablei"><citetitle>tablei</citetitle></link> for audio waveshaping (sound modification by non-linear distortion). Coefficients to produce a particular formant from a sinusoidal lookup index of known amplitude can be determined at preprocessing time using algorithms such as Chebyshev formulae. See also <link linkend="GEN13"><citetitle>GEN13</citetitle></link>.
            </para>
          </listitem>
        </itemizedlist>
      </para>
    </note>
  </refsect1>

  <refsect1>
    <title>Examples</title>
    <para>
      Here is a simple example of the GEN03 routine. It uses the files <ulink url="examples/gen03.orc"><citetitle>gen03.orc</citetitle></ulink> and <ulink url="examples/gen03.sco"><citetitle>gen03.sco</citetitle></ulink>.  It fills a table with a 4th order polynomial function over the x-interval -1 to 1. The origin will be at the offset position 512. The function is post-normalized. Here is its diagram:

      <mediaobject>
        <imageobject>
          <imagedata fileref="images/gen03.png" format="PNG">
        </imageobject>

        <textobject>
          <phrase>Diagram of the waveform generated by GEN03.</phrase>
        </textobject>

        <caption>
          <para>Diagram of the waveform generated by GEN03.</para>
        </caption>
      </mediaobject>

      <example>
        <title>A simple example of the GEN03 routine.</title>

        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/gen03.orc" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>

        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/gen03.sco" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>
      </example>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="GEN13"><citetitle>GEN13</citetitle></link>,
      <link linkend="GEN14"><citetitle>GEN14</citetitle></link>, and
      <link linkend="GEN15"><citetitle>GEN15</citetitle></link>.
    </para>
  </refsect1>
</refentry>
