-
Notifications
You must be signed in to change notification settings - Fork 10
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
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 d2248c9
Remove muted property
robertlong 524df3e
Respond to OMI_audio_emitter PR feedback
robertlong f353a5b
Move to audio sources instead of clips
robertlong 808dae1
Added descriptions and fixed PR feedback
robertlong 5f32b79
Readme volume -> gain
robertlong 7f3a577
Merge branch 'main' into OMI_audio_emitter
robertlong 87c700d
Add explainer
robertlong 56a3d3b
Update explainer
robertlong 73720dc
changes autoplay to playing and revises docs
antpb 078b856
revises readme
antpb 8249dc6
revises phrasing of description
antpb 525b335
use the word setting instead of saving
antpb 06c81d4
Merge pull request #45 from antpb/autoplay-rename-to-playing
robertlong 7d79f9b
adds explainer formulas
antpb 4c0ebc6
reformats code block
antpb aaafdf3
adds audio cone gain algorithm example graphic and explainer docs
9ca0547
fix relative path for audio cone figure
0767da7
adds white background to audio cone figure
3b30b9b
adds Third Room to list of implementations
5fada8b
add anthony to contributor list
antpb df24720
adds figure source of audiio cone graphic
antpb 8d995c1
open cone graphic external link in new tab
antpb 88fbc60
adjusts figure 1 caption markup
antpb 32c29d2
Merge pull request #46 from antpb/add-explainer-documentation
robertlong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
"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/) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
usesinnerConeAngle
andouterConeAngle
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?