@origingame/engine 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/og.mjs +25 -0
- package/dist/web/origin-engine.d.ts +1233 -0
- package/dist/web/origin-engine.js +8628 -0
- package/dist/web/origin-engine_bg.wasm +0 -0
- package/dist/web/origin-engine_bg.wasm.d.ts +366 -0
- package/dist/web-publish/origin-engine-lanes.js +8509 -0
- package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish/origin-engine.d.ts +1176 -0
- package/dist/web-publish/origin-engine.js +8313 -0
- package/dist/web-publish/origin-engine_bg.wasm +0 -0
- package/dist/web-publish/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/dist/web-publish-2d/origin-engine-lanes.js +8509 -0
- package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine.d.ts +1176 -0
- package/dist/web-publish-2d/origin-engine.js +8313 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish-2d/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/knowledge/README.md +31 -0
- package/knowledge/knowledge.json +13 -0
- package/knowledge/looks/catalogue.json +1871 -0
- package/knowledge/package.json +33 -0
- package/knowledge/rules/platform.json +329 -0
- package/knowledge/scaffold/README.md +27 -0
- package/knowledge/scaffold/distribution.json +48 -0
- package/knowledge/scaffold/origin-engine.json +19 -0
- package/knowledge/scaffold/template/.origin/setup +14 -0
- package/knowledge/scaffold/template/LICENSES.md +23 -0
- package/knowledge/scaffold/template/README.md +37 -0
- package/knowledge/scaffold/template/assets/ai/guard.ogt +48 -0
- package/knowledge/scaffold/template/assets/audio/click.ogt +9 -0
- package/knowledge/scaffold/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
- package/knowledge/scaffold/template/assets/fonts/OFL.txt +93 -0
- package/knowledge/scaffold/template/assets/looks/origin-game.ogt +12 -0
- package/knowledge/scaffold/template/assets/nav/yard.ogt +27 -0
- package/knowledge/scaffold/template/assets/scenes/main.ogt +34 -0
- package/knowledge/scaffold/template/assets/strings/en.ogt +14 -0
- package/knowledge/scaffold/template/assets/textures/stone_n.png.ogt +7 -0
- package/knowledge/scaffold/template/gitattributes +22 -0
- package/knowledge/scaffold/template/package.json +18 -0
- package/knowledge/scaffold/template/project.ogt +25 -0
- package/knowledge/scaffold/template/src/main.ts +246 -0
- package/knowledge/scaffold/template/tests/guard.og.ts +67 -0
- package/knowledge/scaffold/template/tests/smoke.og.ts +43 -0
- package/knowledge/scaffold/template/tsconfig.json +17 -0
- package/knowledge/scripts/lib.ts +203 -0
- package/knowledge/scripts/mount.ts +210 -0
- package/knowledge/scripts/pack.ts +24 -0
- package/knowledge/scripts/scaffold.ts +72 -0
- package/knowledge/scripts/validate.ts +749 -0
- package/knowledge/skills/og-ai/SKILL.md +386 -0
- package/knowledge/skills/og-audio/SKILL.md +191 -0
- package/knowledge/skills/og-build/SKILL.md +330 -0
- package/knowledge/skills/og-core/SKILL.md +285 -0
- package/knowledge/skills/og-feel/SKILL.md +385 -0
- package/knowledge/skills/og-game/SKILL.md +1479 -0
- package/knowledge/skills/og-i18n/SKILL.md +220 -0
- package/knowledge/skills/og-platform-sdk/SKILL.md +199 -0
- package/knowledge/skills/og-taste/SKILL.md +537 -0
- package/knowledge/skills/og-ui/SKILL.md +444 -0
- package/knowledge/wiki/ai.md +627 -0
- package/knowledge/wiki/anim.md +1187 -0
- package/knowledge/wiki/atmosphere.md +636 -0
- package/knowledge/wiki/audio.md +732 -0
- package/knowledge/wiki/camera.md +711 -0
- package/knowledge/wiki/commands.md +357 -0
- package/knowledge/wiki/game.md +220 -0
- package/knowledge/wiki/i18n.md +213 -0
- package/knowledge/wiki/index.md +1027 -0
- package/knowledge/wiki/input.md +1714 -0
- package/knowledge/wiki/load.md +1280 -0
- package/knowledge/wiki/math.md +166 -0
- package/knowledge/wiki/nav.md +1154 -0
- package/knowledge/wiki/physics.md +3142 -0
- package/knowledge/wiki/platform.md +857 -0
- package/knowledge/wiki/probe.md +1692 -0
- package/knowledge/wiki/reflect.md +285 -0
- package/knowledge/wiki/render.md +3511 -0
- package/knowledge/wiki/rng.md +393 -0
- package/knowledge/wiki/stream.md +376 -0
- package/knowledge/wiki/system.md +197 -0
- package/knowledge/wiki/systems.md +43 -0
- package/knowledge/wiki/terrain.md +727 -0
- package/knowledge/wiki/tilemap.md +422 -0
- package/knowledge/wiki/time.md +150 -0
- package/knowledge/wiki/transform.md +230 -0
- package/knowledge/wiki/tween.md +580 -0
- package/knowledge/wiki/ui.md +8000 -0
- package/knowledge/wiki/world.md +909 -0
- package/package.json +68 -4
- package/schema/api.schema.json +29675 -0
- package/shell/README.md +22 -0
- package/shell/brand/README.md +23 -0
- package/shell/brand/icon-192.png +0 -0
- package/shell/brand/icon-512.png +0 -0
- package/shell/brand/mark-on-paper.svg +6 -0
- package/shell/brand/origin-mark.svg +5 -0
- package/shell/brand/origin-motion.css +251 -0
- package/shell/brand/tokens.css +20 -0
- package/shell/brand.ts +132 -0
- package/shell/page.ts +715 -0
- package/shell/platform.ts +203 -0
- package/shell/player.ts +238 -0
- package/shell/shell.css +185 -0
- package/shell/sw.ts +177 -0
- package/shell/transport.ts +515 -0
- package/shell/wire.ts +369 -0
- package/src/e6.ts +69 -0
- package/src/env.d.ts +100 -0
- package/src/generated/abi.ts +980 -0
- package/src/index.ts +193 -0
- package/src/node/audio.ts +86 -0
- package/src/node/build.ts +109 -0
- package/src/node/device.ts +981 -0
- package/src/node/doctor.ts +60 -0
- package/src/node/index.ts +102 -0
- package/src/node/platform.ts +24 -0
- package/src/node/playtest-run.ts +249 -0
- package/src/node/png.ts +130 -0
- package/src/node/polish.ts +976 -0
- package/src/node/run.ts +373 -0
- package/src/node/web-build.ts +808 -0
- package/src/p2.ts +35 -0
- package/src/platform-local.ts +211 -0
- package/src/playtest.ts +131 -0
- package/src/runtime.ts +1509 -0
- package/src/systems/cameras.ts +247 -0
- package/src/ui-kit/bind.ts +141 -0
- package/src/ui-kit/huds.ts +303 -0
- package/src/ui-kit/index.ts +36 -0
- package/src/ui-kit/menus.ts +187 -0
- package/src/ui-kit/settings.ts +131 -0
- package/src/ui-kit/store.ts +222 -0
- package/src/ui-kit/story.ts +89 -0
- package/src/ui-kit/util.ts +106 -0
- package/src/web/a11y.ts +429 -0
- package/src/web/audio-worklet.ts +193 -0
- package/src/web/audio.ts +307 -0
- package/src/web/basis.ts +239 -0
- package/src/web/gamepad.ts +123 -0
- package/src/web/host.ts +166 -0
- package/src/web/input.ts +237 -0
- package/src/web/lanes.ts +21 -0
- package/src/web/play.ts +20 -0
- package/src/web/rpc-ring.ts +110 -0
- package/src/web/settle.ts +122 -0
- package/src/web/shell.ts +643 -0
- package/src/web/text-input.ts +248 -0
- package/src/web/worker.ts +1002 -0
- package/types/bindings.json +13654 -0
- package/types/index.d.ts +20090 -0
- package/vendor/basis/LICENSE +201 -0
- package/vendor/basis/NOTICE +15 -0
- package/vendor/basis/README.md +18 -0
- package/vendor/basis/basis_transcoder.js +19 -0
- package/vendor/basis/basis_transcoder.wasm +0 -0
- package/README.md +0 -3
|
@@ -0,0 +1,732 @@
|
|
|
1
|
+
<!-- Generated from crates/og-api/api.ogt by `og api gen`. Do not edit: `og api check` fails on any difference; change api.ogt and regenerate. -->
|
|
2
|
+
|
|
3
|
+
# The `audio` module
|
|
4
|
+
|
|
5
|
+
Sound: inside the tick, the engine's og.audio system (after the game's systems and physics) turns AudioSource changes into a deterministic, time-stamped command stream; outside the tick the host's mixer renders it (an AudioWorklet on the web, the output device, a capture or a null sink natively).
|
|
6
|
+
|
|
7
|
+
The stream, not the PCM, is world state: snapshots, restore and the world hash cover it, and nothing a sink does reaches the world. Load sounds with og.load.sound; inserting a source plays it, setting `playing` false stops it, and a one-shot sets `playing` back to false when it ends.
|
|
8
|
+
|
|
9
|
+
Spatial gain and pan are computed in the tick from the source's world transform relative to the first AudioListener's (three.js convention: the listener looks down -Z, +X is right; with none, the origin looking down -Z). A source, listener or zone on a child entity is placed at its og.Transform composed down og.Parent, as og.MatrixWorld is: a sound on a child is heard where its parent carries it, a listener under a camera rig hears from the rig.
|
|
10
|
+
|
|
11
|
+
- **TypeScript**: functions are the namespace `og.audio`; components, resources and events are tokens on `og`.
|
|
12
|
+
- **Publish builds**: kept (members may override).
|
|
13
|
+
- **Skill**: `og-audio`, which teaches the module (how much of it to use, and how to prove it).
|
|
14
|
+
- **Index**: [every module and name](index.md).
|
|
15
|
+
|
|
16
|
+
```ogt
|
|
17
|
+
module audio {
|
|
18
|
+
# declarations follow, each quoted below
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
<sub>`api.ogt` line 6408</sub>
|
|
22
|
+
|
|
23
|
+
## Contents
|
|
24
|
+
|
|
25
|
+
| Name | Kind | Summary |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| [`SOUND_FINISHED`](#const-SOUND_FINISHED) | constant | SoundEnded.reason: a one-shot played to its end. |
|
|
28
|
+
| [`SOUND_STOPPED`](#const-SOUND_STOPPED) | constant | SoundEnded.reason: `playing` was set to false. |
|
|
29
|
+
| [`SOUND_REMOVED`](#const-SOUND_REMOVED) | constant | SoundEnded.reason: the AudioSource was removed from a living entity. |
|
|
30
|
+
| [`SOUND_REPLACED`](#const-SOUND_REPLACED) | constant | SoundEnded.reason: `sound` changed while it played. |
|
|
31
|
+
| [`SOUND_CULLED`](#const-SOUND_CULLED) | constant | SoundEnded.reason: more sources played than Audio.maxVoices and this one stood lowest (priority, then volume, then age). |
|
|
32
|
+
| [`AudioBus`](#type-AudioBus) | enum | The bus a source plays on; every bus passes through master. |
|
|
33
|
+
| [`AudioBus()`](#column-AudioBus) | column kind | An AudioBus field: the variant's index. |
|
|
34
|
+
| [`og.AudioSource`](#record-AudioSource) | component | A sound an entity plays. Level-triggered: while `playing` is true it plays (inserting a source plays it), setting it false stops it, and a one-shot that reaches its end sets it back to false and sends og.SoundEnded. |
|
|
35
|
+
| [`og.AudioListener`](#record-AudioListener) | component | Where spatial sources are heard from: the entity's world transform (its og.Transform down og.Parent, so a listener under a camera rig hears from the rig), looking down its -Z with +X to the right. The first listener in query order is used. |
|
|
36
|
+
| [`og.Audio`](#record-Audio) | resource | Bus volumes; master scales every bus. A change ramps over 256 frames in the mixer. |
|
|
37
|
+
| [`og.AudioBusFx`](#record-AudioBusFx) | component | A bus's insert effects: a high- and low-pass (12 dB/octave), a compressor, side-chain ducking by another bus, and a send to the shared reverb, whose return joins master. One entity per bus (the first in query order counts); without one a bus passes straight through. |
|
|
38
|
+
| [`og.ReverbZone`](#record-ReverbZone) | component | A reverb zone: a box (or a sphere) where the shared reverb sounds like this room. While the og.AudioListener is inside, og.audio eases the reverb's room size and damping, and one bus's send to it, towards the zone's; past the volume's surface it fades out linearly over `fade` metres, so walking in through a door the room grows around the listener. |
|
|
39
|
+
| [`og.Music`](#record-Music) | component | A musical clock: tempo, metre and where bar 1 starts. The og.music system (before og.audio) writes the bar and beat and the times of the next beat and bar line every tick, and sends MusicBeat for every beat; an AudioSource whose startAt is nextBar starts on the bar line to the sample, so stems started together stay in step and a stinger lands on the downbeat. |
|
|
40
|
+
| [`og.MusicBeat`](#record-MusicBeat) | event | A beat of a Music clock, sent in the tick whose interval holds it (systems read it the tick after). |
|
|
41
|
+
| [`og.SoundStarted`](#record-SoundStarted) | event | A source started, sent in the tick it happens (systems read it the tick after). |
|
|
42
|
+
| [`og.SoundEnded`](#record-SoundEnded) | event | A sound ended, sent in the tick it happens (systems read it the tick after). |
|
|
43
|
+
| [`og.audio.outputLatency`](#fn-outputLatency) | function | How long after its world time a sample leaves the speaker, as the host reports it: on the web the AudioContext's baseLatency and outputLatency and the worklet ring's buffer, natively the device's latency (cpal's playback less callback instant) and the mixer's buffer; 0 headless (the null and capture sinks are driven to the tick). Host input, written to og.Audio between ticks, so a replay carries it. A rhythm game hears a note at its time plus this: judge a press against the note's time plus the latency, then a calibrated rest (the display, the hand). |
|
|
44
|
+
|
|
45
|
+
## Functions
|
|
46
|
+
|
|
47
|
+
<a id="fn-outputLatency"></a>
|
|
48
|
+
|
|
49
|
+
### `og.audio.outputLatency`
|
|
50
|
+
|
|
51
|
+
How long after its world time a sample leaves the speaker, as the host reports it: on the web the AudioContext's baseLatency and outputLatency and the worklet ring's buffer, natively the device's latency (cpal's playback less callback instant) and the mixer's buffer; 0 headless (the null and capture sinks are driven to the tick). Host input, written to og.Audio between ticks, so a replay carries it. A rhythm game hears a note at its time plus this: judge a press against the note's time plus the latency, then a calibrated rest (the display, the hand).
|
|
52
|
+
|
|
53
|
+
Inside a system og.Audio must be among its reads or writes.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
og.audio.outputLatency(world: World): number
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Parameter | Type | Optional | Doc |
|
|
60
|
+
|---|---|---|---|
|
|
61
|
+
| `world` | `World` | no | The world. |
|
|
62
|
+
|
|
63
|
+
**Returns** `number`: Seconds; 0 headless.
|
|
64
|
+
|
|
65
|
+
Binding symbol `og_audio_output_latency` · publish builds: kept
|
|
66
|
+
|
|
67
|
+
```ogt
|
|
68
|
+
fn outputLatency {
|
|
69
|
+
doc "How long after its world time a sample leaves the speaker, as the host reports it: on the web the AudioContext's baseLatency and outputLatency and the worklet ring's buffer, natively the device's latency (cpal's playback less callback instant) and the mixer's buffer; 0 headless (the null and capture sinks are driven to the tick). Host input, written to og.Audio between ticks, so a replay carries it. A rhythm game hears a note at its time plus this: judge a press against the note's time plus the latency, then a calibrated rest (the display, the hand)."
|
|
70
|
+
doc "Inside a system og.Audio must be among its reads or writes."
|
|
71
|
+
param world World "The world."
|
|
72
|
+
returns f64 "Seconds; 0 headless."
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<sub>`api.ogt` line 6788</sub>
|
|
77
|
+
|
|
78
|
+
## Components, resources and events
|
|
79
|
+
|
|
80
|
+
<a id="record-AudioSource"></a>
|
|
81
|
+
|
|
82
|
+
### `og.AudioSource` (component)
|
|
83
|
+
|
|
84
|
+
A sound an entity plays. Level-triggered: while `playing` is true it plays (inserting a source plays it), setting it false stops it, and a one-shot that reaches its end sets it back to false and sends og.SoundEnded.
|
|
85
|
+
|
|
86
|
+
A one-shot of F frames at rate R and pitch p started in tick S ends in tick S + ceil(F * tickRate / (R * p)) - 1. A despawned entity's voice is silenced without an event.
|
|
87
|
+
|
|
88
|
+
Token `og.AudioSource`, registered under the schema name `og.AudioSource`; its value type is `AudioSource`.
|
|
89
|
+
|
|
90
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
91
|
+
|---|---|---|---|---|---|---|
|
|
92
|
+
| `sound` | `Sound` | `0` | — | — | — | The sound, from og.load.sound; 0 plays nothing. A handle not yet loaded waits and starts on the first tick it is there. |
|
|
93
|
+
| `bus` | `AudioBus` | `"sfx"` | — | — | — | The bus it plays on. |
|
|
94
|
+
| `volume` | `number` | `1` | 0 … 4 | — | tunable | Linear gain. |
|
|
95
|
+
| `pitch` | `number` | `1` | 0.0625 … 16 | — | tunable | Playback rate: 2 is an octave up and half as long. |
|
|
96
|
+
| `pan` | `number` | `0` | -1 … 1 | — | tunable | Stereo position of a non-spatial source, -1 left to 1 right. |
|
|
97
|
+
| `loop` | `boolean` | `false` | — | — | — | Loop between loopStart and loopEnd, seamlessly. |
|
|
98
|
+
| `loopStart` | `number` | `0` | ≥ 0 | `s` | — | Where a loop restarts. |
|
|
99
|
+
| `loopEnd` | `number` | `0` | ≥ 0 | `s` | — | Where a loop wraps; 0 is the sound's end. |
|
|
100
|
+
| `spatial` | `boolean` | `false` | — | — | — | Attenuate and pan by the entity's world transform (its og.Transform down og.Parent) relative to the listener. |
|
|
101
|
+
| `refDistance` | `number` | `1` | ≥ 0 | `m` | tunable | Full volume up to this distance, as Web Audio's PannerNode.refDistance. |
|
|
102
|
+
| `maxDistance` | `number` | `100` | ≥ 0 | `m` | tunable | No quieter past this distance, as Web Audio's PannerNode.maxDistance. |
|
|
103
|
+
| `rolloffFactor` | `number` | `1` | ≥ 0 | — | tunable | How fast volume falls with distance, in Web Audio's inverse model: ref / (ref + rolloff * (clamp(d, ref, max) - ref)). |
|
|
104
|
+
| `playing` | `boolean` | `true` | — | — | — | Plays while true; the engine sets it false when a one-shot ends. |
|
|
105
|
+
| `priority` | `number` | `128` | 0 … 255 | — | — | When more than Audio.maxVoices would play, the lowest priority is stopped first (then the quietest, then the oldest), with SoundEnded reason SOUND_CULLED. |
|
|
106
|
+
| `lowpass` | `number` | `0` | 0 … 20000 | `hz` | tunable | A low-pass filter on this source, its cutoff; 0 is off. |
|
|
107
|
+
| `occlude` | `boolean` | `false` | — | — | — | A spatial source behind a collider (a physics ray to the listener) plays at Audio.occlusionGain through a low-pass at Audio.occlusionCutoff. |
|
|
108
|
+
| `distanceCutoff` | `number` | `0` | 0 … 20000 | `hz` | tunable | A spatial source's low-pass by distance: the cutoff at maxDistance, from 20 kHz at refDistance (log-linear between); 0 is off. |
|
|
109
|
+
| `startAt` | `number` | `0` | ≥ 0 | `s` | — | Starts at this world time (seconds since tick 0), to the sample, even inside a tick; 0 or a time past starts at once. Music.nextBar and Music.nextBeat give musical times. |
|
|
110
|
+
| `startOffset` | `number` | `0` | ≥ 0 | `s` | — | Where in the sound it starts, in seconds of the sound: started at startAt (or at once) from this far in, to the sample and at full gain, so a resumed phrase continues instead of restarting. Past a one-shot's end it plays nothing; a loop wraps into its region. |
|
|
111
|
+
| `fade` | `number` | `0` | 0 … 30 | `s` | tunable | Starts, stops and volume changes ramp over this long: a crossfade is one source stopped and another started with the same fade; 0 is 5 ms. |
|
|
112
|
+
|
|
113
|
+
```ogt
|
|
114
|
+
component AudioSource {
|
|
115
|
+
doc "A sound an entity plays. Level-triggered: while `playing` is true it plays (inserting a source plays it), setting it false stops it, and a one-shot that reaches its end sets it back to false and sends og.SoundEnded."
|
|
116
|
+
doc "A one-shot of F frames at rate R and pitch p started in tick S ends in tick S + ceil(F * tickRate / (R * p)) - 1. A despawned entity's voice is silenced without an event."
|
|
117
|
+
field sound Sound "The sound, from og.load.sound; 0 plays nothing. A handle not yet loaded waits and starts on the first tick it is there."
|
|
118
|
+
field bus AudioBus "The bus it plays on." {
|
|
119
|
+
default sfx
|
|
120
|
+
}
|
|
121
|
+
field volume f32 "Linear gain." {
|
|
122
|
+
default 1
|
|
123
|
+
min 0
|
|
124
|
+
max 4
|
|
125
|
+
tunable true
|
|
126
|
+
}
|
|
127
|
+
field pitch f32 "Playback rate: 2 is an octave up and half as long." {
|
|
128
|
+
default 1
|
|
129
|
+
min 0.0625
|
|
130
|
+
max 16
|
|
131
|
+
tunable true
|
|
132
|
+
}
|
|
133
|
+
field pan f32 "Stereo position of a non-spatial source, -1 left to 1 right." {
|
|
134
|
+
min -1
|
|
135
|
+
max 1
|
|
136
|
+
tunable true
|
|
137
|
+
}
|
|
138
|
+
field loop bool "Loop between loopStart and loopEnd, seamlessly."
|
|
139
|
+
field loopStart f32 "Where a loop restarts." {
|
|
140
|
+
min 0
|
|
141
|
+
unit s
|
|
142
|
+
}
|
|
143
|
+
field loopEnd f32 "Where a loop wraps; 0 is the sound's end." {
|
|
144
|
+
min 0
|
|
145
|
+
unit s
|
|
146
|
+
}
|
|
147
|
+
field spatial bool "Attenuate and pan by the entity's world transform (its og.Transform down og.Parent) relative to the listener."
|
|
148
|
+
field refDistance f32 "Full volume up to this distance, as Web Audio's PannerNode.refDistance." {
|
|
149
|
+
default 1
|
|
150
|
+
min 0
|
|
151
|
+
unit m
|
|
152
|
+
tunable true
|
|
153
|
+
}
|
|
154
|
+
field maxDistance f32 "No quieter past this distance, as Web Audio's PannerNode.maxDistance." {
|
|
155
|
+
default 100
|
|
156
|
+
min 0
|
|
157
|
+
unit m
|
|
158
|
+
tunable true
|
|
159
|
+
}
|
|
160
|
+
field rolloffFactor f32 "How fast volume falls with distance, in Web Audio's inverse model: ref / (ref + rolloff * (clamp(d, ref, max) - ref))." {
|
|
161
|
+
default 1
|
|
162
|
+
min 0
|
|
163
|
+
tunable true
|
|
164
|
+
}
|
|
165
|
+
field playing bool "Plays while true; the engine sets it false when a one-shot ends." {
|
|
166
|
+
default true
|
|
167
|
+
}
|
|
168
|
+
field priority u32 "When more than Audio.maxVoices would play, the lowest priority is stopped first (then the quietest, then the oldest), with SoundEnded reason SOUND_CULLED." {
|
|
169
|
+
default 128
|
|
170
|
+
min 0
|
|
171
|
+
max 255
|
|
172
|
+
}
|
|
173
|
+
field lowpass f32 "A low-pass filter on this source, its cutoff; 0 is off." {
|
|
174
|
+
min 0
|
|
175
|
+
max 20000
|
|
176
|
+
unit hz
|
|
177
|
+
tunable true
|
|
178
|
+
}
|
|
179
|
+
field occlude bool "A spatial source behind a collider (a physics ray to the listener) plays at Audio.occlusionGain through a low-pass at Audio.occlusionCutoff."
|
|
180
|
+
field distanceCutoff f32 "A spatial source's low-pass by distance: the cutoff at maxDistance, from 20 kHz at refDistance (log-linear between); 0 is off." {
|
|
181
|
+
min 0
|
|
182
|
+
max 20000
|
|
183
|
+
unit hz
|
|
184
|
+
tunable true
|
|
185
|
+
}
|
|
186
|
+
field startAt f64 "Starts at this world time (seconds since tick 0), to the sample, even inside a tick; 0 or a time past starts at once. Music.nextBar and Music.nextBeat give musical times." {
|
|
187
|
+
min 0
|
|
188
|
+
unit s
|
|
189
|
+
}
|
|
190
|
+
field startOffset f64 "Where in the sound it starts, in seconds of the sound: started at startAt (or at once) from this far in, to the sample and at full gain, so a resumed phrase continues instead of restarting. Past a one-shot's end it plays nothing; a loop wraps into its region." {
|
|
191
|
+
min 0
|
|
192
|
+
unit s
|
|
193
|
+
}
|
|
194
|
+
field fade f32 "Starts, stops and volume changes ramp over this long: a crossfade is one source stopped and another started with the same fade; 0 is 5 ms." {
|
|
195
|
+
min 0
|
|
196
|
+
max 30
|
|
197
|
+
unit s
|
|
198
|
+
tunable true
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
<sub>`api.ogt` line 6435</sub>
|
|
204
|
+
|
|
205
|
+
<a id="record-AudioListener"></a>
|
|
206
|
+
|
|
207
|
+
### `og.AudioListener` (component)
|
|
208
|
+
|
|
209
|
+
Where spatial sources are heard from: the entity's world transform (its og.Transform down og.Parent, so a listener under a camera rig hears from the rig), looking down its -Z with +X to the right. The first listener in query order is used.
|
|
210
|
+
|
|
211
|
+
Token `og.AudioListener`, registered under the schema name `og.AudioListener`; its value type is `AudioListener`.
|
|
212
|
+
|
|
213
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
214
|
+
|---|---|---|---|---|---|---|
|
|
215
|
+
| `volume` | `number` | `1` | 0 … 4 | — | tunable | A gain on every spatial source this listener hears. |
|
|
216
|
+
|
|
217
|
+
```ogt
|
|
218
|
+
component AudioListener {
|
|
219
|
+
doc "Where spatial sources are heard from: the entity's world transform (its og.Transform down og.Parent, so a listener under a camera rig hears from the rig), looking down its -Z with +X to the right. The first listener in query order is used."
|
|
220
|
+
field volume f32 "A gain on every spatial source this listener hears." {
|
|
221
|
+
default 1
|
|
222
|
+
min 0
|
|
223
|
+
max 4
|
|
224
|
+
tunable true
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
<sub>`api.ogt` line 6523</sub>
|
|
230
|
+
|
|
231
|
+
<a id="record-Audio"></a>
|
|
232
|
+
|
|
233
|
+
### `og.Audio` (resource)
|
|
234
|
+
|
|
235
|
+
Bus volumes; master scales every bus. A change ramps over 256 frames in the mixer.
|
|
236
|
+
|
|
237
|
+
Token `og.Audio`, registered under the schema name `og.Audio`; its value type is `Audio`.
|
|
238
|
+
|
|
239
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
240
|
+
|---|---|---|---|---|---|---|
|
|
241
|
+
| `master` | `number` | `1` | 0 … 2 | — | tunable | Gain of the master bus, applied to every sound. |
|
|
242
|
+
| `music` | `number` | `1` | 0 … 2 | — | tunable | Gain of the music bus. |
|
|
243
|
+
| `sfx` | `number` | `1` | 0 … 2 | — | tunable | Gain of the sfx bus. |
|
|
244
|
+
| `ui` | `number` | `1` | 0 … 2 | — | tunable | Gain of the ui bus. |
|
|
245
|
+
| `maxVoices` | `number` | `32` | 1 … 256 | — | — | The most sources that play at once; past it the lowest AudioSource.priority is stopped (SoundEnded reason SOUND_CULLED). |
|
|
246
|
+
| `occlusionGain` | `number` | `0.35` | 0 … 1 | — | tunable | The gain of an occluded source (AudioSource.occlude). |
|
|
247
|
+
| `occlusionCutoff` | `number` | `900` | 20 … 20000 | `hz` | tunable | The low-pass cutoff of an occluded source. |
|
|
248
|
+
| `reverbRoom` | `number` | `0.6` | 0 … 1 | — | tunable | The shared reverb's room size (the AudioBusFx.reverb sends feed it). |
|
|
249
|
+
| `reverbDamping` | `number` | `0.4` | 0 … 1 | — | tunable | The shared reverb's damping of high frequencies. |
|
|
250
|
+
| `outputLatency` | `number` | `0` | ≥ 0 | `s` | read only | Seconds from a sample's world time to the speaker, as the host reports it (og.audio.outputLatency). |
|
|
251
|
+
|
|
252
|
+
```ogt
|
|
253
|
+
resource Audio {
|
|
254
|
+
doc "Bus volumes; master scales every bus. A change ramps over 256 frames in the mixer."
|
|
255
|
+
field master f32 "Gain of the master bus, applied to every sound." {
|
|
256
|
+
default 1
|
|
257
|
+
min 0
|
|
258
|
+
max 2
|
|
259
|
+
tunable true
|
|
260
|
+
}
|
|
261
|
+
field music f32 "Gain of the music bus." {
|
|
262
|
+
default 1
|
|
263
|
+
min 0
|
|
264
|
+
max 2
|
|
265
|
+
tunable true
|
|
266
|
+
}
|
|
267
|
+
field sfx f32 "Gain of the sfx bus." {
|
|
268
|
+
default 1
|
|
269
|
+
min 0
|
|
270
|
+
max 2
|
|
271
|
+
tunable true
|
|
272
|
+
}
|
|
273
|
+
field ui f32 "Gain of the ui bus." {
|
|
274
|
+
default 1
|
|
275
|
+
min 0
|
|
276
|
+
max 2
|
|
277
|
+
tunable true
|
|
278
|
+
}
|
|
279
|
+
field maxVoices u32 "The most sources that play at once; past it the lowest AudioSource.priority is stopped (SoundEnded reason SOUND_CULLED)." {
|
|
280
|
+
default 32
|
|
281
|
+
min 1
|
|
282
|
+
max 256
|
|
283
|
+
}
|
|
284
|
+
field occlusionGain f32 "The gain of an occluded source (AudioSource.occlude)." {
|
|
285
|
+
default 0.35
|
|
286
|
+
min 0
|
|
287
|
+
max 1
|
|
288
|
+
tunable true
|
|
289
|
+
}
|
|
290
|
+
field occlusionCutoff f32 "The low-pass cutoff of an occluded source." {
|
|
291
|
+
default 900
|
|
292
|
+
min 20
|
|
293
|
+
max 20000
|
|
294
|
+
unit hz
|
|
295
|
+
tunable true
|
|
296
|
+
}
|
|
297
|
+
field reverbRoom f32 "The shared reverb's room size (the AudioBusFx.reverb sends feed it)." {
|
|
298
|
+
default 0.6
|
|
299
|
+
min 0
|
|
300
|
+
max 1
|
|
301
|
+
tunable true
|
|
302
|
+
}
|
|
303
|
+
field reverbDamping f32 "The shared reverb's damping of high frequencies." {
|
|
304
|
+
default 0.4
|
|
305
|
+
min 0
|
|
306
|
+
max 1
|
|
307
|
+
tunable true
|
|
308
|
+
}
|
|
309
|
+
field outputLatency f64 "Seconds from a sample's world time to the speaker, as the host reports it (og.audio.outputLatency)." {
|
|
310
|
+
min 0
|
|
311
|
+
unit s
|
|
312
|
+
readonly true
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
<sub>`api.ogt` line 6533</sub>
|
|
318
|
+
|
|
319
|
+
<a id="record-AudioBusFx"></a>
|
|
320
|
+
|
|
321
|
+
### `og.AudioBusFx` (component)
|
|
322
|
+
|
|
323
|
+
A bus's insert effects: a high- and low-pass (12 dB/octave), a compressor, side-chain ducking by another bus, and a send to the shared reverb, whose return joins master. One entity per bus (the first in query order counts); without one a bus passes straight through.
|
|
324
|
+
|
|
325
|
+
Changes reach the mixer through the command stream, so they are deterministic and in the world hash; the PCM is the mixer's.
|
|
326
|
+
|
|
327
|
+
Token `og.AudioBusFx`, registered under the schema name `og.AudioBusFx`; its value type is `AudioBusFx`.
|
|
328
|
+
|
|
329
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
330
|
+
|---|---|---|---|---|---|---|
|
|
331
|
+
| `bus` | `AudioBus` | `"music"` | — | — | — | The bus these effects are on. |
|
|
332
|
+
| `lowpass` | `number` | `0` | 0 … 20000 | `hz` | tunable | Low-pass cutoff; 0 is off. |
|
|
333
|
+
| `highpass` | `number` | `0` | 0 … 20000 | `hz` | tunable | High-pass cutoff; 0 is off. |
|
|
334
|
+
| `reverb` | `number` | `0` | 0 … 1 | — | tunable | How much of the bus goes to the reverb. |
|
|
335
|
+
| `threshold` | `number` | `0` | -60 … 0 | `db` | tunable | The compressor's threshold; 0 dB is off. |
|
|
336
|
+
| `ratio` | `number` | `4` | 1 … 30 | — | tunable | The compressor's ratio: dB in over the threshold per dB out. |
|
|
337
|
+
| `attack` | `number` | `0.005` | 0 … 1 | `s` | tunable | The compressor's attack. |
|
|
338
|
+
| `release` | `number` | `0.15` | 0 … 3 | `s` | tunable | The compressor's release. |
|
|
339
|
+
| `makeup` | `number` | `0` | -24 … 24 | `db` | tunable | Gain after the compressor. |
|
|
340
|
+
| `duck` | `boolean` | `false` | — | — | — | Turns this bus down while duckBus is loud: music under effects or dialogue. |
|
|
341
|
+
| `duckBus` | `AudioBus` | `"sfx"` | — | — | — | The bus that ducks this one. |
|
|
342
|
+
| `duckDepth` | `number` | `9` | 0 … 60 | `db` | tunable | How far it is turned down. |
|
|
343
|
+
| `duckThreshold` | `number` | `-36` | -80 … 0 | `db` | tunable | How loud the key bus must be. |
|
|
344
|
+
| `duckAttack` | `number` | `0.02` | 0 … 2 | `s` | tunable | How fast it goes down. |
|
|
345
|
+
| `duckRelease` | `number` | `0.4` | 0 … 5 | `s` | tunable | How fast it comes back. |
|
|
346
|
+
|
|
347
|
+
```ogt
|
|
348
|
+
component AudioBusFx {
|
|
349
|
+
doc "A bus's insert effects: a high- and low-pass (12 dB/octave), a compressor, side-chain ducking by another bus, and a send to the shared reverb, whose return joins master. One entity per bus (the first in query order counts); without one a bus passes straight through."
|
|
350
|
+
doc "Changes reach the mixer through the command stream, so they are deterministic and in the world hash; the PCM is the mixer's."
|
|
351
|
+
field bus AudioBus "The bus these effects are on." {
|
|
352
|
+
default music
|
|
353
|
+
}
|
|
354
|
+
field lowpass f32 "Low-pass cutoff; 0 is off." {
|
|
355
|
+
min 0
|
|
356
|
+
max 20000
|
|
357
|
+
unit hz
|
|
358
|
+
tunable true
|
|
359
|
+
}
|
|
360
|
+
field highpass f32 "High-pass cutoff; 0 is off." {
|
|
361
|
+
min 0
|
|
362
|
+
max 20000
|
|
363
|
+
unit hz
|
|
364
|
+
tunable true
|
|
365
|
+
}
|
|
366
|
+
field reverb f32 "How much of the bus goes to the reverb." {
|
|
367
|
+
min 0
|
|
368
|
+
max 1
|
|
369
|
+
tunable true
|
|
370
|
+
}
|
|
371
|
+
field threshold f32 "The compressor's threshold; 0 dB is off." {
|
|
372
|
+
min -60
|
|
373
|
+
max 0
|
|
374
|
+
unit db
|
|
375
|
+
tunable true
|
|
376
|
+
}
|
|
377
|
+
field ratio f32 "The compressor's ratio: dB in over the threshold per dB out." {
|
|
378
|
+
default 4
|
|
379
|
+
min 1
|
|
380
|
+
max 30
|
|
381
|
+
tunable true
|
|
382
|
+
}
|
|
383
|
+
field attack f32 "The compressor's attack." {
|
|
384
|
+
default 0.005
|
|
385
|
+
min 0
|
|
386
|
+
max 1
|
|
387
|
+
unit s
|
|
388
|
+
tunable true
|
|
389
|
+
}
|
|
390
|
+
field release f32 "The compressor's release." {
|
|
391
|
+
default 0.15
|
|
392
|
+
min 0
|
|
393
|
+
max 3
|
|
394
|
+
unit s
|
|
395
|
+
tunable true
|
|
396
|
+
}
|
|
397
|
+
field makeup f32 "Gain after the compressor." {
|
|
398
|
+
min -24
|
|
399
|
+
max 24
|
|
400
|
+
unit db
|
|
401
|
+
tunable true
|
|
402
|
+
}
|
|
403
|
+
field duck bool "Turns this bus down while duckBus is loud: music under effects or dialogue."
|
|
404
|
+
field duckBus AudioBus "The bus that ducks this one." {
|
|
405
|
+
default sfx
|
|
406
|
+
}
|
|
407
|
+
field duckDepth f32 "How far it is turned down." {
|
|
408
|
+
default 9
|
|
409
|
+
min 0
|
|
410
|
+
max 60
|
|
411
|
+
unit db
|
|
412
|
+
tunable true
|
|
413
|
+
}
|
|
414
|
+
field duckThreshold f32 "How loud the key bus must be." {
|
|
415
|
+
default -36
|
|
416
|
+
min -80
|
|
417
|
+
max 0
|
|
418
|
+
unit db
|
|
419
|
+
tunable true
|
|
420
|
+
}
|
|
421
|
+
field duckAttack f32 "How fast it goes down." {
|
|
422
|
+
default 0.02
|
|
423
|
+
min 0
|
|
424
|
+
max 2
|
|
425
|
+
unit s
|
|
426
|
+
tunable true
|
|
427
|
+
}
|
|
428
|
+
field duckRelease f32 "How fast it comes back." {
|
|
429
|
+
default 0.4
|
|
430
|
+
min 0
|
|
431
|
+
max 5
|
|
432
|
+
unit s
|
|
433
|
+
tunable true
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
<sub>`api.ogt` line 6596</sub>
|
|
439
|
+
|
|
440
|
+
<a id="record-ReverbZone"></a>
|
|
441
|
+
|
|
442
|
+
### `og.ReverbZone` (component)
|
|
443
|
+
|
|
444
|
+
A reverb zone: a box (or a sphere) where the shared reverb sounds like this room. While the og.AudioListener is inside, og.audio eases the reverb's room size and damping, and one bus's send to it, towards the zone's; past the volume's surface it fades out linearly over `fade` metres, so walking in through a door the room grows around the listener.
|
|
445
|
+
|
|
446
|
+
Deterministic: each tick the listener's weight in every zone is a function of its position (written to `weight`), the strongest zone wins (ties to the first in query order), and the eased values reach the mixer as fx commands in the stream and the world hash. Audio.reverbRoom, Audio.reverbDamping and the bus's AudioBusFx.reverb stay the open air's: the zone never writes them. The listener and the zone are placed at their world transforms (og.Transform down og.Parent): a zone on a child of a moving room moves with it.
|
|
447
|
+
|
|
448
|
+
Token `og.ReverbZone`, registered under the schema name `og.ReverbZone`; its value type is `ReverbZone`.
|
|
449
|
+
|
|
450
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
451
|
+
|---|---|---|---|---|---|---|
|
|
452
|
+
| `size` | `Vector3` | `{ x: 10, y: 4, z: 10 }` | — | `m` | — | The box's full size along the entity's axes, centred on it (times og.Transform.scale). |
|
|
453
|
+
| `radius` | `number` | `0` | ≥ 0 | `m` | tunable | A sphere of this radius about the entity instead of the box (times the largest of og.Transform.scale); 0 uses the box. |
|
|
454
|
+
| `fade` | `number` | `2` | ≥ 0 | `m` | tunable | How far past the volume's surface the zone fades out, linearly; 0 is a hard edge. |
|
|
455
|
+
| `bus` | `AudioBus` | `"sfx"` | — | — | — | The bus whose reverb send the zone sets. |
|
|
456
|
+
| `send` | `number` | `0.5` | 0 … 1 | — | tunable | That bus's send to the reverb inside (its AudioBusFx.reverb outside). |
|
|
457
|
+
| `room` | `number` | `0.85` | 0 … 1 | — | tunable | The reverb's room size inside (Audio.reverbRoom outside). |
|
|
458
|
+
| `damping` | `number` | `0.3` | 0 … 1 | — | tunable | The reverb's damping of high frequencies inside (Audio.reverbDamping outside). |
|
|
459
|
+
| `weight` | `number` | `0` | 0 … 1 | — | read only | How much of this zone the listener hears, 0 to 1: 1 inside, 0 past the fade (written by og.audio each tick). |
|
|
460
|
+
|
|
461
|
+
```ogt
|
|
462
|
+
component ReverbZone {
|
|
463
|
+
doc "A reverb zone: a box (or a sphere) where the shared reverb sounds like this room. While the og.AudioListener is inside, og.audio eases the reverb's room size and damping, and one bus's send to it, towards the zone's; past the volume's surface it fades out linearly over `fade` metres, so walking in through a door the room grows around the listener."
|
|
464
|
+
doc "Deterministic: each tick the listener's weight in every zone is a function of its position (written to `weight`), the strongest zone wins (ties to the first in query order), and the eased values reach the mixer as fx commands in the stream and the world hash. Audio.reverbRoom, Audio.reverbDamping and the bus's AudioBusFx.reverb stay the open air's: the zone never writes them. The listener and the zone are placed at their world transforms (og.Transform down og.Parent): a zone on a child of a moving room moves with it."
|
|
465
|
+
field size Vector3 "The box's full size along the entity's axes, centred on it (times og.Transform.scale)." {
|
|
466
|
+
default 10 4 10
|
|
467
|
+
unit m
|
|
468
|
+
}
|
|
469
|
+
field radius f32 "A sphere of this radius about the entity instead of the box (times the largest of og.Transform.scale); 0 uses the box." {
|
|
470
|
+
min 0
|
|
471
|
+
unit m
|
|
472
|
+
tunable true
|
|
473
|
+
}
|
|
474
|
+
field fade f32 "How far past the volume's surface the zone fades out, linearly; 0 is a hard edge." {
|
|
475
|
+
default 2
|
|
476
|
+
min 0
|
|
477
|
+
unit m
|
|
478
|
+
tunable true
|
|
479
|
+
}
|
|
480
|
+
field bus AudioBus "The bus whose reverb send the zone sets." {
|
|
481
|
+
default sfx
|
|
482
|
+
}
|
|
483
|
+
field send f32 "That bus's send to the reverb inside (its AudioBusFx.reverb outside)." {
|
|
484
|
+
default 0.5
|
|
485
|
+
min 0
|
|
486
|
+
max 1
|
|
487
|
+
tunable true
|
|
488
|
+
}
|
|
489
|
+
field room f32 "The reverb's room size inside (Audio.reverbRoom outside)." {
|
|
490
|
+
default 0.85
|
|
491
|
+
min 0
|
|
492
|
+
max 1
|
|
493
|
+
tunable true
|
|
494
|
+
}
|
|
495
|
+
field damping f32 "The reverb's damping of high frequencies inside (Audio.reverbDamping outside)." {
|
|
496
|
+
default 0.3
|
|
497
|
+
min 0
|
|
498
|
+
max 1
|
|
499
|
+
tunable true
|
|
500
|
+
}
|
|
501
|
+
field weight f32 "How much of this zone the listener hears, 0 to 1: 1 inside, 0 past the fade (written by og.audio each tick)." {
|
|
502
|
+
min 0
|
|
503
|
+
max 1
|
|
504
|
+
readonly true
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
<sub>`api.ogt` line 6685</sub>
|
|
510
|
+
|
|
511
|
+
<a id="record-Music"></a>
|
|
512
|
+
|
|
513
|
+
### `og.Music` (component)
|
|
514
|
+
|
|
515
|
+
A musical clock: tempo, metre and where bar 1 starts. The og.music system (before og.audio) writes the bar and beat and the times of the next beat and bar line every tick, and sends MusicBeat for every beat; an AudioSource whose startAt is nextBar starts on the bar line to the sample, so stems started together stay in step and a stinger lands on the downbeat.
|
|
516
|
+
|
|
517
|
+
Token `og.Music`, registered under the schema name `og.Music`; its value type is `Music`.
|
|
518
|
+
|
|
519
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
520
|
+
|---|---|---|---|---|---|---|
|
|
521
|
+
| `bpm` | `number` | `120` | 20 … 400 | `bpm` | tunable | Beats per minute. |
|
|
522
|
+
| `beatsPerBar` | `number` | `4` | 1 … 16 | — | — | Beats per bar. |
|
|
523
|
+
| `start` | `number` | `0` | ≥ 0 | `s` | — | The world time of bar 1's first beat. |
|
|
524
|
+
| `bar` | `number` | `0` | — | — | read only | The bar the next tick starts in, from 1 (0 before start; written by og.music). |
|
|
525
|
+
| `beat` | `number` | `0` | — | — | read only | The beat in that bar, from 1 (written by og.music). |
|
|
526
|
+
| `nextBeat` | `number` | `0` | — | `s` | read only | The world time of the next beat from the next tick on (written by og.music). |
|
|
527
|
+
| `nextBar` | `number` | `0` | — | `s` | read only | The world time of the next bar line from the next tick on (written by og.music). |
|
|
528
|
+
|
|
529
|
+
```ogt
|
|
530
|
+
component Music {
|
|
531
|
+
doc "A musical clock: tempo, metre and where bar 1 starts. The og.music system (before og.audio) writes the bar and beat and the times of the next beat and bar line every tick, and sends MusicBeat for every beat; an AudioSource whose startAt is nextBar starts on the bar line to the sample, so stems started together stay in step and a stinger lands on the downbeat."
|
|
532
|
+
field bpm f32 "Beats per minute." {
|
|
533
|
+
default 120
|
|
534
|
+
min 20
|
|
535
|
+
max 400
|
|
536
|
+
unit bpm
|
|
537
|
+
tunable true
|
|
538
|
+
}
|
|
539
|
+
field beatsPerBar u32 "Beats per bar." {
|
|
540
|
+
default 4
|
|
541
|
+
min 1
|
|
542
|
+
max 16
|
|
543
|
+
}
|
|
544
|
+
field start f64 "The world time of bar 1's first beat." {
|
|
545
|
+
min 0
|
|
546
|
+
unit s
|
|
547
|
+
}
|
|
548
|
+
field bar u32 "The bar the next tick starts in, from 1 (0 before start; written by og.music)." {
|
|
549
|
+
readonly true
|
|
550
|
+
}
|
|
551
|
+
field beat u32 "The beat in that bar, from 1 (written by og.music)." {
|
|
552
|
+
readonly true
|
|
553
|
+
}
|
|
554
|
+
field nextBeat f64 "The world time of the next beat from the next tick on (written by og.music)." {
|
|
555
|
+
unit s
|
|
556
|
+
readonly true
|
|
557
|
+
}
|
|
558
|
+
field nextBar f64 "The world time of the next bar line from the next tick on (written by og.music)." {
|
|
559
|
+
unit s
|
|
560
|
+
readonly true
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
<sub>`api.ogt` line 6731</sub>
|
|
566
|
+
|
|
567
|
+
<a id="record-MusicBeat"></a>
|
|
568
|
+
|
|
569
|
+
### `og.MusicBeat` (event)
|
|
570
|
+
|
|
571
|
+
A beat of a Music clock, sent in the tick whose interval holds it (systems read it the tick after).
|
|
572
|
+
|
|
573
|
+
Token `og.MusicBeat`, registered under the schema name `og.MusicBeat`; its value type is `MusicBeat`.
|
|
574
|
+
|
|
575
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
576
|
+
|---|---|---|---|---|---|---|
|
|
577
|
+
| `entity` | `Entity` | `0` | — | — | — | The entity with the Music. |
|
|
578
|
+
| `bar` | `number` | `0` | — | — | — | The bar, from 1. |
|
|
579
|
+
| `beat` | `number` | `0` | — | — | — | The beat in the bar, from 1 (1 is the bar line). |
|
|
580
|
+
| `time` | `number` | `0` | — | — | — | Its world time. |
|
|
581
|
+
|
|
582
|
+
```ogt
|
|
583
|
+
event MusicBeat {
|
|
584
|
+
doc "A beat of a Music clock, sent in the tick whose interval holds it (systems read it the tick after)."
|
|
585
|
+
field entity Entity "The entity with the Music."
|
|
586
|
+
field bar u32 "The bar, from 1."
|
|
587
|
+
field beat u32 "The beat in the bar, from 1 (1 is the bar line)."
|
|
588
|
+
field time f64 "Its world time."
|
|
589
|
+
}
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
<sub>`api.ogt` line 6765</sub>
|
|
593
|
+
|
|
594
|
+
<a id="record-SoundStarted"></a>
|
|
595
|
+
|
|
596
|
+
### `og.SoundStarted` (event)
|
|
597
|
+
|
|
598
|
+
A source started, sent in the tick it happens (systems read it the tick after).
|
|
599
|
+
|
|
600
|
+
Token `og.SoundStarted`, registered under the schema name `og.SoundStarted`; its value type is `SoundStarted`.
|
|
601
|
+
|
|
602
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
603
|
+
|---|---|---|---|---|---|---|
|
|
604
|
+
| `entity` | `Entity` | `0` | — | — | — | The entity whose AudioSource started. |
|
|
605
|
+
| `sound` | `Sound` | `0` | — | — | — | The sound. |
|
|
606
|
+
| `voice` | `number` | `0` | — | — | — | The voice id in the command stream. |
|
|
607
|
+
|
|
608
|
+
```ogt
|
|
609
|
+
event SoundStarted {
|
|
610
|
+
doc "A source started, sent in the tick it happens (systems read it the tick after)."
|
|
611
|
+
field entity Entity "The entity whose AudioSource started."
|
|
612
|
+
field sound Sound "The sound."
|
|
613
|
+
field voice u32 "The voice id in the command stream."
|
|
614
|
+
}
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
<sub>`api.ogt` line 6773</sub>
|
|
618
|
+
|
|
619
|
+
<a id="record-SoundEnded"></a>
|
|
620
|
+
|
|
621
|
+
### `og.SoundEnded` (event)
|
|
622
|
+
|
|
623
|
+
A sound ended, sent in the tick it happens (systems read it the tick after).
|
|
624
|
+
|
|
625
|
+
Token `og.SoundEnded`, registered under the schema name `og.SoundEnded`; its value type is `SoundEnded`.
|
|
626
|
+
|
|
627
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
628
|
+
|---|---|---|---|---|---|---|
|
|
629
|
+
| `entity` | `Entity` | `0` | — | — | — | The entity whose AudioSource ended. |
|
|
630
|
+
| `sound` | `Sound` | `0` | — | — | — | The sound. |
|
|
631
|
+
| `voice` | `number` | `0` | — | — | — | The voice id in the command stream. |
|
|
632
|
+
| `reason` | `number` | `0` | — | — | — | Why: SOUND_FINISHED (0), SOUND_STOPPED (1), SOUND_REMOVED (2), SOUND_REPLACED (3) or SOUND_CULLED (4). |
|
|
633
|
+
|
|
634
|
+
```ogt
|
|
635
|
+
event SoundEnded {
|
|
636
|
+
doc "A sound ended, sent in the tick it happens (systems read it the tick after)."
|
|
637
|
+
field entity Entity "The entity whose AudioSource ended."
|
|
638
|
+
field sound Sound "The sound."
|
|
639
|
+
field voice u32 "The voice id in the command stream."
|
|
640
|
+
field reason u32 "Why: SOUND_FINISHED (0), SOUND_STOPPED (1), SOUND_REMOVED (2), SOUND_REPLACED (3) or SOUND_CULLED (4)."
|
|
641
|
+
}
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
<sub>`api.ogt` line 6780</sub>
|
|
645
|
+
|
|
646
|
+
## Types
|
|
647
|
+
|
|
648
|
+
<a id="type-AudioBus"></a>
|
|
649
|
+
|
|
650
|
+
### `AudioBus` (enum)
|
|
651
|
+
|
|
652
|
+
The bus a source plays on; every bus passes through master.
|
|
653
|
+
|
|
654
|
+
A string: one of the variants below. The zero value is `"master"`.
|
|
655
|
+
|
|
656
|
+
| Variant | Doc |
|
|
657
|
+
|---|---|
|
|
658
|
+
| `"master"` | The master bus: what every bus passes through. |
|
|
659
|
+
| `"music"` | Music. |
|
|
660
|
+
| `"sfx"` | Sound effects. |
|
|
661
|
+
| `"ui"` | Interface sounds. |
|
|
662
|
+
|
|
663
|
+
```ogt
|
|
664
|
+
enum AudioBus {
|
|
665
|
+
doc "The bus a source plays on; every bus passes through master."
|
|
666
|
+
variant master "The master bus: what every bus passes through."
|
|
667
|
+
variant music "Music."
|
|
668
|
+
variant sfx "Sound effects."
|
|
669
|
+
variant ui "Interface sounds."
|
|
670
|
+
}
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
<sub>`api.ogt` line 6420</sub>
|
|
674
|
+
|
|
675
|
+
## Column kinds
|
|
676
|
+
|
|
677
|
+
Each is a factory, `AudioBus(value?, options?)`, that makes one field of a component or resource layout.
|
|
678
|
+
|
|
679
|
+
| Column | Value | Typed array | Stride | Doc |
|
|
680
|
+
|---|---|---|---|---|
|
|
681
|
+
| <a id="column-AudioBus"></a>`AudioBus` | `AudioBus` | `Uint32Array` | 1 | An AudioBus field: the variant's index. |
|
|
682
|
+
|
|
683
|
+
```ogt
|
|
684
|
+
column AudioBus {
|
|
685
|
+
doc "An AudioBus field: the variant's index."
|
|
686
|
+
array Uint32Array
|
|
687
|
+
stride 1
|
|
688
|
+
value AudioBus
|
|
689
|
+
}
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
<sub>`api.ogt` line 6428</sub>
|
|
693
|
+
|
|
694
|
+
## Constants
|
|
695
|
+
|
|
696
|
+
| Constant | Type | Value | Doc |
|
|
697
|
+
|---|---|---|---|
|
|
698
|
+
| <a id="const-SOUND_FINISHED"></a>`SOUND_FINISHED` | `number` | `0` | SoundEnded.reason: a one-shot played to its end. |
|
|
699
|
+
| <a id="const-SOUND_STOPPED"></a>`SOUND_STOPPED` | `number` | `1` | SoundEnded.reason: `playing` was set to false. |
|
|
700
|
+
| <a id="const-SOUND_REMOVED"></a>`SOUND_REMOVED` | `number` | `2` | SoundEnded.reason: the AudioSource was removed from a living entity. |
|
|
701
|
+
| <a id="const-SOUND_REPLACED"></a>`SOUND_REPLACED` | `number` | `3` | SoundEnded.reason: `sound` changed while it played. |
|
|
702
|
+
| <a id="const-SOUND_CULLED"></a>`SOUND_CULLED` | `number` | `4` | SoundEnded.reason: more sources played than Audio.maxVoices and this one stood lowest (priority, then volume, then age). |
|
|
703
|
+
|
|
704
|
+
```ogt
|
|
705
|
+
const SOUND_FINISHED u32 0 "SoundEnded.reason: a one-shot played to its end."
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
<sub>`api.ogt` line 6414</sub>
|
|
709
|
+
|
|
710
|
+
```ogt
|
|
711
|
+
const SOUND_STOPPED u32 1 "SoundEnded.reason: `playing` was set to false."
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
<sub>`api.ogt` line 6415</sub>
|
|
715
|
+
|
|
716
|
+
```ogt
|
|
717
|
+
const SOUND_REMOVED u32 2 "SoundEnded.reason: the AudioSource was removed from a living entity."
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
<sub>`api.ogt` line 6416</sub>
|
|
721
|
+
|
|
722
|
+
```ogt
|
|
723
|
+
const SOUND_REPLACED u32 3 "SoundEnded.reason: `sound` changed while it played."
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
<sub>`api.ogt` line 6417</sub>
|
|
727
|
+
|
|
728
|
+
```ogt
|
|
729
|
+
const SOUND_CULLED u32 4 "SoundEnded.reason: more sources played than Audio.maxVoices and this one stood lowest (priority, then volume, then age)."
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
<sub>`api.ogt` line 6418</sub>
|