Skip to content

Commit

Permalink
Merge pull request #67 from ux3d/fix/OMI_audio_emitter
Browse files Browse the repository at this point in the history
Suggestion for fixes and improvements
  • Loading branch information
robertlong authored Mar 10, 2022
2 parents c31ce67 + 21b6ea2 commit cdb2e08
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
30 changes: 16 additions & 14 deletions extensions/2.0/OMI_audio_emitter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* K. S. Ernest (iFire) Lee, Individual Contributor
* Michael Nisbet, Individual Contributor
* humbletim, Individual Contributor
* Norbert Nopper, UX3D [@UX3DGpuSoftware](https://twitter.com/UX3DGpuSoftware)

## Status

Expand Down Expand Up @@ -43,7 +44,7 @@ Audio emitter objects may be added to 3D nodes for positional audio or to the sc
{
"name": "environment emitter",
"type": "global",
"gain": 1,
"gain": 1.0,
"loop": true,
"playing": true,
"source": 0
Expand All @@ -57,10 +58,10 @@ Audio emitter objects may be added to 3D nodes for positional audio or to the sc
"source": 1,
"coneInnerAngle": 6.283185307179586,
"coneOuterAngle": 6.283185307179586,
"coneOuterGain": 0,
"coneOuterGain": 0.0,
"distanceModel": "inverse",
"maxDistance": 10,
"refDistance": 1,
"maxDistance": 10.0,
"refDistance": 1.0,
"rolloffFactor": 0.8
}
]
Expand All @@ -79,7 +80,7 @@ Audio emitter objects may be added to 3D nodes for positional audio or to the sc
"nodes": [
{
"name": "Duck",
"translation": [1, 2, 3],
"translation": [1.0, 2.0, 3.0],
"extensions": {
"OMI_audio_emitter": {
"audioEmitter": 1
Expand Down Expand Up @@ -128,11 +129,11 @@ When storing audio data in a buffer view, the `mimeType` field must be specified

#### `bufferView`

The index of the bufferView that contains the audio data. Use this instead of the image's uri property.
The index of the bufferView that contains the audio data. Use this instead of the audio source'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.
The audio's MIME type. Required if `bufferView` is defined. Unless specified by another extension, the only supported mimeType is `audio/mpeg`.

#### `uri`

Expand All @@ -150,7 +151,7 @@ The MPEG3 Audio Format is commonly available and freely licensed.

Specifies the audio emitter type.

- `positional` Positional audio emitters
- `positional` Positional audio emitters. Using sound cones, the orientation is `+Z` having the same front side for a [glTF asset](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#coordinate-system-and-units).
- `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`
Expand Down Expand Up @@ -186,11 +187,11 @@ The gain of the audio emitter set when outside the cone defined by the `coneOute
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)`
`1.0 - 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)`
`pow((Math.max(distance, refDistance) / refDistance, -rolloffFactor))`

#### `maxDistance`

Expand Down Expand Up @@ -241,16 +242,16 @@ Audio emitters of type `positional` may be added to nodes using the following sy
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 Audio Rolloff range is `(0.0, +∞)`. The default is `1.0`.

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)`
- linear formula: `1.0 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)`
- inverse formula: `refDistance / (refDistance + rolloffFactor * (Math.max(distance, refDistance) - refDistance))`
- exponential formula: `pow((Math.max(distance, refDistance) / refDistance, -rolloffFactor)`
- exponential formula: `pow((Math.max(distance, refDistance) / refDistance, -rolloffFactor))`

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

### Audio Cone Vizualized
Expand All @@ -274,6 +275,7 @@ Radians are used for rotations matching glTF2.

* Third Room - https://github.com/thirdroom/thirdroom
* Three Object Viewer (WordPress Plugin) - https://wordpress.org/plugins/three-object-viewer/
* UX3D Experimental C++ implementation - https://github.com/ux3d/OMI

## Resources

Expand Down
30 changes: 15 additions & 15 deletions extensions/2.0/OMI_audio_emitter/schema/audioEmitter.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"gain": {
"description": "Unitless multiplier against original source volume for determining emitter loudness.",
"type": "number",
"minimum": 0,
"default": 1
"minimum": 0.0,
"default": 1.0
},
"loop": {
"description": "Whether or not to loop the specified audio clip when finished.",
Expand All @@ -49,61 +49,61 @@
"coneInnerAngle": {
"description": "The angle, in radians, of a cone inside of which there will be no volume reduction.",
"type": "number",
"minimum": 0,
"minimum": 0.0,
"maximum": 6.283185307179586,
"default": 6.283185307179586
},
"coneOuterAngle": {
"description": "The angle, in radians, of a cone outside of which the volume will be reduced to a constant value of`coneOuterGain`.",
"type": "number",
"minimum": 0,
"minimum": 0.0,
"maximum": 6.283185307179586,
"default": 6.283185307179586
},
"coneOuterGain": {
"description": "The gain of the audio emitter set when outside the cone defined by the `coneOuterAngle` property. It is a linear value (not dB).",
"type": "number",
"minimum": 0,
"maximum": 1,
"default": 0
"minimum": 0.0,
"maximum": 1.0,
"default": 0.0
},
"distanceModel": {
"type": "string",
"description": "Specifies the distance model for the audio emitter.",
"anyOf": [
{
"enum": [ "linear" ],
"description": "A linear distance model calculating the gain induced by the distance according to: 1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)"
"description": "A linear distance model calculating the gain induced by the distance according to: 1.0 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)"
},
{
"enum": [ "inverse" ],
"description": "An inverse distance model calculating the gain induced by the distance according to: refDistance / (refDistance + rolloffFactor * (Math.max(distance, refDistance) - refDistance))"
},
{
"enum": [ "exponential" ],
"description": "An exponential distance model calculating the gain induced by the distance according to: pow((Math.max(distance, refDistance) / refDistance, -rolloffFactor)"
"description": "An exponential distance model calculating the gain induced by the distance according to: pow((Math.max(distance, refDistance) / refDistance, -rolloffFactor))"
}
],
"default": "inverse"
},
"maxDistance": {
"description": "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.",
"type": "number",
"minimum": 0,
"minimum": 0.0,
"exclusiveMinimum": true,
"default": 10000
"default": 10000.0
},
"refDistance": {
"description": "A reference distance for reducing volume as the emitter moves further from the listener. For distances less than this, the volume is not reduced.",
"type": "number",
"minimum": 0,
"default": 1
"minimum": 0.0,
"default": 1.0
},
"rolloffFactor": {
"type": "number",
"description": "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.",
"minimum": 0,
"default": 1
"minimum": 0.0,
"default": 1.0
},
"name": { },
"extensions": { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"mimeType": {
"type": "string",
"description": "The audio's MIME type. Required if `bufferView` is defined. Unless specified by another extension, the only supported mimeType is audio/mpeg.",
"description": "The audio's MIME type. Required if `bufferView` is defined. Unless specified by another extension, the only supported mimeType is `audio/mpeg`.",
"anyOf": [
{
"enum": [ "audio/mpeg" ]
Expand All @@ -26,7 +26,7 @@
},
"bufferView": {
"allOf": [ { "$ref": "glTFid.schema.json" } ],
"description": "The index of the bufferView that contains the audio data. Use this instead of the image's uri property."
"description": "The index of the bufferView that contains the audio data. Use this instead of the audio source's uri property."
},
"name": { },
"extensions": { },
Expand Down

0 comments on commit cdb2e08

Please sign in to comment.