| 1 | |
| 2 | <refentry id="GEN33"> |
| 3 | <indexterm id="IndexGEN33"><primary>GEN33</primary></indexterm> |
| 4 | <refmeta> |
| 5 | <refentrytitle>GEN33</refentrytitle> |
| 6 | </refmeta> |
| 7 | |
| 8 | <refnamediv> |
| 9 | <refname>GEN33</refname> |
| 10 | <refpurpose> |
| 11 | Generate composite waveforms by mixing simple sinusoids. |
| 12 | </refpurpose> |
| 13 | </refnamediv> |
| 14 | |
| 15 | <refsect1> |
| 16 | <title>Description</title> |
| 17 | <para> |
| 18 | These routines generate composite waveforms by mixing simple sinusoids, similarly to <link linkend="GEN09"><citetitle>GEN09</citetitle></link>, but the parameters of the partials are specified in an already existing table, which makes it possible to calculate any number of partials in the orchestra. |
| 19 | </para> |
| 20 | |
| 21 | <para> |
| 22 | The difference between <emphasis>GEN33</emphasis> and <link linkend="GEN34"><citetitle>GEN34</citetitle></link> is that <emphasis>GEN33</emphasis> uses inverse FFT to generate output, while <emphasis>GEN34</emphasis> is based on the algorithm used in oscils opcode. <emphasis>GEN33</emphasis> allows integer partials only, and does not support power of two plus 1 table size, but may be significantly faster with a large number of partials. On the other hand, with <emphasis>GEN34</emphasis>, it is possible to use non-integer partial numbers and extended guard point, and this routine may be faster if there is only a small number of partials (note that <emphasis>GEN34</emphasis> is also several times faster than <link linkend="GEN09"><citetitle>GEN09</citetitle></link>, although the latter may be more accurate). |
| 23 | </para> |
| 24 | </refsect1> |
| 25 | |
| 26 | <refsect1> |
| 27 | <title>Syntax</title> |
| 28 | <synopsis><command>f</command> # time size 33 src nh scl [fmode]</synopsis> |
| 29 | </refsect1> |
| 30 | |
| 31 | <refsect1> |
| 32 | <title>Initialization</title> |
| 33 | <para> |
| 34 | <emphasis>size</emphasis> -- number of points in the table. Must be power of two and at least 4. |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>src</emphasis> -- source table number. This table contains the parameters of each partial in the following format: |
| 39 | <literallayout> |
| 40 | stra, pna, phsa, strb, pnb, phsb, ... |
| 41 | </literallayout> |
| 42 | |
| 43 | the parameters are: |
| 44 | |
| 45 | <itemizedlist> |
| 46 | <listitem><para>stra, strb, etc.: relative strength of partials. The actual amplitude depends on the value of scl, or normalization (if enabled).</para></listitem> |
| 47 | <listitem><para>pna, pnb, etc.: partial number, or frequency, depending on fmode (see below); zero and negative values are allowed, however, if the absolute value of the partial number exceeds (size / 2), the partial will not be rendered. With <emphasis>GEN33</emphasis>, partial number is rounded to the nearest integer.</para></listitem> |
| 48 | <listitem><para>phsa, phsb, etc.: initial phase, in the range 0 to 1.</para></listitem> |
| 49 | </itemizedlist> |
| 50 | |
| 51 | Table length (not including the guard point) should be at least 3 * nh. If the table is too short, the number of partials (nh) is reduced to (table length) / 3, rounded towards zero. |
| 52 | </para> |
| 53 | |
| 54 | <para> |
| 55 | <emphasis>nh</emphasis> -- number of partials. Zero or negative values are allowed, and result in an empty table (silence). The actual number may be reduced if the source table (src) is too short, or some partials have too high frequency. |
| 56 | </para> |
| 57 | |
| 58 | <para> |
| 59 | <emphasis>scl</emphasis> -- amplitude scale. |
| 60 | </para> |
| 61 | |
| 62 | <para> |
| 63 | <emphasis>fmode</emphasis> (optional, default = 0) -- a non-zero value can be used to set frequency in Hz instead of partial numbers in the source table. The sample rate is assumed to be fmode if it is positive, or -(sr * fmode) if any negative value is specified. |
| 64 | </para> |
| 65 | </refsect1> |
| 66 | |
| 67 | <refsect1> |
| 68 | <title>Examples</title> |
| 69 | <para> |
| 70 | Here is an example of the GEN33 routine. It uses the file <ulink url="examples/gen33.csd"><citetitle>gen33.csd</citetitle></ulink>. |
| 71 | <example> |
| 72 | <title>Example of the gen33 generator.</title> |
| 73 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 74 | <xi:include href="examples-xml/gen33.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 75 | </example> |
| 76 | |
| 77 | <textobject> |
| 78 | <phrase>This is the diagram of the waveform generated by GEN33, as used in the example:</phrase> |
| 79 | </textobject> |
| 80 | <para> |
| 81 | </para> |
| 82 | <mediaobject> |
| 83 | <imageobject> |
| 84 | <imagedata fileref="images/gen33.png" format="PNG"/> |
| 85 | <textobject> |
| 86 | <phrase>f 2 0 262144 -33 1 inumh 1 -1</phrase> |
| 87 | </textobject> |
| 88 | </imageobject> |
| 89 | |
| 90 | <caption> |
| 91 | <para>f 2 0 262144 -33 1 inumh 1 -1</para> |
| 92 | </caption> |
| 93 | </mediaobject> |
| 94 | </para> |
| 95 | </refsect1> |
| 96 | |
| 97 | <refsect1> |
| 98 | <title>See Also</title> |
| 99 | <para> |
| 100 | <link linkend="GEN09"><citetitle>GEN09</citetitle></link>, |
| 101 | <link linkend="GEN34"><citetitle>GEN34</citetitle></link> |
| 102 | </para> |
| 103 | </refsect1> |
| 104 | |
| 105 | <refsect1> |
| 106 | <title>Credits</title> |
| 107 | <para> |
| 108 | <simplelist> |
| 109 | <member>Programmer: &nameistvan;</member> |
| 110 | <member>March 2002</member> |
| 111 | </simplelist> |
| 112 | </para> |
| 113 | |
| 114 | <para>New in version 4.19</para> |
| 115 | </refsect1> |
| 116 | </refentry> |