| 1 | |
| 2 | <refentry id="foscil"> |
| 3 | <indexterm id="Indexfoscil"><primary>foscil</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:FM Synthesis</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>foscil</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>foscil</refname> |
| 13 | <refpurpose> |
| 14 | A basic frequency modulated oscillator. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | A basic frequency modulated oscillator. |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis>ares <command>foscil</command> xamp, kcps, xcar, xmod, kndx [, ifn , iphs]</synopsis> |
| 28 | </refsect1> |
| 29 | |
| 30 | <refsect1> |
| 31 | <title>Initialization</title> |
| 32 | <para> |
| 33 | <emphasis>ifn</emphasis> (optional) -- function table number. Requires a |
| 34 | wrap-around guard point. Defaults to a sine wave. |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>iphs</emphasis> (optional, default=0) -- initial phase of waveform in table <emphasis>ifn</emphasis>, expressed as a fraction of a cycle (0 to 1). A negative value will cause phase initialization to be skipped. The default value is 0. |
| 39 | </para> |
| 40 | </refsect1> |
| 41 | |
| 42 | <refsect1> |
| 43 | <title>Performance</title> |
| 44 | <para> |
| 45 | <emphasis>xamp</emphasis> -- the amplitude of the output signal. |
| 46 | </para> |
| 47 | |
| 48 | <para> |
| 49 | <emphasis>kcps</emphasis> -- a common denominator, in cycles per second, for the carrier and modulating frequencies. |
| 50 | </para> |
| 51 | |
| 52 | <para> |
| 53 | <emphasis>xcar</emphasis> -- a factor that, when multiplied by the <emphasis>kcps</emphasis> parameter, gives the carrier frequency. |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | <emphasis>xmod</emphasis> -- a factor that, when multiplied by the <emphasis>kcps</emphasis> parameter, gives the modulating frequency. |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | <emphasis>kndx</emphasis> -- the modulation index. |
| 62 | </para> |
| 63 | |
| 64 | <para> |
| 65 | <emphasis>foscil</emphasis> is a composite unit that effectively |
| 66 | banks two <emphasis>oscil</emphasis> opcodes in the familiar |
| 67 | Chowning FM setup, wherein the audio-rate output of one |
| 68 | generator is used to modulate the frequency input of another |
| 69 | (the <quote>carrier</quote>). Effective carrier frequency = |
| 70 | <emphasis>kcps</emphasis> * <emphasis>xcar</emphasis>, and |
| 71 | modulating frequency = <emphasis>kcps</emphasis> * |
| 72 | <emphasis>xmod</emphasis>. For integral values of |
| 73 | <emphasis>xcar</emphasis> and <emphasis>xmod</emphasis>, the |
| 74 | perceived fundamental will be the minimum positive value of |
| 75 | <emphasis>kcps</emphasis> * (<emphasis>xcar</emphasis> - <emphasis>n</emphasis> * |
| 76 | <emphasis>xmod</emphasis>), <emphasis>n</emphasis> = 0,1,2,... The input |
| 77 | <emphasis>kndx</emphasis> is the index of modulation (usually |
| 78 | time-varying and ranging 0 to 4 or so) which determines the |
| 79 | spread of acoustic energy over the partial positions given by <emphasis>n</emphasis> |
| 80 | = 0,1,2,.., etc. <emphasis>ifn</emphasis> should point to a |
| 81 | stored sine wave. Previous to version 3.50, |
| 82 | <emphasis>xcar</emphasis> and <emphasis>xmod</emphasis> could be |
| 83 | k-rate only. |
| 84 | </para> |
| 85 | <para> |
| 86 | The actual formula used for this implementation of FM synthesis |
| 87 | is |
| 88 | <emphasis>xamp</emphasis> * cos(2π * <emphasis>t</emphasis> * <emphasis>kcps</emphasis> * |
| 89 | <emphasis>xcar</emphasis> + |
| 90 | <emphasis>kndx</emphasis> * sin(2π * <emphasis>t </emphasis>* <emphasis>kcps</emphasis> * |
| 91 | <emphasis>xmod</emphasis>) - π), |
| 92 | assuming that the table is a sine wave. |
| 93 | </para> |
| 94 | </refsect1> |
| 95 | |
| 96 | <refsect1> |
| 97 | <title>Examples</title> |
| 98 | <para> |
| 99 | Here is an example of the foscil opcode. It uses the file <ulink url="examples/foscil.csd"><citetitle>foscil.csd</citetitle></ulink>. |
| 100 | |
| 101 | <example> |
| 102 | <title>Example of the foscil opcode.</title> |
| 103 | |
| 104 | |
| 105 | |
| 106 | <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> |
| 107 | <xi:include href="examples-xml/foscil.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 108 | </example> |
| 109 | </para> |
| 110 | </refsect1> |
| 111 | |
| 112 | <refsect1> |
| 113 | <title>See Also</title> |
| 114 | <para> |
| 115 | <link linkend="SiggenFmsynth"><citetitle>FM Synthesis</citetitle></link> |
| 116 | </para> |
| 117 | <para> More information about frequency modulation on Wikipedia: <ulink url="http://en.wikipedia.org/wiki/Frequency_modulation_synthesis"><citetitle>http://en.wikipedia.org/wiki/Frequency_modulation_synthesis</citetitle></ulink></para> |
| 118 | </refsect1> |
| 119 | </refentry> |