OverviewFilesCommitsIssuesDocsReleasesPeers

gltf-extensions commits / aaafdf3

adds audio cone gain algorithm example graphic and explainer docs
aaafdf3fe30fc93e224ea9225510e3021431d290
by Anthony Burchell <antpb@Anthonys-Mini.attlocal.net> · 2022-01-10T04:39:06.000Z

Changed files (2) +102 -43

extensions/2.0/OMI_audio_emitter/README.md +2 -43
……@@ -250,52 +250,11 @@ The gain unit range is (0,+∞). The default is 1.
250250- gain formula: `originalVolume * gain`
251251
252252### Audio Cone Vizualized
253![Audio cone showing how cone parameters impact volume based on relative distance to the source.](https://webaudio.github.io/web-audio-api/images/cone-diagram.svg)
253![Audio cone showing how cone parameters impact volume based on relative distance to the source.](../figures/cone-diagram.svg)
254254
255255The cone properties relate to the `PannerNode` interface and determine the amount of volume relative to a listeners position within the defined cone area.
256256
257The gain relative to cone properties is determined as follows:
258
259```
260function coneGain() {
261 const sourceOrientation =
262 new Vec3(source.orientationX, source.orientationY, source.orientationZ);
263 if (sourceOrientation.magnitude == 0 ||
264 ((source.coneInnerAngle == 360) && (source.coneOuterAngle == 360)))
265 return 1; // no cone specified - unity gain
266 // Normalized source-listener vector
267 const sourcePosition = new Vec3(panner.positionX.value, panner.positionY.value,
268 panner.positionZ.value);
269 const listenerPosition =
270 new Vec3(listener.positionX.value, listener.positionY.value,
271 listener.positionZ.value);
272 const sourceToListener = sourcePosition.diff(listenerPosition).normalize();
273 const normalizedSourceOrientation = sourceOrientation.normalize();
274 // Angle between the source orientation vector and the source-listener vector
275 const angle = 180 *
276 Math.acos(sourceToListener.dot(normalizedSourceOrientation)) /
277 Math.PI;
278 const absAngle = Math.abs(angle);
279 // Divide by 2 here since API is entire angle (not half-angle)
280 const absInnerAngle = Math.abs(source.coneInnerAngle) / 2;
281 const absOuterAngle = Math.abs(source.coneOuterAngle) / 2;
282 let gain = 1;
283 if (absAngle <= absInnerAngle) {
284 // No attenuation
285 gain = 1;
286 } else if (absAngle >= absOuterAngle) {
287 // Max attenuation
288 gain = source.coneOuterGain;
289 } else {
290 // Between inner and outer cones
291 // inner -> outer, x goes from 0 -> 1
292 const x = (absAngle - absInnerAngle) / (absOuterAngle - absInnerAngle);
293 gain = (1 - x) + source.coneOuterGain * x;
294 }
295 return gain;
296}
297```
298[Cone Gain Algorithm Source](https://webaudio.github.io/web-audio-api/#Spatialization-sound-cones)
257The gain relative to cone properties is determined in a similar way as described in the web audio api with the difference that this audio emitter extension uses radians in place of degrees. [Cone Gain Algorithm Example](https://webaudio.github.io/web-audio-api/#Spatialization-sound-cones)
299258
300259### Units for Rotations
301260
extensions/2.0/OMI_audio_emitter/figures/cone-diagram.svg +100 -0
……@@ -0,0 +1,100 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3<svg width="100%" height="100%" viewBox="0 0 1328 1047" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
4 <g id="Canvas_1">
5 <g id="Canvas_1:-Layer-1" serif:id="Canvas_1: Layer 1">
6 <g id="Graphic_6">
7 <path d="M614.148,593.332L223.265,367.656C347.903,151.778 623.946,77.812 839.824,202.45C908.438,242.064 965.416,299.042 1005.03,367.656L614.148,593.332Z" style="fill:none;fill-rule:nonzero;stroke:rgb(255,38,0);stroke-width:3px;"/>
8 </g>
9 <g id="Graphic_7">
10 <path d="M933.302,274.179C1109.57,450.442 1109.57,736.222 933.302,912.486C757.038,1088.75 471.258,1088.75 294.994,912.486C118.729,736.222 118.729,450.442 294.994,274.179C471.258,97.914 757.038,97.914 933.302,274.179" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;stroke-dasharray:1,4;"/>
11 </g>
12 <g id="Graphic_5">
13 <path d="M614.148,593.332L423.398,184.268C544.315,127.884 683.981,127.884 804.898,184.268L614.148,593.332Z" style="fill:none;fill-rule:nonzero;stroke:rgb(0,250,0);stroke-width:3px;"/>
14 </g>
15 <g id="Graphic_8">
16 <circle cx="614.148" cy="593.332" r="55.25" style="fill:white;"/>
17 <circle cx="614.148" cy="593.332" r="55.25" style="fill:none;stroke:black;stroke-width:1px;"/>
18 </g>
19 <g id="Graphic_9">
20 <circle cx="210.25" cy="71.25" r="55.25" style="fill:none;stroke:black;stroke-width:1px;"/>
21 </g>
22 <g id="Line_11">
23 <path d="M163.872,101.299L58.649,169.475" style="fill:none;fill-rule:nonzero;stroke:rgb(4,50,255);stroke-width:3px;"/>
24 </g>
25 <g id="Line_12">
26 <path d="M613.962,538.083L612.37,63.876" style="fill:none;fill-rule:nonzero;stroke:rgb(4,50,255);stroke-width:3px;"/>
27 </g>
28 <g transform="matrix(1,0,0,1,167.578,79.75)">
29 <g id="Graphic_13">
30 <g>
31 <text x="0px" y="0px" style="font-family:'HelveticaNeue', 'Helvetica Neue';font-size:24px;">Listener</text>
32 </g>
33 </g>
34 </g>
35 <g transform="matrix(2.22037,0,0,2.22037,-690.605,-961.829)">
36 <path d="M571.818,697.649L575.117,689.059L576.341,689.059L579.857,697.649L578.562,697.649L577.56,695.047L573.968,695.047L573.025,697.649L571.818,697.649ZM574.296,694.122L577.209,694.122L576.312,691.743C576.039,691.02 575.835,690.426 575.703,689.961C575.593,690.512 575.439,691.059 575.24,691.602L574.296,694.122Z" style="fill-rule:nonzero;"/>
37 <path d="M584.709,697.649L584.709,696.735C584.224,697.438 583.566,697.79 582.734,697.79C582.367,697.79 582.024,697.719 581.706,697.579C581.387,697.438 581.151,697.261 580.997,697.048C580.842,696.835 580.734,696.575 580.671,696.266C580.628,696.059 580.607,695.731 580.607,695.282L580.607,691.426L581.662,691.426L581.662,694.877C581.662,695.428 581.683,695.799 581.726,695.991C581.793,696.268 581.933,696.486 582.148,696.644C582.363,696.802 582.628,696.881 582.945,696.881C583.261,696.881 583.558,696.8 583.835,696.638C584.113,696.476 584.309,696.255 584.424,695.976C584.54,695.697 584.597,695.291 584.597,694.76L584.597,691.426L585.652,691.426L585.652,697.649L584.709,697.649Z" style="fill-rule:nonzero;"/>
38 <path d="M591.341,697.649L591.341,696.864C590.947,697.481 590.367,697.79 589.601,697.79C589.105,697.79 588.649,697.653 588.233,697.379C587.817,697.106 587.495,696.724 587.266,696.234C587.038,695.744 586.923,695.18 586.923,694.543C586.923,693.922 587.027,693.359 587.234,692.853C587.441,692.347 587.752,691.959 588.166,691.69C588.58,691.42 589.043,691.286 589.554,691.286C589.929,691.286 590.263,691.365 590.556,691.523C590.849,691.681 591.087,691.887 591.271,692.141L591.271,689.059L592.32,689.059L592.32,697.649L591.341,697.649ZM588.007,694.543C588.007,695.34 588.175,695.936 588.511,696.331C588.847,696.725 589.244,696.922 589.701,696.922C590.162,696.922 590.553,696.734 590.876,696.357C591.198,695.98 591.359,695.405 591.359,694.631C591.359,693.78 591.195,693.155 590.867,692.756C590.539,692.358 590.134,692.159 589.654,692.159C589.185,692.159 588.794,692.35 588.479,692.733C588.165,693.116 588.007,693.719 588.007,694.543Z" style="fill-rule:nonzero;"/>
39 <path d="M593.984,690.272L593.984,689.059L595.039,689.059L595.039,690.272L593.984,690.272ZM593.984,697.649L593.984,691.426L595.039,691.426L595.039,697.649L593.984,697.649Z" style="fill-rule:nonzero;"/>
40 <path d="M596.252,694.538C596.252,693.385 596.572,692.532 597.212,691.977C597.748,691.516 598.4,691.286 599.169,691.286C600.025,691.286 600.724,691.566 601.267,692.126C601.81,692.687 602.082,693.461 602.082,694.45C602.082,695.25 601.961,695.88 601.721,696.339C601.481,696.798 601.131,697.155 600.672,697.409C600.213,697.663 599.712,697.79 599.169,697.79C598.298,697.79 597.594,697.51 597.057,696.952C596.52,696.393 596.252,695.588 596.252,694.538ZM597.335,694.538C597.335,695.334 597.509,695.931 597.857,696.328C598.205,696.724 598.642,696.922 599.169,696.922C599.693,696.922 600.128,696.723 600.476,696.325C600.824,695.926 600.998,695.319 600.998,694.502C600.998,693.733 600.823,693.15 600.473,692.753C600.124,692.357 599.689,692.159 599.169,692.159C598.642,692.159 598.205,692.356 597.857,692.75C597.509,693.145 597.335,693.741 597.335,694.538Z" style="fill-rule:nonzero;"/>
41 <path d="M569.128,710.041L569.128,701.452L575.339,701.452L575.339,702.465L570.265,702.465L570.265,705.096L575.017,705.096L575.017,706.104L570.265,706.104L570.265,709.028L575.539,709.028L575.539,710.041L569.128,710.041Z" style="fill-rule:nonzero;"/>
42 <path d="M576.974,710.041L576.974,703.819L577.918,703.819L577.918,704.692C578.113,704.387 578.373,704.142 578.697,703.957C579.021,703.771 579.39,703.678 579.804,703.678C580.265,703.678 580.643,703.774 580.938,703.965C581.233,704.157 581.441,704.424 581.562,704.768C582.054,704.041 582.695,703.678 583.484,703.678C584.101,703.678 584.576,703.849 584.908,704.191C585.24,704.533 585.406,705.059 585.406,705.77L585.406,710.041L584.357,710.041L584.357,706.122C584.357,705.7 584.323,705.396 584.254,705.21C584.186,705.025 584.062,704.875 583.882,704.762C583.703,704.649 583.492,704.592 583.25,704.592C582.812,704.592 582.449,704.738 582.16,705.029C581.871,705.32 581.726,705.786 581.726,706.426L581.726,710.041L580.671,710.041L580.671,705.998C580.671,705.53 580.585,705.178 580.414,704.944C580.242,704.709 579.96,704.592 579.57,704.592C579.273,704.592 578.999,704.67 578.747,704.827C578.495,704.983 578.312,705.211 578.199,705.512C578.085,705.813 578.029,706.247 578.029,706.813L578.029,710.041L576.974,710.041Z" style="fill-rule:nonzero;"/>
43 <path d="M586.976,702.665L586.976,701.452L588.031,701.452L588.031,702.665L586.976,702.665ZM586.976,710.041L586.976,703.819L588.031,703.819L588.031,710.041L586.976,710.041Z" style="fill-rule:nonzero;"/>
44 <path d="M591.939,709.098L592.091,710.03C591.794,710.092 591.529,710.123 591.294,710.123C590.912,710.123 590.615,710.063 590.404,709.942C590.193,709.821 590.044,709.662 589.959,709.464C589.873,709.267 589.83,708.852 589.83,708.219L589.83,704.639L589.056,704.639L589.056,703.819L589.83,703.819L589.83,702.278L590.878,701.645L590.878,703.819L591.939,703.819L591.939,704.639L590.878,704.639L590.878,708.278C590.878,708.579 590.897,708.772 590.934,708.858C590.971,708.944 591.032,709.012 591.116,709.063C591.2,709.114 591.32,709.139 591.476,709.139C591.593,709.139 591.748,709.125 591.939,709.098Z" style="fill-rule:nonzero;"/>
45 <path d="M595.273,709.098L595.425,710.03C595.128,710.092 594.863,710.123 594.628,710.123C594.246,710.123 593.949,710.063 593.738,709.942C593.527,709.821 593.378,709.662 593.293,709.464C593.207,709.267 593.164,708.852 593.164,708.219L593.164,704.639L592.39,704.639L592.39,703.819L593.164,703.819L593.164,702.278L594.212,701.645L594.212,703.819L595.273,703.819L595.273,704.639L594.212,704.639L594.212,708.278C594.212,708.579 594.231,708.772 594.268,708.858C594.305,708.944 594.366,709.012 594.45,709.063C594.534,709.114 594.654,709.139 594.81,709.139C594.927,709.139 595.082,709.125 595.273,709.098Z" style="fill-rule:nonzero;"/>
46 <path d="M600.564,708.038L601.654,708.172C601.482,708.809 601.164,709.303 600.699,709.655C600.234,710.006 599.64,710.182 598.918,710.182C598.007,710.182 597.286,709.902 596.752,709.341C596.219,708.781 595.953,707.995 595.953,706.983C595.953,705.936 596.222,705.123 596.761,704.545C597.3,703.967 598,703.678 598.859,703.678C599.691,703.678 600.371,703.961 600.898,704.528C601.425,705.094 601.689,705.891 601.689,706.918C601.689,706.981 601.687,707.075 601.683,707.2L597.043,707.2C597.082,707.883 597.275,708.407 597.623,708.77C597.97,709.133 598.404,709.315 598.923,709.315C599.31,709.315 599.64,709.213 599.914,709.01C600.187,708.807 600.404,708.483 600.564,708.038ZM597.101,706.332L600.576,706.332C600.529,705.809 600.396,705.416 600.177,705.155C599.841,704.748 599.406,704.545 598.871,704.545C598.386,704.545 597.979,704.707 597.649,705.032C597.319,705.356 597.136,705.79 597.101,706.332Z" style="fill-rule:nonzero;"/>
47 <path d="M602.966,710.041L602.966,703.819L603.916,703.819L603.916,704.762C604.158,704.321 604.381,704.03 604.586,703.889C604.792,703.748 605.017,703.678 605.263,703.678C605.619,703.678 605.98,703.791 606.347,704.018L605.984,704.997C605.726,704.844 605.468,704.768 605.21,704.768C604.98,704.768 604.773,704.837 604.589,704.976C604.406,705.115 604.275,705.307 604.197,705.553C604.08,705.928 604.021,706.338 604.021,706.784L604.021,710.041L602.966,710.041Z" style="fill-rule:nonzero;"/>
48 </g>
49 <g transform="matrix(1,0,0,1,557.256,28)">
50 <g id="Graphic_15">
51 <g>
52 <text x="0px" y="0px" style="font-family:'HelveticaNeue', 'Helvetica Neue';font-size:24px;">orientation</text>
53 </g>
54 </g>
55 </g>
56 <g transform="matrix(1,0,0,1,5.782,210.5)">
57 <g id="Graphic_16">
58 <g>
59 <text x="0px" y="0px" style="font-family:'HelveticaNeue', 'Helvetica Neue';font-size:24px;">forwar<tspan x="67.512px " y="0px ">d</tspan></text>
60 </g>
61 </g>
62 </g>
63 <g transform="matrix(0.422618,-0.906308,0.906308,0.422618,806.478,451.101)">
64 <g id="Graphic_17">
65 <g>
66 <text x="0px" y="0px" style="font-family:'HelveticaNeue', 'Helvetica Neue';font-size:24px;">coneInnerAngle</text>
67 </g>
68 </g>
69 </g>
70 <g transform="matrix(0.866025,-0.5,0.5,0.866025,806.941,564.66)">
71 <g id="Graphic_18">
72 <g>
73 <text x="0px" y="0px" style="font-family:'HelveticaNeue', 'Helvetica Neue';font-size:24px;">coneOuterAngle</text>
74 </g>
75 </g>
76 </g>
77 <g transform="matrix(1,0,0,1,652.697,128.5)">
78 <g id="Graphic_19">
79 <g>
80 <text x="0px" y="0px" style="font-family:'HelveticaNeue', 'Helvetica Neue';font-size:24px;">gain = 1</text>
81 </g>
82 </g>
83 </g>
84 <g transform="matrix(1,0,0,1,1086.5,541.5)">
85 <g id="Graphic_21">
86 <g>
87 <text x="0px" y="0px" style="font-family:'HelveticaNeue', 'Helvetica Neue';font-size:24px;">gain = coneOuterGain</text>
88 </g>
89 </g>
90 </g>
91 <g transform="matrix(1,0,0,1,914.05,244.5)">
92 <g id="Graphic_22">
93 <g>
94 <text x="0px" y="0px" style="font-family:'HelveticaNeue-Italic', 'Helvetica Neue';font-style:italic;font-size:24px;">V<tspan x="13.344px 25.8px " y="0px 0px ">ar</tspan>iable gain</text>
95 </g>
96 </g>
97 </g>
98 </g>
99 </g>
100</svg>