Use Non-Frames Version Previous Page Next Page
Signal Modifiers: Panning and Spatialization

spat3di, spat3d, spat3dt

  ar1, ar2, ar3, ar4   spat3di   asig, ix, iy, iz, idist, ifn, imode[, istor]
  ar1, ar2, ar3, ar4   spat3d    asig, kx, ky, kz, idist, ifn, imode, imdel, iovr[, istor]
                       spat3dt   ioutfn, kx, ky, kz, idist, ifn, imode, irlen[, iftnocl]

Description

These opcodes position the input sound in a 3D space, and simulate microphone pick-up of the sound source. Optional simulation of room acoustics is avaliable.

spat3di sets the sound source position at i-time. spat3d moves the sound source at k-rate. This movement is interpolated internally to eliminate "zipper noise," as long as sr and kr are not equal. spat3dt renders the impulse response at i-time. The output of spat3dt is stored in a function table, suitable for convolution.

Output is stereo or B-format. Information about B-format may be found at:
  http://www.york.ac.uk/inst/mustech/3d_audio/ambis2.htm

Initialization

ix – sound source X coordinate in meters. Positive values move the source right. Negative values move the source left.

iy – sound source Y coordinate in meters. Positive values move the source toward the front wall. Negative values move the source toward the rear wall.

iz – sound source Z coordinate in meters. Positive values move the source up. Negative values move the source down.

imode – output mode as follows:

Mode 0 requires the least CPU power, while mode 4 requires the most. The assignment of each output depends on the mode selected as shown:

   imode = 0 imode = 1 imode = 2 imode = 3 imode = 4

ar1 W out W out W out W out L ch: Lo freq
ar2 - - X out X out L ch: Hi freq
ar3 - Y out Y out Y out R ch: Lo freq
ar4 - - - Z out R ch: Hi freq

idist – for modes 0 to 3, unit circle distance in meters. For mode 4, distance in meters between the microphones. Recommended values are in the range 0.2 to 0.5.

imdel – maximum delay time for spat3d in seconds. This must be longer than the delay time of the latest reflection, which depends on room dimensions, sound source distance, and recursion depth. The following formula gives a safe, although somewhat overestimated, value:
  imdel = (R + 1) * sqrt(W*W + H*H + D*D) / 340.0

where R is the recursion depth, W, H, and D are the width, height, and depth of the room, respectively.

iovr – oversample ratio for spat3d. Acceptable values are in the range 1 - 8. Setting iovr higher improves quality at the expense of memory and CPU usage. The recommended value is 2.

irlen – impulse response length of reflections, in seconds. Depending on the filter parameters, values in the range 0.005 - 0.01 are suitable for most uses. Higher values result in a more accurate output, but are slower to render.

iftnocl – initial state of the the ioutfn as follows:

Default is 0.

istor – skip initialization if non-zero. Default is 0.

ifn – a function table storing the room parameters., For free field, set ifn to zero or negative. Table size must be 64. The index positions in the table are:

Performance

asig – input signal

ar1, ar2, ar3, ar4 – output signals. The format of the signal on each output is dependant on the mode used. See the description of imode above.

kx – sound source X coordinate in meters. Positive values move the source right. Negative values move the source left.

ky – sound source Y coordinate in meters. Positive values move the source toward the front wall. Negative values move the source toward the rear wall.

kz – sound source Z coordinate in meters. Positive values move the source up. Negative values move the source down.

When imode = 1, the B-format output can be converted to left and right stereo as follows:

  aleft   = aW + 0.7071*aY
  aright  = aW - 0.7071*aY

When imode = 2, the B-format output can be converted to UHJ as follows:

  aWre, aWim   hilbert aW
  aXre, aXim   hilbert aX
  aYre, aYim   hilbert aY
  aWXr         =       0.0928*aXre + 0.4699*aWre
  aWXiYr       =       0.2550*aXim - 0.1710*aWim + 0.3277*aYre
  aleft        =       aWXr + aWXiYr
  aright       =       aWXr - aWXiYr

When imode = 4, a stereo signal can be obtained by processing the output as follows:

  ar1    butterlp   ar1, kfreq
  ar3    butterlp   ar3, kfreq
  aLeft  =           ar1 + ar2
  aRight =           ar3 + ar4

The optional lowpass filters change the frequency response depending on direction. For example, if the sound source is located to the left of the listener, high frequencies are attenuated in the right channel, and slightly increased in the left. The recommended value for kfreq is around 1000 Hz. Other filters (tone, etc.) will provide different results, and may be more suitable for a given use. This effect can be disabled by eliminating the filters.

Note that mode 4 is most useful for listening with headphones and is also more expensive to calculate than the B-format modes (0 to 3). When using mode 4, idist sets the distance between the left and right microphones. For headphones, values between 0.2 and 0.25 are recommended, although higher settings, up to 0.4, may be used for wide stereo effects.

For spat3d, 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. There is no such limitation for spat3di and spat3dt.

For spat3d, sudden changes or discontinuities in the sound source location can result in pops or clicks. Very fast movement may also degrade quality.

Very slow performance (up to 100 times slower) may be caused by underflows. (This is also true of many other IIR opcodes, including butterlp, pareq, hilbert.) Underflows can be avoided by:

Author

Istvan Varga
August 2001
New in Csound 4.13


Use Non-Frames Version Previous Page Next Page
Signal Modifiers: Panning and Spatialization