Debian Codegraph @

opcodes/spdist.xml

raw symbols SCIP
1
2 <refentry id="spdist">
3 <indexterm id="IndexSpdist"><primary>spdist</primary></indexterm>
4 <refentryinfo><title>Signal Modifiers:Panning and Spatialization</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>spdist</refentrytitle>
7 </refmeta>
8
9 <refnamediv>
10 <refname>spdist</refname>
11 <refpurpose>
12 Calculates distance values from xy coordinates.
13 </refpurpose>
14 </refnamediv>
15
16 <refsect1>
17 <title>Description</title>
18 <para>
19 <emphasis>spdist</emphasis> uses the same xy data as <link linkend="space"><citetitle>space</citetitle></link>, also either from a text file using <link linkend="GEN28"><citetitle>Gen28</citetitle></link> or from x and y arguments given to the unit directly. The purpose of this unit is to make available the values for distance that are calculated from the xy coordinates.
20 </para>
21
22 <para>
23 In the case of <emphasis>space</emphasis>, the xy values are used to determine a distance which is used to attenuate the signal and prepare it for use in <link linkend="spsend"><citetitle>spsend</citetitle></link>. But it is also useful to have these values for distance available to scale the frequency of the signal before it is sent to the <emphasis>space</emphasis> unit.
24 </para>
25 </refsect1>
26
27 <refsect1>
28 <title>Syntax</title>
29 <synopsis>k1 <command>spdist</command> ifn, ktime, kx, ky</synopsis>
30 </refsect1>
31
32 <refsect1>
33 <title>Initialization</title>
34 <para>
35 <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:
36 <literallayout>
37 0 -1 1
38 1 1 1
39 2 4 4
40 2.1 -4 -4
41 3 10 -10
42 5 -40 0</literallayout>
43 </para>
44
45 <para>
46 If that file were named &quot;move&quot; then the <emphasis>Gen28</emphasis> call in the score would like:
47 <literallayout>
48 f1 0 0 28 &quot;move&quot;</literallayout>
49 </para>
50
51 <para>
52 <emphasis>Gen28</emphasis> takes 0 as the size and automatically
53 allocates memory. It creates values to 10 milliseconds of
54 resolution. So in this case there will be 500 values created by
55 interpolating X1 to X2 to X3 and so on, and Y1 to Y2 to Y3 and
56 so on, over the appropriate number of values that are stored in
57 the function table. In the above example, the sound will begin
58 in the left front, over 1 second it will move to the right
59 front, over another second it move further into the distance but
60 still in the right front, then in just 1/10th of a second it
61 moves to the left rear, a bit distant. Finally over the last .9
62 seconds the sound will move to the right rear, moderately
63 distant, and it comes to rest between the two left channels (due
64 west!), quite distant. Since the values in the table are
65 accessed through the use of a time-pointer in the
66 <emphasis>space</emphasis> unit, the actual timing can be made
67 to follow the file's timing exactly or it can be made to go
68 faster or slower through the same trajectory. If you have access
69 to the GUI that allows one to draw and edit the files, there is
70 no need to create the text files manually. But as long as the
71 file is ASCII and in the format shown above, it does not matter
72 how it is made!
73 </para>
74
75 <para>
76 IMPORTANT: If <emphasis>ifn</emphasis> is 0 then <emphasis>spdist</emphasis> will take its values for the xy coordinates from <emphasis>kx</emphasis> and <emphasis>ky</emphasis>.
77 </para>
78
79 </refsect1>
80
81 <refsect1>
82 <title>Performance</title>
83 <para>
84 The configuration of the xy coordinates in space places the signal in the following way:
85 <itemizedlist>
86 <listitem>
87 <para>a1 is -1, 1</para>
88 </listitem>
89
90 <listitem>
91 <para>a2 is 1, 1</para>
92 </listitem>
93
94 <listitem>
95 <para>a3 is -1, -1</para>
96 </listitem>
97
98 <listitem>
99 <para>a4 is 1, -1</para>
100 </listitem>
101 </itemizedlist>
102 </para>
103
104 <para>
105 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&gt;=1, it should work well to do panning and fixed localization in a stereo field.
106 </para>
107
108 <para>
109 <emphasis>ktime</emphasis> -- index into the table containing the xy coordinates. If used like:
110 <literallayout>
111 ktime <emphasis>line</emphasis> 0, 5, 5
112 a1, a2, a3, a4 <emphasis>space</emphasis> asig, 1, ktime, ...
113 </literallayout>
114 </para>
115
116 <para>
117 with the file &quot;move&quot; described above, the speed of the signal's movement will be exactly as described in that file. However:
118 <literallayout>
119 ktime <emphasis>line</emphasis> 0, 10, 5
120 </literallayout>
121 </para>
122
123 <para>
124 the signal will move at half the speed specified. Or in the case of:
125 <literallayout>
126 ktime <emphasis>line</emphasis> 5, 15, 0
127 </literallayout>
128 </para>
129
130 <para>
131 the signal will move in the reverse direction as specified and 3 times slower! Finally:
132 <literallayout>
133 ktime <emphasis>line</emphasis> 2, 10, 3
134 </literallayout>
135 </para>
136
137 <para>
138 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.
139 </para>
140
141 <para>
142 <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.
143 </para>
144 </refsect1>
145
146 <refsect1>
147 <title>Examples</title>
148 <para>
149 Here is an example of the spdist opcode. It uses the file <ulink url="examples/spdist.csd"><citetitle>spdist.csd</citetitle></ulink>.
150 <example>
151 <title>Example of the spdist opcode.</title>
152 <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>
153 <xi:include href="examples-xml/spdist.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
154 </example>
155 </para>
156 <para>
157 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!
158 </para>
159 </refsect1>
160
161 <refsect1>
162 <title>See also</title>
163 <para><link linkend="SigmodPanspatl"><citetitle>Panning and Spatialization: Amplitude spatialization</citetitle></link></para>
164 </refsect1>
165
166 <refsect1>
167 <title>Credits</title>
168 <para>
169 <simplelist>
170 <member>Author: Richard Karpen</member>
171 <member>Seattle, WA USA</member>
172 <member>1998</member>
173 </simplelist>
174 </para>
175
176 <para>New in Csound version 3.48</para>
177 </refsect1>
178 </refentry>