<?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>pan</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="pan2.html" title="pan2" /> <link rel="next" href="pareq.html" title="pareq" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">pan</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="pan2.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="pareq.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="pan"> <a id="pan"></a> <div class="titlepage"></div> <a id="IndexPan" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">pan</span> </h2> <p>pan — Distribute an audio signal amongst four channels. </p> </div> <div class="refsect1" title="Description"> <a id="idp35273096"></a> <h2>Description</h2> <p> Distribute an audio signal amongst four channels with localization control. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp35297376"></a> <h2>Syntax</h2> <pre class="synopsis">a1, a2, a3, a4 <span class="command"><strong>pan</strong></span> asig, kx, ky, ifn [, imode] [, ioffset]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp35298472"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ifn</em></span> -- function table number of a stored pattern describing the amplitude growth in a speaker channel as sound moves towards it from an adjacent speaker. Requires extended guard-point. </p> <p> <span class="emphasis"><em>imode</em></span> (optional) -- mode of the <span class="emphasis"><em>kx, ky</em></span> position values. 0 signifies raw index mode, 1 means the inputs are normalized (0 - 1). The default value is 0. </p> <p> <span class="emphasis"><em>ioffset</em></span> (optional) -- offset indicator for <span class="emphasis"><em>kx, ky</em></span>. 0 infers the origin to be at channel 3 (left rear); 1 requests an axis shift to the quadraphonic center. The default value is 0. </p> </div> <div class="refsect1" title="Performance"> <a id="idp35301024"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>pan</em></span> takes an input signal <span class="emphasis"><em>asig</em></span> and distributes it amongst four outputs (essentially quad speakers) according to the controls <span class="emphasis"><em>kx</em></span> and <span class="emphasis"><em>ky</em></span>. For normalized input (mode=1) and no offset, the four output locations are in order: left-front at (0,1), right-front at (1,1), left-rear at the origin (0,0), and right-rear at (1,0). In the notation (<span class="emphasis"><em>kx</em></span>, <span class="emphasis"><em>ky)</em></span>, the coordinates <span class="emphasis"><em>kx</em></span> and <span class="emphasis"><em>ky</em></span>, each ranging 0 - 1, thus control the 'rightness' and 'forwardness' of a sound location. </p> <p> Movement between speakers is by amplitude variation, controlled by the stored function table <span class="emphasis"><em>ifn</em></span>. As <span class="emphasis"><em>kx</em></span> goes from 0 to 1, the strength of the right-hand signals will grow from the left-most table value to the right-most, while that of the left-hand signals will progress from the right-most table value to the left-most. For a simple linear pan, the table might contain the linear function 0 - 1. A more correct pan that maintains constant power would be obtained by storing the first quadrant of a sinusoid. Since <span class="emphasis"><em>pan</em></span> will scale and truncate <span class="emphasis"><em>kx</em></span> and <span class="emphasis"><em>ky</em></span> in simple table lookup, a medium-large table (say 8193) should be used. </p> <p> <span class="emphasis"><em>kx, ky</em></span> values are not restricted to 0 - 1. A circular motion passing through all four speakers (inscribed) would have a diameter of root 2, and might be defined by a circle of radius R = root 1/2 with center at (.5,.5). <span class="emphasis"><em>kx, ky</em></span> would then come from Rcos(angle), Rsin(angle), with an implicit origin at (.5,.5) (i.e. <span class="emphasis"><em>ioffset</em></span> = 1). Unscaled raw values operate similarly. Sounds can thus be located anywhere in the polar or Cartesian plane; points lying outside the speaker square are projected correctly onto the square's perimeter as for a listener at the center. </p> </div> <div class="refsect1" title="Example"> <a id="idp35306928"></a> <h2>Example</h2> <p> Here is an example of the pan opcodes. It uses the file <a class="ulink" href="examples/pan.csd" target="_top"><em class="citetitle">pan.csd</em></a>. </p> <div class="example"> <a id="idp35307896"></a> <p class="title"> <strong>Example 564. Example of the pan opcodes.</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 real audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o pan.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> 4 <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="oblock">instr</span> 1 kcps <span class="op">=</span> p4 k1 <span class="opc">phasor</span> kcps <span class="comment">; "fraction" of circle - controls speed of rotation - can be negative</span> k2 <span class="opc">tablei</span> k1, 1, 1 <span class="comment">; sin of angle (sinusoid in f1)</span> k3 <span class="opc">tablei</span> k1, 1, 1, .25, 1 <span class="comment">; cos of angle (sin offset 1/4 circle)</span> arnd <span class="opc">randomi</span> 400, 1000, 50 <span class="comment">; produce random values </span> asig <span class="opc">poscil</span> .7, arnd, 1 <span class="comment">; audio signal.. </span> a1,a2,a3,a4 <span class="opc">pan</span> asig, k2<span class="op">/</span>2, k3<span class="op">/</span>2, 2, 1, 1 <span class="comment">; sent in a circle (f2=1st quad sin)</span> <span class="opc">outq</span> a1, a2, a3, a4 <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span>1 0 8192 10 1 <span class="stamnt">f</span>2 0 8193 9 .25 1 0 <span class="stamnt">i</span>1 0 10 .2 <span class="comment">;move to the tight</span> <span class="stamnt">i</span>1 11 10 -.2 <span class="comment">;move to the left</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> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="pan2.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="pareq.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">pan2 </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> pareq</td> </tr> </table> </div> </body> </html>