Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 2622

csound-doc-5.19.01-10.mga5.noarch.rpm

<?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>spat3dt</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="spat3di.html" title="spat3di" />
    <link rel="next" href="spdist.html" title="spdist" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">spat3dt</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="spat3di.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="spdist.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="spat3dt">
      <a id="spat3dt"></a>
      <div class="titlepage"></div>
      <a id="IndexSpat3dt" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">spat3dt</span>
        </h2>
        <p>spat3dt — 
      Can be used to render an impulse response for a 3D space at i-time.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp44648872"></a>
        <h2>Description</h2>
        <p>
      This opcode positions the input sound in a 3D space, with optional simulation of room acoustics, in various output formats. <span class="emphasis"><em>spat3dt</em></span> can be used to render the impulse response at i-time, storing output in a function table, suitable for convolution.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp44683984"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>spat3dt</strong></span> ioutft, iX, iY, iZ, idist, ift, imode, irlen [, iftnocl]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp44684992"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ioutft</em></span> -- Output ftable number for spat3dt. W, X, Y, and Z outputs are written interleaved to this table. If the table is too short, output will be truncated.
    </p>
        <p>
      <span class="emphasis"><em>iX</em></span> -- Sound source X coordinate in meters (positive: right, negative: left)
    </p>
        <p>
      <span class="emphasis"><em>iY</em></span> -- Sound source Y coordinate in meters (positive: front, negative: back)
    </p>
        <p>
      <span class="emphasis"><em>iZ</em></span> -- Sound source Z coordinate in meters (positive: up, negative: down)
    </p>
        <p>
      <span class="emphasis"><em>idist</em></span> -- For modes 0 to 3, <span class="emphasis"><em>idist</em></span> is the unit circle distance in meters. For mode 4, <span class="emphasis"><em>idist</em></span> is the distance between microphones. 
    </p>
        <p>
      The following formulas describe amplitude and delay as a function of sound source distance from microphone(s):
      </p>
        <div class="literallayout">
          <p><br />
amplitude = 1 / (0.1 + distance)<br />
      </p>
        </div>
        <p>

      </p>
        <div class="literallayout">
          <p><br />
delay = distance / 340 (in seconds)<br />
      </p>
        </div>
        <p>
    </p>
        <p>
      Distance can be calculated as:

      </p>
        <div class="literallayout">
          <p><br />
distance = sqrt(iX^2 + iY^2 + iZ^2)<br />
      </p>
        </div>
        <p>

      In Mode 4, distance can be calculated as:

      </p>
        <div class="literallayout">
          <p><br />
distance from left mic = sqrt((iX + idist/2)^2 + iY^2 + iZ^2)<br />
distance from right mic = sqrt((iX - idist/2)^2 + iY^2 + iZ^2)<br />
      </p>
        </div>
        <p>
    </p>
        <p>
      With <span class="emphasis"><em>spat3d</em></span> the distance between the sound source and any microphone should be at least (340 * 18) / sr meters. Shorter distances will work, but may produce artifacts in some cases.  There is no such limitation for <span class="emphasis"><em>spat3di</em></span> and <span class="emphasis"><em>spat3dt</em></span>.
    </p>
        <p>
      Sudden changes or discontinuities in sound source location can result in pops or clicks. Very fast movement may also degrade quality.
    </p>
        <p>
      <span class="emphasis"><em>ift</em></span> -- Function table storing room parameters (for free field spatialization, set it to zero or negative). Table size is 54. The values in the table are:

      </p>
        <div class="informaltable">
          <table border="1">
            <colgroup>
              <col />
              <col />
            </colgroup>
            <thead>
              <tr>
                <th>Room Parameter</th>
                <th>Purpose</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>0</td>
                <td>Early reflection recursion depth (0 is the sound source, 1 is the first reflection etc.) for spat3d and spat3di. The number of echoes for four walls (front, back, right, left) is: N = (2*R + 2) * R. If all six walls are enabled: N = (((4*R + 6)*R + 8)*R) / 3</td>
              </tr>
              <tr>
                <td>1</td>
                <td>Late reflection recursion depth (used by spat3dt only). spat3dt skips early reflections and renders echoes up to this level. If early reflection depth is negative, spat3d and spat3di will output zero, while spat3dt will start rendering from the sound source.</td>
              </tr>
              <tr>
                <td>2</td>
                <td>imdel for spat3d. Overrides opcode parameter if non-negative.</td>
              </tr>
              <tr>
                <td>3</td>
                <td>irlen for spat3dt. Overrides opcode parameter if non-negative.</td>
              </tr>
              <tr>
                <td>4</td>
                <td>idist value. Overrides opcode parameter if &gt;= 0.</td>
              </tr>
              <tr>
                <td>5</td>
                <td>Random seed (0 - 65535) -1 seeds from current time.</td>
              </tr>
              <tr>
                <td>6 - 53</td>
                <td>wall parameters (w = 6: ceil, w = 14: floor, w = 22: front, w = 30: back, w = 38: right, w = 46: left)</td>
              </tr>
              <tr>
                <td>w + 0</td>
                <td>Enable reflections from this wall (0: no, 1: yes)</td>
              </tr>
              <tr>
                <td>w + 1</td>
                <td>Wall distance from listener (in meters)</td>
              </tr>
              <tr>
                <td>w + 2</td>
                <td>Randomization of wall distance (0 - 1) (in units of 1 / (wall distance))</td>
              </tr>
              <tr>
                <td>w + 3</td>
                <td>Reflection level (-1 - 1)</td>
              </tr>
              <tr>
                <td>w + 4</td>
                <td>Parametric equalizer frequency in Hz.</td>
              </tr>
              <tr>
                <td>w + 5</td>
                <td>Parametric equalizer level (1.0: no filtering)</td>
              </tr>
              <tr>
                <td>w + 6</td>
                <td>Parametric equalizer Q (0.7071: no resonance)</td>
              </tr>
              <tr>
                <td>w + 7</td>
                <td>Parametric equalizer mode (0: peak EQ, 1: low shelf, 2: high shelf)</td>
              </tr>
            </tbody>
          </table>
        </div>
        <p>
    </p>
        <p>
      <span class="emphasis"><em>imode</em></span> -- Output mode
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" type="disc">
            <li class="listitem">
              <p>0: B format with W output only (mono)
</p>
              <div class="literallayout">
                <p><br />
aout    =  aW<br />
</p>
              </div>
              <p>
        </p>
            </li>
            <li class="listitem">
              <p>1: B format with W and Y output (stereo)
</p>
              <div class="literallayout">
                <p><br />
aleft   =  aW + 0.7071*aY<br />
aright  =  aW - 0.7071*aY<br />
</p>
              </div>
              <p>
        </p>
            </li>
            <li class="listitem">
              <p>2: B format with W, X, and Y output (2D). This can be converted to UHJ:
</p>
              <div class="literallayout">
                <p><br />
aWre, aWim      hilbert aW<br />
aXre, aXim      hilbert aX<br />
aYre, aYim      hilbert aY<br />
aWXr    =  0.0928*aXre + 0.4699*aWre<br />
aWXiYr  =  0.2550*aXim - 0.1710*aWim + 0.3277*aYre<br />
aleft   =  aWXr + aWXiYr<br />
aright  =  aWXr - aWXiYr<br />
</p>
              </div>
              <p>
        </p>
            </li>
            <li class="listitem">
              <p>3: B format with all outputs (3D)</p>
            </li>
            <li class="listitem">
              <p>4: Simulates a pair of microphones (stereo output)
</p>
              <div class="literallayout">
                <p><br />
aW      butterlp aW, ifreq      ; recommended values for ifreq<br />
aY      butterlp aY, ifreq      ; are around 1000 Hz<br />
aleft   =  aW + aX<br />
aright  =  aY + aZ<br />
</p>
              </div>
              <p>
        </p>
            </li>
          </ul>
        </div>
        <p>
    </p>
        <p>
      Mode 0 is the cheapest to calculate, while mode 4 is the most expensive.
    </p>
        <p>
      In Mode 4, The optional lowpass filters can change the frequency response depending on direction. For example, if the sound source is located left to the listener then the high frequencies are attenuated in the right channel and slightly increased in the left. This effect can be disabled by not using filters. You can also experiment with other filters (tone etc.) for better effect.
    </p>
        <p>
      Note that mode 4 is most useful for listening with headphones, and is also more expensive to calculate than the B-format (0 to 3) modes. The <span class="emphasis"><em>idist</em></span> parameter in this case sets the distance between left and right microphone; for headphones, values between 0.2 - 0.25 are recommended, although higher settings up to 0.4 may be used for wide stereo effects.
    </p>
        <p>
      More information about B format can be found here: <a class="ulink" href="http://www.york.ac.uk/inst/mustech/3d_audio/ambis2.htm" target="_top"><em class="citetitle">http://www.york.ac.uk/inst/mustech/3d_audio/ambis2.htm</em></a>
    </p>
        <p>
      <span class="emphasis"><em>irlen</em></span> -- Impulse response length of echoes (in seconds). Depending on filter parameters, values around 0.005-0.01 are suitable for most uses (higher values result in more accurate output, but slower rendering)
    </p>
        <p>
      <span class="emphasis"><em>iftnocl</em></span> (optional, default=0) -- Do not clear output ftable (mix to existing data) if set to 1, clear table before writing if set to 0 (default: 0).
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp44713256"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the spat3dt opcode. It uses the file <a class="ulink" href="examples/spat3dt.csd" target="_top"><em class="citetitle">spat3dt.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp44714232"></a>
          <p class="title">
            <strong>Example 788. Example of the spat3dt 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">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</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 spat3dt.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</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

garvb   <span class="opc">init</span> 0 
gaW     <span class="opc">init</span> 0 
gaX     <span class="opc">init</span> 0 
gaY     <span class="opc">init</span> 0 

itmp <span class="ohdr">ftgen</span> 1, 0, 64, <span class="op">-</span>2, 2, 40, <span class="op">-</span>1, <span class="op">-</span>1, <span class="op">-</span>1, 123,          \ 
           1, 13.000, 0.05, 0.85, 20000.0, 0.0, 0.50, 2,   \ 
           1,  2.000, 0.05, 0.85, 20000.0, 0.0, 0.25, 2,   \ 
           1, 16.000, 0.05, 0.85, 20000.0, 0.0, 0.35, 2,   \ 
           1,  9.000, 0.05, 0.85, 20000.0, 0.0, 0.35, 2,   \ 
           1, 12.000, 0.05, 0.85, 20000.0, 0.0, 0.35, 2,   \ 
           1,  8.000, 0.05, 0.85, 20000.0, 0.0, 0.35, 2 

itmp <span class="ohdr">ftgen</span> 2, 0, 262144, <span class="op">-</span>2, 0 
     <span class="opc">spat3dt</span> 2, <span class="op">-</span>0.2, 1, 0, 1, 1, 2, 0.005 

itmp <span class="ohdr">ftgen</span> 3, 0, 262144, <span class="op">-</span>52, 3, 2, 0, 4, 2, 1, 4, 2, 2, 4 

<span class="oblock">instr</span> 1 

a1   <span class="opc">vco2</span> 1, 440, 10 
kfrq <span class="opc">port</span> 100, 0.008, 20000 
a1   <span class="opc">butterlp</span> a1, kfrq 
a2   <span class="opc">linseg</span> 0, 0.003, 1, 0.01, 0.7, 0.005, 0, 1, 0 
a1   <span class="op">=</span>  a1 <span class="op">*</span> a2 <span class="op">*</span> 2 
     <span class="opc">denorm</span> a1 
     <span class="opc">vincr</span> garvb, a1 
aw, ax, ay, az <span class="opc">spat3di</span> a1, p4, p5, p6, 1, 1, 2 
     <span class="opc">vincr</span> gaW, aw 
     <span class="opc">vincr</span> gaX, ax 
     <span class="opc">vincr</span> gaY, ay 

<span class="oblock">endin</span> 

<span class="oblock">instr</span> 2 

<span class="opc">denorm</span> garvb 
<span class="comment">; skip as many samples as possible without truncating the IR </span>
arW, arX, arY <span class="opc">ftconv</span> garvb, 3, 2048, 2048, (65536 <span class="op">-</span> 2048) 
aW     <span class="op">=</span>  gaW <span class="op">+</span> arW 
aX     <span class="op">=</span>  gaX <span class="op">+</span> arX 
aY     <span class="op">=</span>  gaY <span class="op">+</span> arY 
garvb  <span class="op">=</span>  0 
gaW    <span class="op">=</span>  0 
gaX    <span class="op">=</span>  0 
gaY    <span class="op">=</span>  0 

aWre, aWim <span class="opc">hilbert</span> aW 
aXre, aXim <span class="opc">hilbert</span> aX 
aYre, aYim <span class="opc">hilbert</span> aY 
aWXr    <span class="op">=</span>  0.0928<span class="op">*</span>aXre <span class="op">+</span> 0.4699<span class="op">*</span>aWre 
aWXiYr  <span class="op">=</span>  0.2550<span class="op">*</span>aXim <span class="op">-</span> 0.1710<span class="op">*</span>aWim <span class="op">+</span> 0.3277<span class="op">*</span>aYre 
aL      <span class="op">=</span>  aWXr <span class="op">+</span> aWXiYr 
aR      <span class="op">=</span>  aWXr <span class="op">-</span> aWXiYr 
        <span class="opc">outs</span> aL, aR 

<span class="oblock">endin</span> 

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 

<span class="stamnt">i</span> 1 0 0.5  0.0  2.0 -0.8 
<span class="stamnt">i</span> 1 1 0.5  1.4  1.4 -0.6 
<span class="stamnt">i</span> 1 2 0.5  2.0  0.0 -0.4 
<span class="stamnt">i</span> 1 3 0.5  1.4 -1.4 -0.2 
<span class="stamnt">i</span> 1 4 0.5  0.0 -2.0  0.0 
<span class="stamnt">i</span> 1 5 0.5 -1.4 -1.4  0.2 
<span class="stamnt">i</span> 1 6 0.5 -2.0  0.0  0.4 
<span class="stamnt">i</span> 1 7 0.5 -1.4  1.4  0.6 
<span class="stamnt">i</span> 1 8 0.5  0.0  2.0  0.8 
<span class="stamnt">i</span> 2 0 10 
<span class="stamnt">e</span> 

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp44716512"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="spat3d.html" title="spat3d"><em class="citetitle">spat3d</em></a>,
      <a class="link" href="spat3di.html" title="spat3di"><em class="citetitle">spat3di</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp44718008"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Istvan Varga</td>
          </tr>
          <tr>
            <td>2001</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 4.12</p>
        <p>Updated April 2002 by Istvan Varga</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="spat3di.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="spdist.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">spat3di </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> spdist</td>
        </tr>
      </table>
    </div>
  </body>
</html>