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 2 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
96 changes: 96 additions & 0 deletions extensions/2.0/OMI_audio_emitter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# OMI_audio_emitter

## Example

```json
{
"extensions": {
"OMI_audio_emitter": {
"audioClips": [
{
"name": "environment",
"sources": [
{
"mimeType": "audio/ogg",
"uri": "./environment.ogg"
},
{
"mimeType": "audio/wav",
"uri": "./environment.wav"
},
{
"mimeType": "audio/mpeg",
"uri": "./environment.mp3"
}
]
robertlong marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "quack",
"sources": [
{
"mimeType": "audio/ogg",
"bufferView": 3
},
{
"mimeType": "audio/wav",
"bufferView": 4
},
{
"mimeType": "audio/mpeg",
"bufferView": 5
}
]
}
],
"audioEmitters": [
{
"name": "environment emitter",
"type": "global",
"volume": 1,
"loop": true,
"autoPlay": true,
"muted": false,
"clip": 0
},
{
"name": "duck emitter",
"type": "positional",
"volume": 0.8,
"loop": false,
"autoPlay": false,
"muted": false,
"clip": 1,
"coneInnerAngle": 360,
"coneOuterAngle": 360,
"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
}
}
}
]
}
```
34 changes: 34 additions & 0 deletions extensions/2.0/OMI_audio_emitter/schema/audio.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "Audio",
"type": "object",
"description": "Audio data used for audio emitters. Audio can be referenced by URI or `bufferView` index. `mimeType` is required.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"uri": {
"type": "string",
"description": "The uri of the image.",
"format": "uriref",
"gltf_detailedDescription": "The uri of the audio. Relative paths are relative to the .gltf file.",
"gltf_uriType": "audio"
},
"mimeType": {
"type": "string",
"description": "The audio's MIME type. Used to determine if the client supports the given audio."
},
"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."
},
"name": { },
"extensions": { },
"extras": { }
},
"oneOf": [
{ "required": [ "uri" ] },
{ "required": [ "bufferView" ] }
],
"required": [
"mimeType"
]
}
22 changes: 22 additions & 0 deletions extensions/2.0/OMI_audio_emitter/schema/audioClip.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "Audio Clip",
"type": "object",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"sources": {
"type": "array",
"items": {
"type": "object",
"$ref": "audio.schema.json"
},
"minItems": 1,
"description": "One or more sources for the client to negotiate using the provided mimetypes. Clients should process sources in order."
},
"extensions": { },
"extras": { }
},
"required": [
"audio"
robertlong marked this conversation as resolved.
Show resolved Hide resolved
]
}
111 changes: 111 additions & 0 deletions extensions/2.0/OMI_audio_emitter/schema/audioEmitter.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "Audio Emitter",
"type": "object",
"description": "A positional or global audio emitter.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"type": {
"type": "string",
"description": "Specifies the audio emitter type.",
"anyOf": [
{
"enum": [ "positional" ],
"description": "Positional audio emitters "
},
{
"enum": [ "global" ],
"description": "Global audio emitters are not affected by the position of audio listeners."
},
{
"type": "string"
}
]
},
"volume": {
"type": "number",
"minimum": 0,
"default": 1
robertlong marked this conversation as resolved.
Show resolved Hide resolved
},
"loop": {
"type": "boolean",
"default": false
},
"autoPlay": {
"type": "boolean",
"default": false
},
"clip": {
"allOf": [
{
"$ref": "glTFid.schema.json"
}
],
"description": "The id of the audio clip referenced by this audio emitter."
},
"coneInnerAngle": {
"type": "number",
"minimum": 0,
"maximum": 360,
"default": 360

Choose a reason for hiding this comment

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

In glTF 2.0 core spec, all angles are in radian. Should we follow it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I second radians.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if I represented this correctly. The maximum is 2PI radians then. Idk how to represent that in JSON schema.

Copy link
Member Author

Choose a reason for hiding this comment

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

Default value should be rounded down at 6 decimal places and maximum value should be rounded up at 6 decimal places to deal with floating point precision.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's also clarify with the Khronos Working Group.

Copy link
Member Author

@robertlong robertlong Sep 1, 2021

Choose a reason for hiding this comment

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

Based on this discussion about the yfov and the punctual spotlight spec. I think we should go with a maximum and minimum value of 6.283185307179586. We can also write in the readme/description that the maximum value is 2 * PI.

This will work just fine in Javascript btw:

Math.PI / 180 * 360 === 6.283185307179586
6.283185307179586 * 180 / Math.PI === 360

Copy link
Member Author

Choose a reason for hiding this comment

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

I've made this change now. I think it should be fine, but could use a second opinion.

},
"coneOuterAngle": {
"type": "number",
"minimum": 0,
"maximum": 360,
"default": 360
},
"coneOuterGain": {
"type": "number",
"minimum": 0,
"maximum": 1,
"default": 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)"
},
{
"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)"
},
{
"type": "string"
robertlong marked this conversation as resolved.
Show resolved Hide resolved
}
],
"default": "inverse"
},
"maxDistance": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true,
"default": 10000
robertlong marked this conversation as resolved.
Show resolved Hide resolved
},
"refDistance": {
"type": "number",
"minimum": 0,
"default": 1
},
"rolloffFactor": {
"type": "number",
"description": "When distanceModel is set to linear, the maximum value is 1.",
"minimum": 0,
"default": 1
},
"name": { },
"extensions": { },
"extras": { }
},
"required": [
"type",
"clip"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "OMI_audio_emitter glTF extension",
"type": "object",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"audioClips": {
"type": "array",
"items": {
"type": "object",
"$ref": "audioClip.schema.json"
},
"minItems": 1
},
"audioEmitters": {
"type": "array",
"items": {
"type": "object",
"$ref": "audioEmitter.schema.json"
},
"minItems": 1
},
"extensions": { },
"extras": { }
},
"required": [
"audio"
robertlong marked this conversation as resolved.
Show resolved Hide resolved
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "OMI_audio_emitter node extension",
"type": "object",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"audioEmitter": {
"allOf": [
{
"$ref": "glTFid.schema.json"
}
],
"description": "The id of the audioEmitter referenced by this node."
},
"extensions": { },
"extras": { }
},
"required": [
"audioEmitter"
]
}