| 1 | |
| 2 | <refentry id="vco2"> |
| 3 | <indexterm id="IndexVco2"><primary>vco2</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Dynamic Spectrum Oscillators</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>vco2</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>vco2</refname> |
| 13 | <refpurpose> |
| 14 | Implementation of a band-limited oscillator using pre-calculated tables. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | <emphasis>vco2</emphasis> is similar to <link linkend="vco"><citetitle>vco</citetitle></link>. But the implementation uses pre-calculated tables of band-limited waveforms (see also <link linkend="GEN30"><citetitle>GEN30</citetitle></link>) rather than integrating impulses. This opcode can be faster than <emphasis>vco</emphasis> (especially if a low control-rate is used) and also allows better sound quality. Additionally, there are more waveforms and oscillator phase can be modulated at k-rate. The disadvantage is increased memory usage. For more details about vco2 tables, see also <link linkend="vco2init"><citetitle>vco2init</citetitle></link> and <link linkend="vco2ft"><citetitle>vco2ft</citetitle></link>. |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis>ares <command>vco2</command> kamp, kcps [, imode] [, kpw] [, kphs] [, inyx]</synopsis> |
| 28 | </refsect1> |
| 29 | |
| 30 | <refsect1> |
| 31 | <title>Initialization</title> |
| 32 | <para> |
| 33 | <emphasis>imode</emphasis> (optional, default=0) -- a sum of values representing the waveform and its control values. |
| 34 | </para> |
| 35 | |
| 36 | <para> |
| 37 | One may use any of the following values for <emphasis>imode</emphasis>: |
| 38 | <itemizedlist> |
| 39 | <listitem><para>16: enable k-rate phase control (if set, <emphasis>kphs</emphasis> is a required k-rate parameter that allows phase modulation)</para></listitem> |
| 40 | <listitem><para>1: skip initialization</para></listitem> |
| 41 | </itemizedlist> |
| 42 | </para> |
| 43 | |
| 44 | <para> |
| 45 | One may use exactly one of these <emphasis>imode</emphasis> values to select the waveform to be generated: |
| 46 | <itemizedlist> |
| 47 | <listitem><para>14: user defined waveform -1 (requires using the <link linkend="vco2init"><citetitle>vco2init</citetitle></link> opcode)</para></listitem> |
| 48 | <listitem><para>12: triangle (no ramp, faster)</para></listitem> |
| 49 | <listitem><para>10: square wave (no PWM, faster)</para></listitem> |
| 50 | <listitem><para>8: 4 * x * (1 - x) (i.e. integrated sawtooth)</para></listitem> |
| 51 | <listitem><para>6: pulse (not normalized)</para></listitem> |
| 52 | <listitem><para>4: sawtooth / triangle / ramp</para></listitem> |
| 53 | <listitem><para>2: square / PWM</para></listitem> |
| 54 | <listitem><para>0: sawtooth</para></listitem> |
| 55 | </itemizedlist> |
| 56 | </para> |
| 57 | |
| 58 | <para> |
| 59 | The default value for <emphasis>imode</emphasis> is zero, which means a sawtooth wave with no k-rate phase control. |
| 60 | </para> |
| 61 | |
| 62 | <para> |
| 63 | <emphasis>inyx</emphasis> (optional, default=0.5) -- bandwidth of the generated waveform, as percentage (0 to 1) of the sample rate. The expected range is 0 to 0.5 (i.e. up to <link linkend="sr"><citetitle>sr</citetitle></link>/2), other values are limited to the allowed range. |
| 64 | </para> |
| 65 | |
| 66 | <para> |
| 67 | Setting <emphasis>inyx</emphasis> to 0.25 (<emphasis>sr</emphasis>/4), or 0.3333 (<emphasis>sr</emphasis>/3) can produce a <quote>fatter</quote> sound in some cases, although it is more likely to reduce quality. |
| 68 | </para> |
| 69 | </refsect1> |
| 70 | |
| 71 | <refsect1> |
| 72 | <title>Performance</title> |
| 73 | <para> |
| 74 | <emphasis>ares </emphasis> -- the output audio signal. |
| 75 | </para> |
| 76 | |
| 77 | <para> |
| 78 | <emphasis>kamp</emphasis> -- amplitude scale. In the case of a <emphasis>imode</emphasis> waveform value of 6 (a pulse waveform), the actual output level can be a lot higher than this value. |
| 79 | </para> |
| 80 | |
| 81 | <para> |
| 82 | <emphasis>kcps</emphasis> -- frequency in Hz (should be in the range -<emphasis>sr</emphasis>/2 to <emphasis>sr</emphasis>/2). |
| 83 | </para> |
| 84 | |
| 85 | <para> |
| 86 | <emphasis>kpw</emphasis> (optional) -- the pulse width of the square wave (<emphasis>imode</emphasis> waveform=2) or the ramp characteristics of the triangle wave (<emphasis>imode</emphasis> waveform=4). It is required only by these waveforms and ignored in all other cases. The expected range is 0 to 1, any other value is wrapped to the allowed range. |
| 87 | </para> |
| 88 | |
| 89 | <warning> |
| 90 | <title>Warning</title> |
| 91 | <para> |
| 92 | <emphasis>kpw</emphasis> must not be an exact integer value (e.g. 0 or 1) if a sawtooth / triangle / ramp (<emphasis>imode</emphasis> waveform=4) is generated. In this case, the recommended range is about 0.01 to 0.99. There is no such limitation for a square/PWM waveform. |
| 93 | </para> |
| 94 | </warning> |
| 95 | |
| 96 | <para> |
| 97 | <emphasis>kphs</emphasis> (optional) -- oscillator phase (depending on <emphasis>imode</emphasis>, this can be either an optional i-rate parameter that defaults to zero or required k-rate). Similarly to <emphasis>kpw</emphasis>, the expected range is 0 to 1. |
| 98 | </para> |
| 99 | |
| 100 | <note> |
| 101 | <title>Note</title> |
| 102 | <para> |
| 103 | When a low control-rate is used, pulse width (<emphasis>kpw</emphasis>) and phase (<emphasis>kphs</emphasis>) modulation is internally converted to frequency modulation. This allows for faster processing and reduced artifacts. But in the case of very long notes and continuous fast changes in <emphasis>kpw</emphasis> or <emphasis>kphs</emphasis>, the phase may drift away from the requested value. In most cases, the phase error is at most 0.037 per hour (assuming a sample rate of 44100 Hz). |
| 104 | </para> |
| 105 | |
| 106 | <para> |
| 107 | This is a problem mainly in the case of pulse width (<emphasis>kpw</emphasis>), where it may result in various artifacts. While future releases of <emphasis>vco2</emphasis> may fix such errors, the following work-arounds may also be of some help: |
| 108 | |
| 109 | <itemizedlist> |
| 110 | <listitem><para>Use <emphasis>kpw</emphasis> values only in the range 0.05 to 0.95. (There are more artifacts around integer values)</para></listitem> |
| 111 | <listitem><para>Try to avoid modulating <emphasis>kpw</emphasis> by asymmetrical waveforms like a sawtooth wave. Relatively slow (<= 20 Hz) symmetrical modulation (e.g. sine or triangle), random splines (also slow), or a fixed pulse width is a lot less likely to cause synchronization problems. |
| 112 | </para></listitem> |
| 113 | <listitem><para>In some cases, adding random jitter (for example: random splines with an amplitude of about 0.01) to <emphasis>kpw</emphasis> may also fix the problem.</para></listitem> |
| 114 | </itemizedlist> |
| 115 | </para> |
| 116 | </note> |
| 117 | </refsect1> |
| 118 | |
| 119 | <refsect1> |
| 120 | <title>Examples</title> |
| 121 | <para> |
| 122 | Here is an example of the vco2 opcode. It uses the file <ulink url="examples/vco2.csd"><citetitle>vco2.csd</citetitle></ulink>. |
| 123 | <example> |
| 124 | <title>Example of the vco2 opcode.</title> |
| 125 | |
| 126 | <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> |
| 127 | <xi:include href="examples-xml/vco2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 128 | </example> |
| 129 | </para> |
| 130 | </refsect1> |
| 131 | |
| 132 | <refsect1> |
| 133 | <title>See Also</title> |
| 134 | <para> |
| 135 | <link linkend="SiggenDynamic"><citetitle>Dynamic Spectrum Oscillators</citetitle></link> |
| 136 | </para> |
| 137 | </refsect1> |
| 138 | |
| 139 | <refsect1> |
| 140 | <title>Credits</title> |
| 141 | <para>Author: &nameistvan;</para> |
| 142 | <para>New in version 4.22</para> |
| 143 | </refsect1> |
| 144 | </refentry> |