Debian Codegraph @

opcodes/spat3di.xml

raw symbols SCIP
1
2 <refentry id="spat3di">
3 <indexterm id="IndexSpat3di"><primary>spat3di</primary></indexterm>
4 <refentryinfo><title>Signal Modifiers:Panning and Spatialization</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>spat3di</refentrytitle>
7 </refmeta>
8
9
10
11 <refnamediv>
12 <refname>spat3di</refname>
13 <refpurpose>
14 Positions the input sound in a 3D space with the sound source position set at i-time.
15 </refpurpose>
16 </refnamediv>
17
18 <refsect1>
19 <title>Description</title>
20 <para>
21 This opcode positions the input sound in a 3D space, with optional simulation of room acoustics, in various output formats. With <emphasis>spat3di</emphasis>, sound source position is set at i-time.
22 </para>
23 </refsect1>
24
25 <refsect1>
26 <title>Syntax</title>
27 <synopsis>aW, aX, aY, aZ <command>spat3di</command> ain, iX, iY, iZ, idist, ift, imode [, istor]</synopsis>
28 </refsect1>
29
30 <refsect1>
31 <title>Initialization</title>
32 <para>
33 <emphasis>iX</emphasis> -- Sound source X coordinate in meters (positive: right, negative: left)
34 </para>
35
36 <para>
37 <emphasis>iY</emphasis> -- Sound source Y coordinate in meters (positive: front, negative: back)
38 </para>
39
40 <para>
41 <emphasis>iZ</emphasis> -- Sound source Z coordinate in meters (positive: up, negative: down)
42 </para>
43
44 <para>
45 <emphasis>idist</emphasis> -- For modes 0 to 3, <emphasis>idist</emphasis> is the unit circle distance in meters. For mode 4, <emphasis>idist</emphasis> is the distance between microphones.
46 </para>
47
48 <para>
49 The following formulas describe amplitude and delay as a function of sound source distance from microphone(s):
50 <literallayout>
51 amplitude = 1 / (0.1 + distance)
52 </literallayout>
53
54 <literallayout>
55 delay = distance / 340 (in seconds)
56 </literallayout>
57 </para>
58
59 <para>
60 Distance can be calculated as:
61
62 <literallayout>
63 distance = sqrt(iX&circ;2 + iY&circ;2 + iZ&circ;2)
64 </literallayout>
65
66 In Mode 4, distance can be calculated as:
67
68 <literallayout>
69 distance from left mic = sqrt((iX + idist/2)&circ;2 + iY&circ;2 + iZ&circ;2)
70 distance from right mic = sqrt((iX - idist/2)&circ;2 + iY&circ;2 + iZ&circ;2)
71 </literallayout>
72 </para>
73
74 <para>
75 With <emphasis>spat3d</emphasis> 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 <emphasis>spat3di</emphasis> and <emphasis>spat3dt</emphasis>.
76 </para>
77
78 <para>
79 Sudden changes or discontinuities in sound source location can result in pops or clicks. Very fast movement may also degrade quality.
80 </para>
81
82 <para>
83 <emphasis>ift</emphasis> -- 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:
84
85 <informaltable frame="all">
86 <tgroup cols="2" colsep="1" rowsep="1">
87 <thead>
88 <row>
89 <entry>Room Parameter</entry>
90 <entry>Purpose</entry>
91 </row>
92 </thead>
93
94 <tbody>
95 <row>
96 <entry>0</entry>
97 <entry>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</entry>
98 </row>
99
100 <row>
101 <entry>1</entry>
102 <entry>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.</entry>
103 </row>
104
105 <row>
106 <entry>2</entry>
107 <entry>imdel for spat3d. Overrides opcode parameter if non-negative.</entry>
108 </row>
109
110 <row>
111 <entry>3</entry>
112 <entry>irlen for spat3dt. Overrides opcode parameter if non-negative.</entry>
113 </row>
114
115 <row>
116 <entry>4</entry>
117 <entry>idist value. Overrides opcode parameter if >= 0.</entry>
118 </row>
119
120 <row>
121 <entry>5</entry>
122 <entry>Random seed (0 - 65535) -1 seeds from current time.</entry>
123 </row>
124
125 <row>
126 <entry>6 - 53</entry>
127 <entry>wall parameters (w = 6: ceil, w = 14: floor, w = 22: front, w = 30: back, w = 38: right, w = 46: left)</entry>
128 </row>
129
130 <row>
131 <entry>w + 0</entry>
132 <entry>Enable reflections from this wall (0: no, 1: yes)</entry>
133 </row>
134
135 <row>
136 <entry>w + 1</entry>
137 <entry>Wall distance from listener (in meters)</entry>
138 </row>
139
140 <row>
141 <entry>w + 2</entry>
142 <entry>Randomization of wall distance (0 - 1) (in units of 1 / (wall distance))</entry>
143 </row>
144
145 <row>
146 <entry>w + 3</entry>
147 <entry>Reflection level (-1 - 1)</entry>
148 </row>
149
150 <row>
151 <entry>w + 4</entry>
152 <entry>Parametric equalizer frequency in Hz.</entry>
153 </row>
154
155 <row>
156 <entry>w + 5</entry>
157 <entry>Parametric equalizer level (1.0: no filtering)</entry>
158 </row>
159
160 <row>
161 <entry>w + 6</entry>
162 <entry>Parametric equalizer Q (0.7071: no resonance)</entry>
163 </row>
164
165 <row>
166 <entry>w + 7</entry>
167 <entry>Parametric equalizer mode (0: peak EQ, 1: low shelf, 2: high shelf)</entry>
168 </row>
169 </tbody>
170 </tgroup>
171 </informaltable>
172 </para>
173
174 <para>
175 <emphasis>imode</emphasis> -- Output mode
176 <itemizedlist>
177 <listitem><para>0: B format with W output only (mono)
178 <literallayout>
179 aout = aW
180 </literallayout>
181 </para></listitem>
182
183 <listitem><para>1: B format with W and Y output (stereo)
184 <literallayout>
185 aleft = aW + 0.7071*aY
186 aright = aW - 0.7071*aY
187 </literallayout>
188 </para></listitem>
189
190 <listitem><para>2: B format with W, X, and Y output (2D). This can be converted to UHJ:
191 <literallayout>
192 aWre, aWim hilbert aW
193 aXre, aXim hilbert aX
194 aYre, aYim hilbert aY
195 aWXr = 0.0928*aXre + 0.4699*aWre
196 aWXiYr = 0.2550*aXim - 0.1710*aWim + 0.3277*aYre
197 aleft = aWXr + aWXiYr
198 aright = aWXr - aWXiYr
199 </literallayout>
200 </para></listitem>
201
202 <listitem><para>3: B format with all outputs (3D)</para></listitem>
203
204 <listitem><para>4: Simulates a pair of microphones (stereo output)
205 <literallayout>
206 aW butterlp aW, ifreq ; recommended values for ifreq
207 aY butterlp aY, ifreq ; are around 1000 Hz
208 aleft = aW + aX
209 aright = aY + aZ
210 </literallayout>
211 </para></listitem>
212 </itemizedlist>
213 </para>
214
215 <para>
216 Mode 0 is the cheapest to calculate, while mode 4 is the most expensive.
217 </para>
218
219 <para>
220 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.
221 </para>
222
223 <para>
224 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 <emphasis>idist</emphasis> 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.
225 </para>
226
227 <para>
228 More information about B format can be found here: <ulink url="http://www.york.ac.uk/inst/mustech/3d_audio/ambis2.htm"><citetitle>http://www.york.ac.uk/inst/mustech/3d_audio/ambis2.htm</citetitle></ulink>
229 </para>
230
231 <para>
232 <emphasis>istor</emphasis> (optional, default=0) -- Skip initialization if non-zero (default: 0).
233 </para>
234 </refsect1>
235
236 <refsect1>
237 <title>Performance</title>
238 <para>
239 <emphasis>ain</emphasis> -- Input signal
240 </para>
241
242 <para>
243 <emphasis>aW, aX, aY, aZ</emphasis> -- Output signals
244
245 <informaltable frame="all">
246 <tgroup cols="6" colsep="1" rowsep="1">
247 <thead>
248 <row>
249 <entry>&nbsp;</entry>
250 <entry>mode 0</entry>
251 <entry>mode 1</entry>
252 <entry>mode 2</entry>
253 <entry>mode 3</entry>
254 <entry>mode 4</entry>
255 </row>
256 </thead>
257
258 <tbody>
259 <row>
260 <entry>aW</entry>
261 <entry>W out</entry>
262 <entry>W out</entry>
263 <entry>W out</entry>
264 <entry>W out</entry>
265 <entry>left chn / low freq.</entry>
266 </row>
267
268 <row>
269 <entry>aX</entry>
270 <entry>0</entry>
271 <entry>0</entry>
272 <entry>X out</entry>
273 <entry>X out</entry>
274 <entry>left chn / high frq.</entry>
275 </row>
276
277 <row>
278 <entry>aY</entry>
279 <entry>0</entry>
280 <entry>Y out</entry>
281 <entry>Y out</entry>
282 <entry>Y out</entry>
283 <entry>right chn / low frq.</entry>
284 </row>
285
286 <row>
287 <entry>aZ</entry>
288 <entry>0</entry>
289 <entry>0</entry>
290 <entry>0</entry>
291 <entry>Z out</entry>
292 <entry>right chn / high fr.</entry>
293 </row>
294 </tbody>
295 </tgroup>
296 </informaltable>
297 </para>
298
299 <para>
300 If you encounter very slow performance (up to 100 times slower), it may be caused by denormals (this is also true of many other IIR opcodes, including <link linkend="butterlp"><citetitle>butterlp</citetitle></link>, <link linkend="pareq"><citetitle>pareq</citetitle></link>, <link linkend="hilbert"><citetitle>hilbert</citetitle></link>, and many others). Underflows can be avoided by:
301 <itemizedlist>
302 <listitem><para>Using the <link linkend="denorm"><citetitle>denorm</citetitle></link> opcode on <emphasis>ain</emphasis> before <emphasis>spat3di</emphasis>.</para></listitem>
303 <listitem><para>mixing low level DC or noise to the input signal, e.g. <literallayout>atmp rnd31 1/1e24, 0, 0</literallayout> <literallayout>aW, aX, aY, aZ spat3di ain + atmp, ...</literallayout> or <literallayout>aW, aX, aY, aZ spa3di ain + 1/1e24, ...</literallayout></para></listitem>
304 <listitem><para>reducing <emphasis>irlen</emphasis> in the case of <emphasis>spat3dt</emphasis> (which does not have an input signal). A value of about 0.005 is suitable for most uses, although it also depends on EQ settings. If the equalizer is not used, <quote>irlen</quote> can be set to 0.</para></listitem>
305 </itemizedlist>
306 </para>
307 </refsect1>
308
309 <refsect1>
310 <title>Examples</title>
311 <para>
312 See the examples for <link linkend="spat3d"><citetitle>spat3d</citetitle></link>.
313 </para>
314 </refsect1>
315
316 <refsect1>
317 <title>See also</title>
318 <para><link linkend="SigmodPanspatl"><citetitle>Panning and Spatialization: Simulation of room acoustics</citetitle></link></para>
319 </refsect1>
320
321 <refsect1>
322 <title>Credits</title>
323 <para>
324 <simplelist>
325 <member>Author: &nameistvan;</member>
326 <member>2001</member>
327 </simplelist>
328 </para>
329
330 <para>New in version 4.12</para>
331 <para>Updated April 2002 by &nameistvan;</para>
332 </refsect1>
333 </refentry>