<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>foscil</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="follow2.html" title="follow2" /> <link rel="next" href="foscili.html" title="foscili" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">foscil</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="follow2.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="foscili.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="foscil"> <a id="foscil"></a> <div class="titlepage"></div> <a id="Indexfoscil" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">foscil</span> </h2> <p>foscil — A basic frequency modulated oscillator. </p> </div> <div class="refsect1" title="Description"> <a id="idp24020360"></a> <h2>Description</h2> <p> A basic frequency modulated oscillator. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp24021080"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>foscil</strong></span> xamp, kcps, xcar, xmod, kndx, ifn [, iphs]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp24029304"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ifn</em></span> -- function table number. Requires a wrap-around guard point. </p> <p> <span class="emphasis"><em>iphs</em></span> (optional, default=0) -- initial phase of waveform in table <span class="emphasis"><em>ifn</em></span>, 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. </p> </div> <div class="refsect1" title="Performance"> <a id="idp24031224"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>xamp</em></span> -- the amplitude of the output signal. </p> <p> <span class="emphasis"><em>kcps</em></span> -- a common denominator, in cycles per second, for the carrier and modulating frequencies. </p> <p> <span class="emphasis"><em>xcar</em></span> -- a factor that, when multiplied by the <span class="emphasis"><em>kcps</em></span> parameter, gives the carrier frequency. </p> <p> <span class="emphasis"><em>xmod</em></span> -- a factor that, when multiplied by the <span class="emphasis"><em>kcps</em></span> parameter, gives the modulating frequency. </p> <p> <span class="emphasis"><em>kndx</em></span> -- the modulation index. </p> <p> <span class="emphasis"><em>foscil</em></span> is a composite unit that effectively banks two <span class="emphasis"><em>oscil</em></span> opcodes in the familiar Chowning FM setup, wherein the audio-rate output of one generator is used to modulate the frequency input of another (the <span class="quote">“<span class="quote">carrier</span>”</span>). Effective carrier frequency = <span class="emphasis"><em>kcps</em></span> * <span class="emphasis"><em>xcar</em></span>, and modulating frequency = <span class="emphasis"><em>kcps</em></span> * <span class="emphasis"><em>xmod</em></span>. For integral values of <span class="emphasis"><em>xcar</em></span> and <span class="emphasis"><em>xmod</em></span>, the perceived fundamental will be the minimum positive value of <span class="emphasis"><em>kcps</em></span> * (<span class="emphasis"><em>xcar</em></span> - <span class="emphasis"><em>n</em></span> * <span class="emphasis"><em>xmod</em></span>), <span class="emphasis"><em>n</em></span> = 0,1,2,... The input <span class="emphasis"><em>kndx</em></span> is the index of modulation (usually time-varying and ranging 0 to 4 or so) which determines the spread of acoustic energy over the partial positions given by <span class="emphasis"><em>n</em></span> = 0,1,2,.., etc. <span class="emphasis"><em>ifn</em></span> should point to a stored sine wave. Previous to version 3.50, <span class="emphasis"><em>xcar</em></span> and <span class="emphasis"><em>xmod</em></span> could be k-rate only. </p> <p> The actual formula used for this implementation of FM synthesis is <span class="emphasis"><em>xamp</em></span> * cos(2π * <span class="emphasis"><em>t</em></span> * <span class="emphasis"><em>kcps</em></span> * <span class="emphasis"><em>xcar</em></span> + <span class="emphasis"><em>kndx</em></span> * sin(2π * <span class="emphasis"><em>t </em></span>* <span class="emphasis"><em>kcps</em></span> * <span class="emphasis"><em>xmod</em></span>) - π), assuming that the table is a sine wave. </p> </div> <div class="refsect1" title="Examples"> <a id="idp24128064"></a> <h2>Examples</h2> <p> Here is an example of the foscil opcode. It uses the file <a class="ulink" href="examples/foscil.csd" target="_top"><em class="citetitle">foscil.csd</em></a>. </p> <div class="example"> <a id="idp24129040"></a> <p class="title"> <strong>Example 288. Example of the foscil opcode.</strong> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select audio/midi flags here according to platform</span> -odac <span class="comment">;;;realtime audio out</span> <span class="comment">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o foscil.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">ksmps</span> <span class="op">=</span> 32 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="oblock">instr</span> 1 kcps <span class="op">=</span> 440 kcar <span class="op">=</span> 1 kmod <span class="op">=</span> p4 kndx <span class="opc">line</span> 0, p3, 20 <span class="comment">;intensivy sidebands</span> asig <span class="opc">foscil</span> .5, kcps, kcar, kmod, kndx, 1 <span class="opc">outs</span> asig, asig <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; sine</span> <span class="stamnt">f</span> 1 0 16384 10 1 <span class="stamnt">i</span> 1 0 9 .01 <span class="comment">;vibrato</span> <span class="stamnt">i</span> 1 10 . 1 <span class="stamnt">i</span> 1 20 . 1.414 <span class="comment">;gong-ish</span> <span class="stamnt">i</span> 1 30 5 2.05 <span class="comment">;with "beat"</span> <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="See Also"> <a id="idp24131376"></a> <h2>See Also</h2> <p> More information about frequency modulation on Wikipedia: <a class="ulink" href="http://en.wikipedia.org/wiki/Frequency_modulation_synthesis" target="_top"><em class="citetitle">http://en.wikipedia.org/wiki/Frequency_modulation_synthesis</em></a></p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="follow2.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="foscili.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">follow2 </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> foscili</td> </tr> </table> </div> </body> </html>