Add 'restrict' to another parameter
[openal-soft.git] / docs / ambisonics.txt
blob77ec8ef7001201f7d3e8b376e0c93a09759bf078
1 OpenAL Soft's renderer has advanced quite a bit since its start with panned
2 stereo output. Among these advancements is support for surround sound output,
3 using psychoacoustic modeling and more accurate plane wave reconstruction. The
4 concepts in use may not be immediately obvious to people just getting into 3D
5 audio, or people who only have more indirect experience through the use of 3D
6 audio APIs, so this document aims to introduce the ideas and purpose of
7 Ambisonics as used by OpenAL Soft.
10 What Is It?
11 ===========
13 Originally developed in the 1970s by Michael Gerzon and a team others,
14 Ambisonics was created as a means of recording and playing back 3D sound.
15 Taking advantage of the way sound waves propogate, it is possible to record a
16 fully 3D soundfield using as few as 4 channels (or even just 3, if you don't
17 mind dropping down to 2 dimensions like many surround sound systems are). This
18 representation is called B-Format. It was designed to handle audio independent
19 of any specific speaker layout, so with a proper decoder the same recording can
20 be played back on a variety of speaker setups, from quadrophonic and hexagonal
21 to cubic and other periphonic (with height) layouts.
23 Although it was developed over 30 years ago, various factors held ambisonics
24 back from really taking hold in the consumer market. However, given the solid
25 theories backing it, as well as the potential and practical benefits on offer,
26 it continued to be a topic of research over the years, with improvements being
27 made over the original design. One of the improvements made is the use of
28 Spherical Harmonics to increase the number of channels for greater spatial
29 definition. Where the original 4-channel design is termed as "First-Order
30 Ambisonics", or FOA, the increased channel count through the use of Spherical
31 Harmonics is termed as "Higher-Order Ambisonics", or HOA. The details of higher
32 order ambisonics are out of the scope of this document, but know that the added
33 channels are still independent of any speaker layout, and aim to further
34 improve the spatial detail for playback.
36 Today, the processing power available on even low-end computers means real-time
37 Ambisonics processing is possible. Not only can decoders be implemented in
38 software, but so can encoders, synthesizing a soundfield using multiple panned
39 sources, thus taking advantage of what ambisonics offers in a virtual audio
40 environment.
43 How Does It Help?
44 =================
46 Positional sound has come a long way from pan-pot stereo (aka pair-wise).
47 Although useful at the time, the issues became readily apparent when trying to
48 extend it for surround sound. Pan-pot doesn't work as well for depth (front-
49 back) or vertical panning, it has a rather small "sweet spot" (the area the
50 head needs to be in to perceive the sound in its intended direction), and it
51 misses key distance-related details of sound waves.
53 Ambisonics takes a different approach. It uses all available speakers to help
54 localize a sound, and it also takes into account how the brain localizes low
55 frequency sounds compared to high frequency ones -- a so-called psychoacoustic
56 model. It may seem counter-intuitive (if a sound is coming from the front-left,
57 surely just play it on the front-left speaker?), but to properly model a sound
58 coming from where a speaker doesn't exist, more needs to be done to construct a
59 proper sound wave that's perceived to come from the intended direction. Doing
60 this creates a larger sweet spot, allowing the perceived sound direction to
61 remain correct over a larger area around the center of the speakers.
64 How Is It Used?
65 ===============
67 As a 3D audio API, OpenAL is tasked with playing 3D sound as best it can with
68 the speaker setup the user has. Since the OpenAL API does not explicitly handle
69 the output channel configuration, it has a lot of leeway in how to deal with
70 the audio before it's played back for the user to hear. Consequently, OpenAL
71 Soft (or any other OpenAL implementation that wishes to) can render using
72 Ambisonics and decode the ambisonic mix for a high level of directional
73 accuracy over what simple pan-pot could provide.
75 This is effectively what the high-quality mode option does, when given an
76 appropriate decoder configuation for the playback channel layout. 3D rendering
77 is done to an ambisonic buffer, which is later decoded for output utilizing the
78 benefits available to ambisonic processing.
80 The basic, non-high-quality, renderer uses similar principles, however it skips
81 the frequency-dependent processing (so low frequency sounds are treated the
82 same as high frequency sounds) and does some creative manipulation of the
83 involved math to skip the intermediate ambisonic buffer, rendering more
84 directly to the output while still taking advantage of all the available
85 speakers to reconstruct the sound wave. This method trades away some playback
86 quality for less memory and processor usage.
88 In addition to providing good support for surround sound playback, Ambisonics
89 also has benefits with stereo output. 2-channel UHJ is a stereo-compatible
90 format that encodes some surround sound information using a wide-band 90-degree
91 phase shift filter. It works by taking a B-Format signal, then deriving a
92 frontal stereo mix with some of the rear sounds filtered in with it. Although
93 the result is not as good as 3-channel (2D) B-Format, it has the distinct
94 advantage of only using 2 channels and being compatible with stereo output.
95 This means it will sound just fine when played as-is through a normal stereo
96 device, or it may optionally be fed to a properly configured surround sound
97 receiver which can extract the encoded information and restore some of the
98 original surround sound signal.
101 What Are Its Limitations?
102 =========================
104 As good as Ambisonics is, it's not a magic bullet that can overcome all
105 problems. One of the bigger issues it has is dealing with irregular speaker
106 setups, such as 5.1 surround sound. The problem mainly lies in the imbalanced
107 speaker positioning -- there are three speakers within the front 60-degree area
108 (meaning only 30-degree gaps in between each of the three speakers), while only
109 two speakers cover the back 140-degree area, leaving 80-degree gaps on the
110 sides. It should be noted that this problem is inherent to the speaker layout
111 itself; there isn't much that can be done to get an optimal surround sound
112 response, with ambisonics or not. It will do the best it can, but there are
113 trade-offs between detail and accuracy.
115 Another issue lies with HRTF. While it's certainly possible to play an
116 ambisonic mix using HRTF, doing so with a high degree of spatial detail
117 requires a fair amount of resources, in both memory and processing time. And
118 even with it, mixing sounds with HRTF directly will still be better for
119 positional accuracy.