<!-- Converted to DocBook/SGML by Kevin Conder -->
<refentry id="spsend">
  <refmeta>
    <refentrytitle>spsend</refentrytitle>
  </refmeta>
 
  <refnamediv>
    <refname>spsend</refname>
    <refpurpose>
      Generates output signals based on a previously defined <emphasis>space</emphasis> opcode.
      <indexterm id="IndexSpsend"><primary>spsend</primary></indexterm>
    </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      <emphasis>spsend</emphasis> depends upon the existence of a previously defined <link linkend="space"><citetitle>space</citetitle></link>. The output signals from <emphasis>spsend</emphasis> are derived from the values given for xy and reverb in the <emphasis>space</emphasis> and are ready to be sent to local or global reverb units (see example below).
    </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis>a1, a2, a3, a4 <command>spsend</command></synopsis>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      The configuration of the xy coordinates in space places the signal in the following way:
      <itemizedlist>
        <listitem>
           <para>a1 is -1, 1</para>
        </listitem>

        <listitem>
           <para>a2 is 1, 1</para>
        </listitem>

        <listitem>
           <para>a3 is -1, -1</para>
        </listitem>

        <listitem>
           <para>a4 is 1, -1</para>
        </listitem>
      </itemizedlist>
    </para>

    <para>
      This assumes a loudspeaker set up as a1 is left front, a2 is right front, a3 is left back, a4 is right back. Values greater than 1 will result in sounds being attenuated, as if in the distance. <emphasis>space</emphasis> considers the speakers to be at a distance of 1; smaller values of xy can be used, but <emphasis>space</emphasis> will not amplify the signal in this case. It will, however balance the signal so that it can sound as if it were within the 4 speaker <emphasis>space</emphasis>.  x=0, y=1, will place the signal equally balanced between left and right front channels, x=y=0 will place the signal equally in all 4 channels, and so on. Although there must be 4 output signals from <emphasis>space</emphasis>, it can be used in a 2 channel orchestra. If the xy's are kept so that Y&gt;=1, it should work well to do panning and fixed localization in a stereo field.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Examples</title>
    <para>
      <informalexample>
        <programlisting>
<emphasis>instr</emphasis> 1
  asig    ;some audio signal
  ktime              <emphasis>line</emphasis>  0, p3, p10
  a1, a2, a3, a4     <emphasis>space</emphasis> asig,1, ktime, .1
  ar1, ar2, ar3, ar4 <emphasis>spsend</emphasis>        
  
  ga1 = ga1+ar1
  ga2 = ga2+ar2
  ga3 = ga3+ar3
  ga4 = ga4+ar4
  
                     <emphasis>outq</emphasis> a1, a2, a3, a4
<emphasis>endin</emphasis>

<emphasis>instr</emphasis> 99 ; reverb instrument
          
  a1 <emphasis>reverb2</emphasis> ga1, 2.5, .5
  a2 <emphasis>reverb2</emphasis> ga2, 2.5, .5
  a3 <emphasis>reverb2</emphasis> ga3, 2.5, .5
  a4 <emphasis>reverb2</emphasis> ga4, 2.5, .5
  
     <emphasis>outq</emphasis> a1, a2, a3, a4
  ga1=0
  ga2=0
  ga3=0
  ga4=0
        </programlisting>
      </informalexample>
    </para>

    <para>
      In the above example, the signal, <emphasis>asig</emphasis>, is moved according to the data in Function #1 indexed by <emphasis>ktime</emphasis>. <emphasis>space</emphasis> sends the appropriate amount of the signal internally to <emphasis>spsend</emphasis>. The outputs of the <emphasis>spsend</emphasis> are added to global accumulators in a common Csound style and the global signals are used as inputs to the reverb units in a separate instrument.
    </para>

    <para>
      <emphasis>space</emphasis> can useful for quad and stereo panning as well as fixed placed of sounds anywhere between two loudspeakers. Below is an example of the fixed placement of sounds in a stereo field using xy values from the score instead of a function table.
      <informalexample>
        <programlisting>
<emphasis>instr</emphasis> 1
  ...
  a1, a2, a3, a4     <emphasis>space</emphasis> asig, 0, 0, .1, p4, p5
  ar1, ar2, ar3, ar4 <emphasis>spsend
  </emphasis>
  ga1=ga1+ar1
  ga2=ga2+ar2
                     <emphasis>outs</emphasis>  a1, a2
<emphasis>endin</emphasis>

<emphasis>instr</emphasis> 99 ; reverb....
  ....
<emphasis>endin</emphasis>
        </programlisting>
      </informalexample>
    </para>

    <para>
      A few notes: p4 and p5 are the X and Y values
      <informalexample>
        <programlisting>
  ;place the sound in the left speaker and near
    i1 0 1 -1 1
  ;place the sound in the right speaker and far
    i1 1 1 45 45
  ;place the sound equally between left and right and in the middle ground distance
    i1 2 1 0 12
e
        </programlisting>
      </informalexample>
    </para>

    <para>
      The next example shows a simple intuitive use of the distance values returned by <emphasis>spdist</emphasis> to simulate Doppler shift.
      <informalexample>
        <programlisting>
  ktime              <emphasis>line</emphasis>   0, p3, 10
  kdist              <emphasis>spdist</emphasis> 1, ktime
  kfreq = (ifreq * 340) / (340 + kdist)
  asig               <emphasis>oscili</emphasis> iamp, kfreq, 1
  
  a1, a2, a3, a4     <emphasis>space</emphasis>  asig, 1, ktime, .1
  ar1, ar2, ar3, ar4 <emphasis>spsend</emphasis>
        </programlisting>
      </informalexample>
    </para>

    <para>
      The same function and time values are used for both <emphasis>spdist</emphasis> and <emphasis>space</emphasis>. This insures that the distance values used internally in the <emphasis>space</emphasis> unit will be the same as those returned by <emphasis>spdist</emphasis> to give the impression of a Doppler shift!
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="space"><citetitle>space</citetitle></link>,
      <link linkend="spdist"><citetitle>spdist</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: Richard Karpen</member>
        <member>Seattle, WA USA</member>
        <member>1998</member>
      </simplelist>
    </para>

    <para>New in Csound version 3.48</para>
  </refsect1>
</refentry>
