| 1 | |
| 2 | <refentry id="space"> |
| 3 | <indexterm id="IndexSpace"><primary>space</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Modifiers:Panning and Spatialization</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>space</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>space</refname> |
| 11 | <refpurpose> |
| 12 | Distributes an input signal among 4 channels using cartesian coordinates. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | <emphasis>space</emphasis> takes an input signal and distributes it among 4 channels using Cartesian xy coordinates to calculate the balance of the outputs. The xy coordinates can be defined in a separate text file and accessed through a Function statement in the score using <link linkend="GEN28"><citetitle>Gen28</citetitle></link>, or they can be specified using the optional <emphasis>kx, ky</emphasis> arguments. The advantages to the former are: |
| 20 | <orderedlist> |
| 21 | <listitem> |
| 22 | <para>A graphic user interface can be used to draw and edit the trajectory through the Cartesian plane</para> |
| 23 | </listitem> |
| 24 | |
| 25 | <listitem> |
| 26 | <para>The file format is in the form time1 X1 Y1 time2 X2 Y2 time3 X3 Y3 allowing the user to define a time-tagged trajectory</para> |
| 27 | </listitem> |
| 28 | </orderedlist> |
| 29 | </para> |
| 30 | |
| 31 | <para> |
| 32 | <emphasis>space</emphasis> then allows the user to specify a time pointer (much as is used for <link linkend="pvoc"><citetitle>pvoc</citetitle></link>, <link linkend="lpread"><citetitle>lpread</citetitle></link> and some other units) to have detailed control over the final speed of movement. |
| 33 | </para> |
| 34 | </refsect1> |
| 35 | |
| 36 | <refsect1> |
| 37 | <title>Syntax</title> |
| 38 | <synopsis>a1, a2, a3, a4 <command>space</command> asig, ifn, ktime, kreverbsend, kx, ky</synopsis> |
| 39 | </refsect1> |
| 40 | |
| 41 | <refsect1> |
| 42 | <title>Initialization</title> |
| 43 | <para> |
| 44 | <emphasis>ifn</emphasis> -- number of the stored function created using <link linkend="GEN28"><citetitle>Gen28</citetitle></link>. This function generator reads a text file which contains sets of three values representing the xy coordinates and a time-tag for when the signal should be placed at that location. The file should look like: |
| 45 | <literallayout> |
| 46 | 0 -1 1 |
| 47 | 1 1 1 |
| 48 | 2 4 4 |
| 49 | 2.1 -4 -4 |
| 50 | 3 10 -10 |
| 51 | 5 -40 0 |
| 52 | </literallayout> |
| 53 | </para> |
| 54 | |
| 55 | <para> |
| 56 | If that file were named <quote>move</quote> then the <emphasis>Gen28</emphasis> call in the score would like: |
| 57 | <literallayout> |
| 58 | f1 0 0 28 "move" |
| 59 | </literallayout> |
| 60 | </para> |
| 61 | |
| 62 | <para> |
| 63 | <emphasis>Gen28</emphasis> takes 0 as the size and automatically allocates memory. It creates values to 10 milliseconds of resolution. So in this case there will be 500 values created by interpolating X1 to X2 to X3 and so on, and Y1 to Y2 to Y3 and so on, over the appropriate number of values that are stored in the function table. In the above example, the sound will begin in the left front, over 1 second it will move to the right front, over another second it move further into the distance but still in the right front, then in just 1/10th of a second it moves to the left rear, a bit distant. Finally over the last .9 seconds the sound will move to the right rear, moderately distant, and it comes to rest between the two left channels (due west!), quite distant. Since the values in the table are accessed through the use of a time-pointer in the <emphasis>space</emphasis> unit, the actual timing can be made to follow the file's timing exactly or it can be made to go faster or slower through the same trajectory. If you have access to the GUI that allows one to draw and edit the files, there is no need to create the text files manually. But as long as the file is ASCII and in the format shown above, it doesn't matter how it is made! |
| 64 | </para> |
| 65 | |
| 66 | <note> |
| 67 | <title>Important</title> |
| 68 | <para> |
| 69 | If <emphasis>ifn</emphasis> is 0, then <emphasis>space</emphasis> will take its values for the xy coordinates from <emphasis>kx</emphasis> and <emphasis>ky</emphasis>. |
| 70 | </para> |
| 71 | </note> |
| 72 | </refsect1> |
| 73 | |
| 74 | <refsect1> |
| 75 | <title>Performance</title> |
| 76 | <para> |
| 77 | The configuration of the xy coordinates in space places the signal in the following way: |
| 78 | <itemizedlist> |
| 79 | <listitem> |
| 80 | <para>a1 is -1, 1</para> |
| 81 | </listitem> |
| 82 | |
| 83 | <listitem> |
| 84 | <para>a2 is 1, 1</para> |
| 85 | </listitem> |
| 86 | |
| 87 | <listitem> |
| 88 | <para>a3 is -1, -1</para> |
| 89 | </listitem> |
| 90 | |
| 91 | <listitem> |
| 92 | <para>a4 is 1, -1</para> |
| 93 | </listitem> |
| 94 | </itemizedlist> |
| 95 | </para> |
| 96 | |
| 97 | <para> |
| 98 | 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 space. 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>=1, it should work well to do panning and fixed localization in a stereo field. |
| 99 | </para> |
| 100 | |
| 101 | <para> |
| 102 | <emphasis>asig</emphasis> -- input audio signal. |
| 103 | </para> |
| 104 | |
| 105 | <para> |
| 106 | <emphasis>ktime</emphasis> -- index into the table containing the xy coordinates. If used like: |
| 107 | <literallayout> |
| 108 | ktime <emphasis>line</emphasis> 0, 5, 5 |
| 109 | a1, a2, a3, a4 <emphasis>space</emphasis> asig, 1, ktime, ... |
| 110 | </literallayout> |
| 111 | </para> |
| 112 | |
| 113 | <para> |
| 114 | with the file <quote>move</quote> described above, the speed of the signal's movement will be exactly as described in that file. However: |
| 115 | <literallayout> |
| 116 | ktime <emphasis>line</emphasis> 0, 10, 5 |
| 117 | </literallayout> |
| 118 | </para> |
| 119 | |
| 120 | <para> |
| 121 | the signal will move at half the speed specified. Or in the case of: |
| 122 | <literallayout> |
| 123 | ktime <emphasis>line</emphasis> 5, 15, 0 |
| 124 | </literallayout> |
| 125 | </para> |
| 126 | |
| 127 | <para> |
| 128 | the signal will move in the reverse direction as specified and 3 times slower! Finally: |
| 129 | <literallayout> |
| 130 | ktime <emphasis>line</emphasis> 2, 10, 3 |
| 131 | </literallayout> |
| 132 | </para> |
| 133 | |
| 134 | <para> |
| 135 | will cause the signal to move only from the place specified in line 3 of the text file to the place specified in line 5 of the text file, and it will take 10 seconds to do it. |
| 136 | </para> |
| 137 | |
| 138 | <para> |
| 139 | <emphasis>kreverbsend</emphasis> -- the percentage of the direct signal that will be factored along with the distance as derived from the xy coordinates to calculate signal amounts that can be sent to reverb units such as <emphasis>reverb</emphasis>, or <emphasis>reverb2</emphasis>. |
| 140 | </para> |
| 141 | |
| 142 | <para> |
| 143 | <emphasis>kx, ky</emphasis> -- when <emphasis>ifn</emphasis> is 0, <emphasis>space</emphasis> and <emphasis>spdist</emphasis> will use these values as the xy coordinates to localize the signal. |
| 144 | </para> |
| 145 | </refsect1> |
| 146 | |
| 147 | <refsect1> |
| 148 | <title>Examples</title> |
| 149 | <para> |
| 150 | Here is an example of the space opcode. It uses the file <ulink url="examples/space_quad.csd"><citetitle>space_quad.csd</citetitle></ulink>. |
| 151 | <example> |
| 152 | <title>Example of the space opcode.</title> |
| 153 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 154 | <xi:include href="examples-xml/space_quad.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 155 | |
| 156 | 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. |
| 157 | |
| 158 | </example> |
| 159 | </para> |
| 160 | <para> |
| 161 | <emphasis>space</emphasis> can be 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. It uses the file <ulink url="examples/space_stereo.csd"><citetitle>space_stereo.csd</citetitle></ulink>. |
| 162 | <example> |
| 163 | |
| 164 | <title>Second example of the space opcode.</title> |
| 165 | <xi:include href="examples-xml/space_stereo.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 166 | </example> |
| 167 | </para> |
| 168 | <para> |
| 169 | <link linkend="spdist"><citetitle>spdist</citetitle></link> demonstrates an example of a simple intuitive use of the distance values to simulate Doppler shift. |
| 170 | </para> |
| 171 | </refsect1> |
| 172 | |
| 173 | <refsect1> |
| 174 | <title>See also</title> |
| 175 | <para><link linkend="SigmodPanspatl"><citetitle>Panning and Spatialization: Amplitude spatialization</citetitle></link></para> |
| 176 | </refsect1> |
| 177 | |
| 178 | <refsect1> |
| 179 | <title>Credits</title> |
| 180 | <para> |
| 181 | <simplelist> |
| 182 | <member>Author: Richard Karpen</member> |
| 183 | <member>Seattle, WA USA</member> |
| 184 | <member>1998</member> |
| 185 | </simplelist> |
| 186 | </para> |
| 187 | |
| 188 | <para>New in Csound version 3.48</para> |
| 189 | </refsect1> |
| 190 | </refentry> |