<?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>fog</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <link rel="stylesheet" type="text/css" href="syntax-highlighting.css" /> <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /> <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="fofilter.html" title="fofilter" /> <link rel="next" href="fold.html" title="fold" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">fog</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="fofilter.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="fold.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="fog"></a> <div class="titlepage"></div> <a id="IndexFog" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">fog</span> </h2> <p>fog — Audio output is a succession of grains derived from data in a stored function table </p> </div> <div class="refsect1"> <a id="idm281472930090904"></a> <h2>Description</h2> <p> Audio output is a succession of grains derived from data in a stored function table <span class="emphasis"><em>ifna</em></span>. The local envelope of these grains and their timing is based on the model of <span class="emphasis"><em>fof</em></span> synthesis and permits detailed control of the granular synthesis. </p> </div> <div class="refsect1"> <a id="idm281472930018872"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>fog</strong></span> xamp, xdens, xtrans, aspd, koct, kband, kris, kdur, kdec, \ iolaps, ifna, ifnb, itotdur [, iphs] [, itmode] [, iskip]</pre> </div> <div class="refsect1"> <a id="idm281472930016680"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>iolaps</em></span> -- number of pre-located spaces needed to hold overlapping grain data. Overlaps are density dependent, and the space required depends on the maximum value of <span class="emphasis"><em>xdens</em></span> * <span class="emphasis"><em>kdur</em></span>. Can be over-estimated at no computation cost. Uses less than 50 bytes of memory per <span class="emphasis"><em>iolap</em></span>. </p> <p> <span class="emphasis"><em>ifna</em></span>, <span class="emphasis"><em>ifnb</em></span> -- table numbers of two stored functions. The first is the data used for granulation, usually from a soundfile (<a class="link" href="GEN01.html" title="GEN01"><em class="citetitle">GEN01</em></a>). The second is a rise shape, used forwards and backwards to shape the grain rise and decay; this is normally a sigmoid (<a class="link" href="GEN19.html" title="GEN19"><em class="citetitle">GEN19</em></a>) but may be linear (<a class="link" href="GEN05.html" title="GEN05"><em class="citetitle">GEN05</em></a>). </p> <p> <span class="emphasis"><em>itotdur</em></span> -- total time during which this <span class="emphasis"><em>fog</em></span> will be active. Normally set to p3. No new grain is created if it cannot complete its <span class="emphasis"><em>kdur</em></span> within the remaining <span class="emphasis"><em>itotdur</em></span>. </p> <p> <span class="emphasis"><em>iphs</em></span> (optional) -- initial phase of the fundamental, expressed as a fraction of a cycle (0 to 1). The default value is 0. </p> <p> <span class="emphasis"><em>itmode</em></span> (optional) -- transposition mode. If zero, each grain keeps the <span class="emphasis"><em>xtrans</em></span> value it was launched with. If non-zero, each is influenced by <span class="emphasis"><em>xtrans</em></span> continuously. The default value is 0. </p> <p> <span class="emphasis"><em>iskip</em></span> (optional, default=0) -- If non-zero, skip initialization (allows legato use). </p> </div> <div class="refsect1"> <a id="idm281472930003096"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>xamp</em></span> -- amplitude factor. Amplitude is also dependent on the number of overlapping grains, the interaction of the rise shape (<span class="emphasis"><em>ifnb</em></span>) and the exponential decay (<span class="emphasis"><em>kband</em></span>), and the scaling of the grain waveform (<span class="emphasis"><em>ifna</em></span>). The actual amplitude may therefore exceed <span class="emphasis"><em>xamp</em></span>. </p> <p> <span class="emphasis"><em>xdens</em></span> -- density. The frequency of grains per second. </p> <p> <span class="emphasis"><em>xtrans</em></span> -- transposition factor. The rate at which data from the stored function table <span class="emphasis"><em>ifna</em></span> is read within each grain. This has the effect of transposing the original material. A value of 1 produces the original pitch. Higher values transpose upwards, lower values downwards. Negative values result in the function table being read backwards. </p> <p> <span class="emphasis"><em>aspd</em></span> -- Starting index pointer. <span class="emphasis"><em>aspd</em></span> is the normalized index (0 to 1) to table <span class="emphasis"><em>ifna</em></span> that determines the movement of a pointer used as the starting point for reading data within each grain. (<span class="emphasis"><em>xtrans</em></span> determines the rate at which data is read starting from this pointer.) </p> <p> <span class="emphasis"><em>koct</em></span> -- octaviation index. The operation of this parameter is identical to that in <a class="link" href="fof.html" title="fof"><em class="citetitle">fof</em></a>. </p> <p> <span class="emphasis"><em>kband</em></span>, <span class="emphasis"><em>kris</em></span>, <span class="emphasis"><em>kdur</em></span>, <span class="emphasis"><em>kdec</em></span> -- grain envelope shape. These parameters determine the exponential decay (<span class="emphasis"><em>kband</em></span>), and the rise (<span class="emphasis"><em>kris</em></span>), overall duration (<span class="emphasis"><em>kdur</em></span>,) and decay (<span class="emphasis"><em>kdec</em></span> ) times of the grain envelope. Their operation is identical to that of the local envelope parameters in <span class="emphasis"><em>fof</em></span>. </p> </div> <div class="refsect1"> <a id="idm281472929986920"></a> <h2>Examples</h2> <p> Here is an example of the fog opcode. It uses the file <a class="ulink" href="examples/fog.csd" target="_top"><em class="citetitle">fog.csd</em></a>. </p> <div class="example"> <a id="idm281472929985064"></a> <p class="title"> <strong>Example 336. Example of the fog 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> <div class="refsect1"> <a id="idm281472761140120"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></span> <span class="c1">; Select audio/midi flags here according to platform</span> -odac <span class="c1">;;;realtime audio out</span> <span class="c1">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o fog.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span> <span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">32</span> <span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">2</span> <span class="vg">0dbfs</span> <span class="o">=</span> <span class="mi">1</span> <span class="kd">instr</span> <span class="nf">1</span> <span class="c1">;p4 = transposition factor</span> <span class="c1">;p5 = speed factor</span> <span class="c1">;p6 = function table for grain data</span> i<span class="n">1</span> <span class="o">=</span> <span class="vg">sr</span><span class="o">/</span><span class="nb">ftlen</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1">;scaling to reflect sample rate and table length</span> a<span class="n">1</span> <span class="nb">phasor</span> i<span class="n">1</span><span class="o">*</span><span class="nb">p5</span> <span class="c1">;index for speed</span> a<span class="n">sigl</span> <span class="nb">fog</span> <span class="mf">.5</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="nb">p4</span><span class="p">,</span> a<span class="n">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">.01</span><span class="p">,</span> <span class="mf">.5</span><span class="p">,</span> <span class="mf">.01</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="nb">p3</span> <span class="c1">;left channel</span> a<span class="n">sigr</span> <span class="nb">fog</span> <span class="mf">.4</span><span class="p">,</span> <span class="mi">25</span><span class="p">,</span> <span class="nb">p4</span><span class="o">+</span><span class="mf">.2</span><span class="p">,</span> a<span class="n">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mf">.01</span><span class="p">,</span> <span class="mf">.5</span><span class="p">,</span> <span class="mf">.01</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="nb">p3</span><span class="p">,</span> <span class="mf">.5</span> <span class="c1">;right channel</span> <span class="nb">outs</span> a<span class="n">sigl</span><span class="p">,</span> a<span class="n">sigr</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="nb">f</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">131072</span> <span class="mi">1</span> <span class="s">"fox.wav"</span> <span class="mi">0</span> <span class="mi">0</span> <span class="mi">0</span> <span class="nb">f</span> <span class="mi">2</span> <span class="mi">0</span> <span class="mi">1024</span> <span class="mi">19</span> <span class="mf">.5</span> <span class="mf">.5</span> <span class="mi">270</span> <span class="mf">.5</span> <span class="nb">i</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">10</span> <span class="mf">.7</span> <span class="mf">.1</span> <span class="nb">i</span> <span class="mi">1</span> <span class="o">+</span> <span class="mi">4</span> <span class="mf">1.2</span> <span class="mi">2</span> <span class="nb">e</span> <span class="nt"></CsScore></span> <span class="nt"></CsoundSynthesizer></span> </pre> </div> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1"> <a id="idm281472929980776"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Michael Clark</td> </tr> <tr> <td>Huddersfield</td> </tr> <tr> <td>May 1997</td> </tr> </table> <p> </p> <p>New in version 3.46</p> <p> The Csound fog generator is by Michael Clarke, extending his earlier work based on IRCAM's FOF algorithm. </p> <p>Added notes by Rasmus Ekman on September 2002.</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="fofilter.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="fold.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">fofilter </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> fold</td> </tr> </table> </div> </body> </html>