Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OMI_audio_emitter #1

Merged
merged 25 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2cae7b0
OMI_audio_emitter first draft
robertlong Jul 15, 2021
d2248c9
Remove muted property
robertlong Jul 15, 2021
524df3e
Respond to OMI_audio_emitter PR feedback
robertlong Aug 26, 2021
f353a5b
Move to audio sources instead of clips
robertlong Sep 1, 2021
808dae1
Added descriptions and fixed PR feedback
robertlong Sep 9, 2021
5f32b79
Readme volume -> gain
robertlong Sep 10, 2021
7f3a577
Merge branch 'main' into OMI_audio_emitter
robertlong Nov 23, 2021
87c700d
Add explainer
robertlong Nov 23, 2021
56a3d3b
Update explainer
robertlong Nov 23, 2021
73720dc
changes autoplay to playing and revises docs
antpb Jan 3, 2022
078b856
revises readme
antpb Jan 3, 2022
8249dc6
revises phrasing of description
antpb Jan 3, 2022
525b335
use the word setting instead of saving
antpb Jan 3, 2022
06c81d4
Merge pull request #45 from antpb/autoplay-rename-to-playing
robertlong Jan 3, 2022
7d79f9b
adds explainer formulas
antpb Jan 4, 2022
4c0ebc6
reformats code block
antpb Jan 4, 2022
aaafdf3
adds audio cone gain algorithm example graphic and explainer docs
Jan 10, 2022
9ca0547
fix relative path for audio cone figure
Jan 10, 2022
0767da7
adds white background to audio cone figure
Jan 10, 2022
3b30b9b
adds Third Room to list of implementations
Jan 10, 2022
5fada8b
add anthony to contributor list
antpb Jan 13, 2022
df24720
adds figure source of audiio cone graphic
antpb Jan 21, 2022
8d995c1
open cone graphic external link in new tab
antpb Jan 21, 2022
88fbc60
adjusts figure 1 caption markup
antpb Jan 21, 2022
32c29d2
Merge pull request #46 from antpb/add-explainer-documentation
robertlong Feb 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
277 changes: 277 additions & 0 deletions extensions/2.0/OMI_audio_emitter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
# OMI_audio_emitter

## Contributors

* Robert Long, Element Inc.
* Anthony Burchell, Individual Contributor

## Status

Open Metaverse Interoperability Group Stage 1 Proposal

## Dependencies

Written against the glTF 2.0 spec.

## Overview

This extension allows for the addition of spatialized and non-spatialized audio to glTF scenes.

Audio emitter objects may be added to 3D nodes for positional audio or to the scene for environmental or ambient audio such as background music.

### Example:

```json
{
"extensions": {
"OMI_audio_emitter": {
"audioSources": [
{
"name": "environment",
"uri": "./environment.mp3"
},
{
"name": "quack",
"mimeType": "audio/mpeg",
"bufferView": 5
}
],
"audioEmitters": [
{
"name": "environment emitter",
"type": "global",
"gain": 1,
"loop": true,
"playing": true,
"source": 0
},
{
"name": "duck emitter",
"type": "positional",
"gain": 0.8,
"loop": false,
"playing": false,
"source": 1,
"coneInnerAngle": 6.283185307179586,
"coneOuterAngle": 6.283185307179586,
Comment on lines +55 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that KHR_LIGHTS_PUNCTUAL uses innerConeAngle and outerConeAngle to describe it's spotlight cone. As we have updated the proposed specification already to more closely mirror the way images are added, should we also look to other primary extensions for naming inspiration?

"coneOuterGain": 0,
"distanceModel": "inverse",
"maxDistance": 10,
"refDistance": 1,
"rolloffFactor": 0.8
}
]
}
},
"scenes": [
{
"name": "Default Scene",
"extensions": {
"OMI_audio_emitter": {
"audioEmitters": [0]
}
}
}
],
"nodes": [
{
"name": "Duck",
"translation": [1, 2, 3],
"extensions": {
"OMI_audio_emitter": {
"audioEmitter": 1
}
}
}
]
}
```

## glTF Schema Updates

This extension consists of two primary data structures: Audio Sources and Audio Emitters. Both sources and emitters are defined on an `OMI_audio_emitter` object added to the `extensions`
object on the document root.

The extension must be added to the file's `extensionsUsed` array and because it is optional, it does not need to be added to the `extensionsRequired` array.

#### Example:

```json
{
"asset": {
"version": "2.0"
}
"extensionsUsed" : [
"OMI_audio_emitter"
],
"scenes": [...],
"nodes": [...],
"extensions": {
"OMI_audio_emitter": {
"audioSources": [...],
"audioEmitters": [...]
}
}
}
```

### Audio Sources

Audio source objects define audio data to be used in audio emitters. Multiple audio emitters may use the same audio source.

Audio sources can store their data in either a buffer view or reference an external file via uri.

When storing audio data in a buffer view, the `mimeType` field must be specified. Currently the only supported mime type is `audio/mpeg`.

#### `bufferView`

The index of the bufferView that contains the audio data. Use this instead of the image's uri property.

#### `mimeType`

The audio's MIME type. Required if `bufferView` is defined. Unless specified by another extension, the only supported mimeType is audio/mpeg.

#### `uri`

The uri of the audio file. Relative paths are relative to the glTF file.

#### MP3 Audio Format

Provides a space efficient format that can also be tuned to satisfy audio engineers.

The MPEG3 Audio Format is commonly available and freely licensed.

### Audio Emitter

#### `type`

Specifies the audio emitter type.

- `positional` Positional audio emitters
- `global ` Global audio emitters are not affected by the position of audio listeners. `coneInnerAngle`, `coneOuterAngle`, `coneOuterGain`, `distanceModel`, `maxDistance`, `refDistance`, and `rolloffFactor` should all be ignored when set.

#### `gain`

Unitless multiplier against original source volume for determining emitter loudness.

#### `loop`

Whether or not to loop the specified audio clip when finished.

#### `playing`

Whether or not the specified audio clip is playing. Setting this property `true` will set the audio clip to play on load (autoplay).

#### `source`

The id of the audio source referenced by this audio emitter.

#### `coneInnerAngle`

The angle, in radians, of a cone inside of which there will be no volume reduction.

#### `coneOuterAngle`

The angle, in radians, of a cone outside of which the volume will be reduced to a constant value of`coneOuterGain`.

#### `coneOuterGain`

The gain of the audio emitter set when outside the cone defined by the `coneOuterAngle` property. It is a linear value (not dB).

#### `distanceModel`

Specifies the distance model for the audio emitter.

- `linear` A linear distance model calculating the gain induced by the distance according to:
`1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)`
- `inverse ` (default) An inverse distance model calculating the gain induced by the distance according to:
`refDistance / (refDistance + rolloffFactor * (Math.max(distance, refDistance) - refDistance))`
- `exponential` An exponential distance model calculating the gain induced by the distance according to:
`pow((Math.max(distance, refDistance) / refDistance, -rolloffFactor)`

#### `maxDistance`

The maximum distance between the emitter and listener, after which the volume will not be reduced any further. `maximumDistance` may only be applied when the distanceModel is set to linear. Otherwise, it should be ignored.

#### `refDistance`

A reference distance for reducing volume as the emitter moves further from the listener. For distances less than this, the volume is not reduced.

#### `rolloffFactor`

Describes how quickly the volume is reduced as the emitter moves away from listener. When distanceModel is set to linear, the maximum value is 1 otherwise there is no upper limit.

### Using Audio Emitters

Audio emitters of type `global` may be added to scenes using the following syntax:

```json
{
"scenes": [
{
"extensions": {
"OMI_audio_emitter": {
"audioEmitters": [0, 1]
}
}
}
]
}
```

Audio emitters of type `positional` may be added to nodes using the following syntax:

```json
{
"nodes": [
{
"extensions": {
"OMI_audio_emitter": {
"audioEmitter": 2
}
}
}
]
}
```

Note that multiple global audio emitters are allowed on the scene, but only a single audio emitter may be added to a node.

### Audio Rolloff Formula
The Audio Rolloff range is (0, +∞). The default is 1.

The rolloff formula is dependant on the distance model defined. The available distance models are `linear`, `inverse`, and `exponential`.

- linear formula: `1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)`
- inverse formula: `refDistance / (refDistance + rolloffFactor * (Math.max(distance, refDistance) - refDistance))`
- exponential formula: `pow((Math.max(distance, refDistance) / refDistance, -rolloffFactor)`

### Audio Gain Units
The gain unit range is (0,+∞). The default is 1.
- gain formula: `originalVolume * gain`

### Audio Cone Vizualized
<img alt="Audio cone showing how cone parameters impact volume based on relative distance to the source." src="./figures/cone-diagram.svg" width="500px" />

Figure 1. A modified graphic based on the <a href="https://webaudio.github.io/web-audio-api/#Spatialization-sound-cones" target="_blank">W3C Web Audio API Audio cone Figure</a>

The cone properties relate to the `PannerNode` interface and determine the amount of volume relative to a listeners position within the defined cone area.

The 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)

### Units for Rotations

Radians are used for rotations matching glTF2.

### JSON Schema

[glTF.OMI_audio_emitter.schema.json](/extensions/2.0/OMI_audio_emitter/schema/glTF.OMI_audio_emitter.schema.json)

## Known Implementations

* Third Room - https://github.com/thirdroom/thirdroom

## Resources

Prior Art:
* [W3C Web Audio API](https://www.w3.org/TR/webaudio/)
Loading