Debian Codegraph @

opcodes/spat3dt.xml

raw symbols SCIP
1
2 <refentry id="spat3dt">
3 <indexterm id="IndexSpat3dt"><primary>spat3dt</primary></indexterm>
4 <refentryinfo><title>Signal Modifiers:Panning and Spatialization</title></refentryinfo>
5 <refmeta>
6 <refentrytitle>spat3dt</refentrytitle>
7 </refmeta>
8
9
10
11 <refnamediv>
12 <refname>spat3dt</refname>
13 <refpurpose>
14 Can be used to render an impulse response for a 3D space 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. <emphasis>spat3dt</emphasis> can be used to render the impulse response at i-time, storing output in a function table, suitable for convolution.
22 </para>
23 </refsect1>
24
25 <refsect1>
26 <title>Syntax</title>
27 <synopsis><command>spat3dt</command> ioutft, iX, iY, iZ, idist, ift, imode, irlen [, iftnocl]</synopsis>
28 </refsect1>
29
30 <refsect1>
31 <title>Initialization</title>
32 <para>
33 <emphasis>ioutft</emphasis> -- 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.
34 </para>
35
36 <para>
37 <emphasis>iX</emphasis> -- Sound source X coordinate in meters (positive: right, negative: left)
38 </para>
39
40 <para>
41 <emphasis>iY</emphasis> -- Sound source Y coordinate in meters (positive: front, negative: back)
42 </para>
43
44 <para>
45 <emphasis>iZ</emphasis> -- Sound source Z coordinate in meters (positive: up, negative: down)
46 </para>
47
48 <para>
49 <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.
50 </para>
51
52 <para>
53 The following formulas describe amplitude and delay as a function of sound source distance from microphone(s):
54 <literallayout>
55 amplitude = 1 / (0.1 + distance)
56 </literallayout>
57
58 <literallayout>
59 delay = distance / 340 (in seconds)
60 </literallayout>
61 </para>
62
63 <para>
64 Distance can be calculated as:
65
66 <literallayout>
67 distance = sqrt(iX&circ;2 + iY&circ;2 + iZ&circ;2)
68 </literallayout>
69
70 In Mode 4, distance can be calculated as:
71
72 <literallayout>
73 distance from left mic = sqrt((iX + idist/2)&circ;2 + iY&circ;2 + iZ&circ;2)
74 distance from right mic = sqrt((iX - idist/2)&circ;2 + iY&circ;2 + iZ&circ;2)
75 </literallayout>
76 </para>
77
78 <para>
79 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>.
80 </para>
81
82 <para>
83 Sudden changes or discontinuities in sound source location can result in pops or clicks. Very fast movement may also degrade quality.
84 </para>
85
86 <para>
87 <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:
88
89 <informaltable frame="all">
90 <tgroup cols="2" colsep="1" rowsep="1">
91 <thead>
92 <row>
93 <entry>Room Parameter</entry>
94 <entry>Purpose</entry>
95 </row>
96 </thead>
97
98 <tbody>
99 <row>
100 <entry>0</entry>
101 <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>
102 </row>
103
104 <row>
105 <entry>1</entry>
106 <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>
107 </row>
108
109 <row>
110 <entry>2</entry>
111 <entry>imdel for spat3d. Overrides opcode parameter if non-negative.</entry>
112 </row>
113
114 <row>
115 <entry>3</entry>
116 <entry>irlen for spat3dt. Overrides opcode parameter if non-negative.</entry>
117 </row>
118
119 <row>
120 <entry>4</entry>
121 <entry>idist value. Overrides opcode parameter if >= 0.</entry>
122 </row>
123
124 <row>
125 <entry>5</entry>
126 <entry>Random seed (0 - 65535) -1 seeds from current time.</entry>
127 </row>
128
129 <row>
130 <entry>6 - 53</entry>
131 <entry>wall parameters (w = 6: ceil, w = 14: floor, w = 22: front, w = 30: back, w = 38: right, w = 46: left)</entry>
132 </row>
133
134 <row>
135 <entry>w + 0</entry>
136 <entry>Enable reflections from this wall (0: no, 1: yes)</entry>
137 </row>
138
139 <row>
140 <entry>w + 1</entry>
141 <entry>Wall distance from listener (in meters)</entry>
142 </row>
143
144 <row>
145 <entry>w + 2</entry>
146 <entry>Randomization of wall distance (0 - 1) (in units of 1 / (wall distance))</entry>
147 </row>
148
149 <row>
150 <entry>w + 3</entry>
151 <entry>Reflection level (-1 - 1)</entry>
152 </row>
153
154 <row>
155 <entry>w + 4</entry>
156 <entry>Parametric equalizer frequency in Hz.</entry>
157 </row>
158
159 <row>
160 <entry>w + 5</entry>
161 <entry>Parametric equalizer level (1.0: no filtering)</entry>
162 </row>
163
164 <row>
165 <entry>w + 6</entry>
166 <entry>Parametric equalizer Q (0.7071: no resonance)</entry>
167 </row>
168
169 <row>
170 <entry>w + 7</entry>
171 <entry>Parametric equalizer mode (0: peak EQ, 1: low shelf, 2: high shelf)</entry>
172 </row>
173 </tbody>
174 </tgroup>
175 </informaltable>
176 </para>
177
178 <para>
179 <emphasis>imode</emphasis> -- Output mode
180 <itemizedlist>
181 <listitem><para>0: B format with W output only (mono)
182 <literallayout>
183 aout = aW
184 </literallayout>
185 </para></listitem>
186
187 <listitem><para>1: B format with W and Y output (stereo)
188 <literallayout>
189 aleft = aW + 0.7071*aY
190 aright = aW - 0.7071*aY
191 </literallayout>
192 </para></listitem>
193
194 <listitem><para>2: B format with W, X, and Y output (2D). This can be converted to UHJ:
195 <literallayout>
196 aWre, aWim hilbert aW
197 aXre, aXim hilbert aX
198 aYre, aYim hilbert aY
199 aWXr = 0.0928*aXre + 0.4699*aWre
200 aWXiYr = 0.2550*aXim - 0.1710*aWim + 0.3277*aYre
201 aleft = aWXr + aWXiYr
202 aright = aWXr - aWXiYr
203 </literallayout>
204 </para></listitem>
205
206 <listitem><para>3: B format with all outputs (3D)</para></listitem>
207
208 <listitem><para>4: Simulates a pair of microphones (stereo output)
209 <literallayout>
210 aW butterlp aW, ifreq ; recommended values for ifreq
211 aY butterlp aY, ifreq ; are around 1000 Hz
212 aleft = aW + aX
213 aright = aY + aZ
214 </literallayout>
215 </para></listitem>
216 </itemizedlist>
217 </para>
218
219 <para>
220 Mode 0 is the cheapest to calculate, while mode 4 is the most expensive.
221 </para>
222
223 <para>
224 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.
225 </para>
226
227 <para>
228 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.
229 </para>
230
231 <para>
232 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>
233 </para>
234
235 <para>
236 <emphasis>irlen</emphasis> -- 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)
237 </para>
238
239 <para>
240 <emphasis>iftnocl</emphasis> (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).
241 </para>
242 </refsect1>
243
244 <refsect1>
245 <title>Examples</title>
246 <para>
247 Here is an example of the spat3dt opcode. It uses the file <ulink url="examples/spat3dt.csd"><citetitle>spat3dt.csd</citetitle></ulink>.
248 <example>
249 <title>Example of the spat3dt opcode.</title>
250 <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>
251 <xi:include href="examples-xml/spat3dt.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
252 </example>
253 </para>
254 </refsect1>
255
256 <refsect1>
257 <title>See also</title>
258 <para><link linkend="SigmodPanspatl"><citetitle>Panning and Spatialization: Simulation of room acoustics</citetitle></link></para>
259 </refsect1>
260
261 <refsect1>
262 <title>Credits</title>
263 <para>
264 <simplelist>
265 <member>Author: &nameistvan;</member>
266 <member>2001</member>
267 </simplelist>
268 </para>
269
270 <para>New in version 4.12</para>
271 <para>Updated April 2002 by &nameistvan;</para>
272 </refsect1>
273 </refentry>