• No results found

Convolution with the HRTF

In document Schissler_unc_0153D_17260.pdf (Page 110-113)

5.4 Efficient Perceptual Construction of the Spatial Impulse Response

5.4.2 Convolution with the HRTF

Once the minimum spherical harmonic ordern˜has been determined for a given partition, the next step is to convolve the partition IR with the user’s HRTF to generate the SIR for the partition.

First, the time-domain spherical harmonic signal for the IR partition must be computed from theNi sound paths that arrived during the partition. This can be done by evaluating equation 5.27 for each time

sample in the partition with the appropriate path delays added:

Xlmω¯(t) = 1 PNi i=0δ(t−ti)Iiω¯ Ni X i=0 δ(t−ti)Ylm(~xi)Iiω¯. (5.31)

The result of this operation is a set of normalized SH coefficients for each time sample and frequency band in

the partition that represent an approximation of the directional information up to SH order˜n. Next, the energy-time curve for the partition,Iω¯(t), is computed as a sum of delayed impulses:

Iω¯(t) =

M

X

j=0

δ(t−ti)Iiω¯. (5.32)

This signal represents the sound energy decay for the partition at frequency bandω¯.

To efficiently perform the convolution with the HRTF in frequency domain, the signalsXlmω¯(t)and Iω¯(t)which are of lengthLmust be padded at the end with zeros so that they are2Laudio samples long. In

a preprocessing step, the HRTF is padded with zeros in time domain so that it is also2Lsamples long. The

HRTF is converted to frequency domain with a forward Fourier transform of size2Land then projected into

the spherical harmonic basis, yielding complex HRTF coefficientshlm(ω). The partition SIR for frequency bandω¯ can then be computed by convolvinghlm(ω)with the Fourier transform of the IR signals:

pω¯(t) =F−1 " n˜ X l=0 l X m=−l hlm(ω)F Xlmω¯(t) p Iω¯(t)z0 # (5.33)

whereF is the Fourier transform operator. The resulting filters for all frequency bands are then band-pass filtered and then summed according to equation 5.4 to generate the full SIR for the partition. Then, the

partition SIR is added to the output SIR at the partition’s time offset. When all partitions have been processed,

the SIR is complete and can be convolved with the anechoic audio for the sound source.

5.5 Implementation

In this section we describe the various implementation details for our spatial sound rendering system. We

implemented our approach as a plugin for the Unity™game engine. The sound sources, listener, and scene

geometry are specified by attaching scripts to objects within the game engine. Spatial audio processing is

applied to each sound source’s anechoic audio as a custom Unity audio effect. The sound for all sources is

then mixed for stereo reproduction using Unity’s built-in audio mixing system. Our system supports dynamic

area/volume sources, listeners, and moving rigid geometry.

Sound Propagation: The propagation of sound within the virtual scene is computed in 4 logarithmically-

distributed frequency bands:0−110Hz,110−630Hz,630−3500Hz, and3500−22050Hz. We use the ray-based image source method (Vorl¨ander, 1989) to compute early specular reflections and Monte Carlo

path tracing from the listener for diffuse reflections. We accelerate these computations using temporal

coherence techniques such as the specular path cache and the impulse response cache (Chapter 3). Our sound

propagation module also computes diffraction up to order 3 according to the UTD model (Tsingos et al., 2001;

Schissler et al., 2014) during the specular ray tracing step. The number of primary rays traced on each frame

from the listener is calculated based on the time taken to compute the previous frame. This allows our system

to adaptively reduce or increase the simulation quality to maintain a specific update time for sound propa-

gation. About500−1,000primary rays are traced for indoor scenes, while more rays are traced outdoors because most rays escape the scene after a few bounces. The ray tracing is parallelized across half of the avail-

able CPU threads (6 in this case), and these threads execute with low priority to avoid audio rendering glitches.

Area/Volume Sound Sources: We incorporate a simple model of sound propagation delay into our

technique for direct sound of area and volume sources. Rather than using the actual delay to each audible

point on sound source, we use theminimumdelay to avoid comb-filtering artifacts which occur when the same

anechoic source audio is played with slightly different delays. We compute the nearest sample on the source

algorithm (Wenzel et al., 2000) to produce smoothly-varying sound that incorporates Doppler shifting effects

for the direct sound. The anechoic sound for each source is resampled using linear interpolation and then

convolved with the spatial audio filter. Other propagation delay models such as center of bounding sphere or

center of gravity of mesh are also possible options.

Spatial IR Construction: In our implementation, we use an impulse response partition size ofL= 512

samples, or roughly10.7ms at a 48,000kHz sampling rate. The filtering of the spatial IR into frequency

bands is accomplished using a 4th-order time-domain Linkwitz-Riley crossover network. The SRIR(s) for

all sources are computed in parallel using the other half of the CPU threads (6 in our system). Spatial IR

construction is performed in parallel with sound propagation in order to reduce the update period, and the

IR(s) are double-buffered such that the sound propagation for framenis computed while the spatial IR for framen−1is constructed.

Spherical Harmonics:Efficient computation of our spatial sound techniques requires fast evaluation of the

real spherical harmonics. We use the formulation proposed in (Sloan, 2013) that uses aggressive constant

propagation and recurrence relations to speed up the computation for normalized cartesian vectors. It is

more than an order of magnitude faster than na¨ıve SH evaluation and substantially reduces the computational

requirements for our spatial sound techniques. In a recent study of HRTF localization, the 4th-order spherical

harmonics were sufficient to achieve accurate localization performance (Romigh et al., 2015). As a result, we

use a maximum spherical harmonic order ofnmax= 4.

Sharp Directivities:Low-order spherical harmonics may not always be sufficient to represent cases where

the impulse response has very sharp directivities, such as with direct and early reflected sound. To handle this,

we implemented a simple approach that finds important propagation paths in a preliminary pass over the RIR

and then performs accurate HRTF interpolation (5.3) for just those paths. The other paths are computed using

the our approach from Section 5.4. A path is considered important if its intensity is a significant fraction of

the total energy in the impulse response, e.g.1%. This approach tends to reduce the SH order required to

represent strongly directional impulse responses. As a result, a smaller value fornmaxcan be used to save time in evaluation of the directivity metric. However, we did not notice any significant impact on performance

or sound quality in the benchmark scenes so this module was disabled for our main results.

Auralization:Given a set of spatial impulse responses, the auralization module uses a non-uniform partitioned

block convolution algorithm to efficiently convolve the SRIRs with the anechoic audio for each sound source

with low latency (Gardner, 1994). We use an initial block size of 64 samples, and then double the block

size every 4 blocks until a maximum block size of 512 samples is reached. This keeps both the convolution

latency (128 samples) and the latency to update the impulse response (≤512 samples) low. A thread pool with 2 high-priority threads is used to execute the convolution for each group of 4 blocks in parallel, and the

priority for each of the tasks is inversely proportional to the block size. On each audio rendering frame, the

audio device output thread waits on the thread pool tasks that are due on that frame (Battenberg and Avizienis,

2011). When the IR for a block is updated, a convolution is computed for both the previous and next filters,

and then the results are interpolated in time domain over the block length (M¨uller-Tomfelde, 2001). The

resulting audio for all sound sources is mixed and then sent to the audio device for playback. We use the

Unity™game engine audio system which introduces an additional 21.3ms of latency due to audio output

buffering.

5.6 Results

In this section we present results and analysis of our spatial sound techniques. First we demonstrate the

performance of our technique for area and volume sources. Then, we show how our method for efficient

spatial IR construction can improve on existing approaches.

In document Schissler_unc_0153D_17260.pdf (Page 110-113)