| 1 | |
| 2 | <refentry id="oscbnk"> |
| 3 | <indexterm id="IndexOscbnk"><primary>oscbnk</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Basic Oscillators</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>oscbnk</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>oscbnk</refname> |
| 13 | <refpurpose> |
| 14 | Mixes the output of any number of oscillators. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | This unit generator mixes the output of any number of oscillators. The frequency, phase, and amplitude of each oscillator can be modulated by two LFOs (all oscillators have a separate set of LFOs, with different phase and frequency); additionally, the output of each oscillator can be filtered through an optional parametric equalizer (also controlled by the LFOs). This opcode is most useful for rendering ensemble (strings, choir, etc.) instruments. |
| 22 | </para> |
| 23 | |
| 24 | <para> |
| 25 | Although the LFOs run at k-rate, amplitude, phase and filter modulation are interpolated internally, so it is possible (and recommended in most cases) to use this unit at low (˜1000 Hz) control rates without audible quality degradation. |
| 26 | </para> |
| 27 | |
| 28 | <para> |
| 29 | The start phase and frequency of all oscillators and LFOs can be set by a built-in seedable 31-bit random number generator, or specified manually in a function table (GEN2). |
| 30 | </para> |
| 31 | </refsect1> |
| 32 | |
| 33 | <refsect1> |
| 34 | <title>Syntax</title> |
| 35 | <synopsis>ares <command>oscbnk</command> kcps, kamd, kfmd, kpmd, iovrlap, iseed, kl1minf, kl1maxf, \ |
| 36 | kl2minf, kl2maxf, ilfomode, keqminf, keqmaxf, keqminl, keqmaxl, \ |
| 37 | keqminq, keqmaxq, ieqmode, kfn [, il1fn] [, il2fn] [, ieqffn] \ |
| 38 | [, ieqlfn] [, ieqqfn] [, itabl] [, ioutfn]</synopsis> |
| 39 | </refsect1> |
| 40 | |
| 41 | <refsect1> |
| 42 | <title>Initialization</title> |
| 43 | <para> |
| 44 | <emphasis>iovrlap</emphasis> -- Number of oscillator units. |
| 45 | </para> |
| 46 | |
| 47 | <para> |
| 48 | <emphasis>iseed</emphasis> -- Seed value for random number generator (positive integer in the range 1 to 2147483646 (2 ˆ 31 - 2)). <emphasis>iseed</emphasis> <= 0 seeds from the current time. |
| 49 | </para> |
| 50 | |
| 51 | <para> |
| 52 | <emphasis>ieqmode</emphasis> -- Parametric equalizer mode |
| 53 | <itemizedlist> |
| 54 | <listitem><para>-1: disable EQ (faster)</para></listitem> |
| 55 | <listitem><para>0: peak</para></listitem> |
| 56 | <listitem><para>1: low shelf</para></listitem> |
| 57 | <listitem><para>2: high shelf</para></listitem> |
| 58 | <listitem><para>3: peak (filter interpolation disabled)</para></listitem> |
| 59 | <listitem><para>4: low shelf (interpolation disabled)</para></listitem> |
| 60 | <listitem><para>5: high shelf (interpolation disabled)</para></listitem> |
| 61 | </itemizedlist> |
| 62 | |
| 63 | The non-interpolated modes are faster, and in some cases (e.g. high shelf filter at low cutoff frequencies) also more stable; however, interpolation is useful for avoiding <quote>zipper noise</quote> at low control rates. |
| 64 | </para> |
| 65 | |
| 66 | <para> |
| 67 | <emphasis>ilfomode</emphasis> -- LFO modulation mode, sum of: |
| 68 | <itemizedlist> |
| 69 | <listitem><para>128: LFO1 to frequency</para></listitem> |
| 70 | <listitem><para>64: LFO1 to amplitude</para></listitem> |
| 71 | <listitem><para>32: LFO1 to phase</para></listitem> |
| 72 | <listitem><para>16: LFO1 to EQ</para></listitem> |
| 73 | <listitem><para>8: LFO2 to frequency</para></listitem> |
| 74 | <listitem><para>4: LFO2 to amplitude</para></listitem> |
| 75 | <listitem><para>2: LFO2 to phase</para></listitem> |
| 76 | <listitem><para>1: LFO2 to EQ</para></listitem> |
| 77 | </itemizedlist> |
| 78 | |
| 79 | If an LFO does not modulate anything, it is not calculated, and the ftable number (<emphasis>il1fn</emphasis> or <emphasis>il2fn</emphasis>) can be omitted. |
| 80 | </para> |
| 81 | |
| 82 | <para> |
| 83 | <emphasis>il1fn</emphasis> (optional: default=0) -- LFO1 function table number. The waveform in this table has to be normalized (absolute value <= 1), and is read with linear interpolation. |
| 84 | </para> |
| 85 | |
| 86 | <para> |
| 87 | <emphasis>il2fn</emphasis> (optional: default=0) -- LFO2 function table number. The waveform in this table has to be normalized, and is read with linear interpolation. |
| 88 | </para> |
| 89 | |
| 90 | <para> |
| 91 | <emphasis>ieqffn, ieqlfn, ieqqfn</emphasis> (optional: default=0) -- Lookup tables for EQ frequency, level, and Q (optional if EQ is disabled). Table read position is 0 if the modulator signal is less than, or equal to -1, (table length / 2) if the modulator signal is zero, and the guard point if the modulator signal is greater than, or equal to 1. These tables have to be normalized to the range 0 - 1, and have an extended guard point (table length = power of two + 1). All tables are read with linear interpolation. |
| 92 | </para> |
| 93 | |
| 94 | <para> |
| 95 | <emphasis>itabl</emphasis> (optional: default=0) -- Function table storing phase and frequency values for all oscillators (optional). The values in this table are in the following order (5 for each oscillator unit): |
| 96 | |
| 97 | <informalexample> |
| 98 | <literallayout>oscillator phase, lfo1 phase, lfo1 frequency, lfo2 phase, lfo2 frequency, ...</literallayout> |
| 99 | </informalexample> |
| 100 | |
| 101 | All values are in the range 0 to 1; if the specified number is greater than 1, it is wrapped (phase) or limited (frequency) to the allowed range. A negative value (or end of table) will use the output of the random number generator. The random seed is always updated (even if no random number was used), so switching one value between random and fixed will not change others. |
| 102 | </para> |
| 103 | |
| 104 | <para> |
| 105 | <emphasis>ioutfn</emphasis> (optional: default=0) -- Function table to write phase and frequency values (optional). The format is the same as in the case of <emphasis>itabl</emphasis>. This table is useful when experimenting with random numbers to record the best values. |
| 106 | </para> |
| 107 | |
| 108 | <para> |
| 109 | The two optional tables (<emphasis>itabl</emphasis> and <emphasis>ioutfn</emphasis>) are accessed only at i-time. This is useful to know, as the tables can be safely overwritten after opcode initialization, which allows precalculating parameters at i-time and storing in a temporary table before <emphasis>oscbnk</emphasis> initialization. |
| 110 | </para> |
| 111 | </refsect1> |
| 112 | |
| 113 | <refsect1> |
| 114 | <title>Performance</title> |
| 115 | <para> |
| 116 | <emphasis>ares</emphasis> -- Output signal. |
| 117 | </para> |
| 118 | |
| 119 | <para> |
| 120 | <emphasis>kcps</emphasis> -- Oscillator frequency in Hz. |
| 121 | </para> |
| 122 | |
| 123 | <para> |
| 124 | <emphasis>kamd</emphasis> -- AM depth (0 - 1). |
| 125 | |
| 126 | <literallayout> |
| 127 | (AM output) = (AM input) * ((1 - (AM depth)) + (AM depth) * (modulator)) |
| 128 | </literallayout> |
| 129 | |
| 130 | If <emphasis>ilfomode</emphasis> is not set to modulate the amplitude, then (AM output) = (AM input) regardless of the value of <emphasis>kamd</emphasis>. That means that <emphasis>kamd</emphasis> will have no effect. |
| 131 | </para> |
| 132 | |
| 133 | <para> |
| 134 | Note: Amplitude modulation is applied before the parametric equalizer. |
| 135 | </para> |
| 136 | |
| 137 | <para> |
| 138 | <emphasis>kfmd</emphasis> -- FM depth (in Hz). |
| 139 | </para> |
| 140 | |
| 141 | <para> |
| 142 | <emphasis>kpmd</emphasis> -- Phase modulation depth. |
| 143 | </para> |
| 144 | |
| 145 | <para> |
| 146 | <emphasis>kl1minf, kl1maxf</emphasis> -- LFO1 minimum and maximum frequency in Hz. |
| 147 | </para> |
| 148 | |
| 149 | <para> |
| 150 | <emphasis>kl2minf, kl2maxf</emphasis> -- LFO2 minimum and maximum frequency in Hz. (Note: oscillator and LFO frequencies are allowed to be zero or negative.) |
| 151 | </para> |
| 152 | |
| 153 | <para> |
| 154 | <emphasis>keqminf, keqmaxf</emphasis> -- Parametric equalizer minimum and maximum frequency in Hz. |
| 155 | </para> |
| 156 | |
| 157 | <para> |
| 158 | <emphasis>keqminl, keqmaxl</emphasis> -- Parametric equalizer minimum and maximum level. |
| 159 | </para> |
| 160 | |
| 161 | <para> |
| 162 | <emphasis>keqminq, keqmaxq</emphasis> -- Parametric equalizer minimum and maximum Q. |
| 163 | </para> |
| 164 | |
| 165 | <para> |
| 166 | <emphasis>kfn</emphasis> -- Oscillator waveform table. Table number can be changed at k-rate (this is useful to select from a set of band-limited tables generated by GEN30, to avoid aliasing). The table is read with linear interpolation. |
| 167 | </para> |
| 168 | |
| 169 | <note> |
| 170 | <title>Note</title> |
| 171 | <para> |
| 172 | <emphasis>oscbnk</emphasis> uses the same random number generator as <emphasis>rnd31</emphasis>. So reading <link linkend="rnd31"><citetitle>its documentation</citetitle></link> is also recommended. |
| 173 | </para> |
| 174 | </note> |
| 175 | </refsect1> |
| 176 | |
| 177 | <refsect1> |
| 178 | <title>Examples</title> |
| 179 | <para> |
| 180 | Here is an example of oscbnk opcode. It uses the file <ulink url="examples/oscbnk.csd"><citetitle>oscbnk.csd</citetitle></ulink>. |
| 181 | |
| 182 | <example> |
| 183 | <title>Example of the oscbnk opcode.</title> |
| 184 | |
| 185 | |
| 186 | |
| 187 | <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> |
| 188 | <xi:include href="examples-xml/oscbnk.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 189 | </example> |
| 190 | </para> |
| 191 | </refsect1> |
| 192 | |
| 193 | <refsect1> |
| 194 | <para> |
| 195 | Here is an advanced example of oscbnk opcode. It uses the file <ulink url="examples/oscbnk-advanced.csd"><citetitle>oscbnk-advanced.csd</citetitle></ulink>. |
| 196 | <example> |
| 197 | <title>Advanced example of the oscbnk opcode.</title> |
| 198 | <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> |
| 199 | <xi:include href="examples-xml/oscbnk-advanced.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 200 | </example> |
| 201 | </para> |
| 202 | </refsect1> |
| 203 | |
| 204 | <refsect1> |
| 205 | <title>See also</title> |
| 206 | <para><link linkend="SiggenBasic"><citetitle>Basic Oscillators</citetitle></link></para> |
| 207 | </refsect1> |
| 208 | |
| 209 | <refsect1> |
| 210 | <title>Credits</title> |
| 211 | <para> |
| 212 | <simplelist> |
| 213 | <member>Author: &nameistvan;</member> |
| 214 | <member>2001</member> |
| 215 | </simplelist> |
| 216 | </para> |
| 217 | |
| 218 | <para>New in version 4.15</para> |
| 219 | <para>Updated April 2002 by &nameistvan;</para> |
| 220 | </refsect1> |
| 221 | </refentry> |