Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(audio): the built-in buses are declared once, and the backend says what it can do

esengine3c63b51a38c6
diff --git a/desktop b/desktop
index a51eeba6c..6a3703ab2 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit a51eeba6c9596169fbe25f05374d1f268a26f9e0
+Subproject commit 6a3703ab2b8c050d575e032562f8b96ef50696e2
diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.json
index 1820faaa1..7f1c64bec 100644
--- a/docs/astro/src/data/apiStability.generated.json
+++ b/docs/astro/src/data/apiStability.generated.json
@@ -3,10 +3,10 @@
"counts": {
"public": 113,
"beta": 91,
- "experimental": 1797,
+ "experimental": 1799,
"deprecated": 3
},
- "total": 2001,
+ "total": 2003,
"subsystems": [
{
"id": "ecs",
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index b56e903b6..02614d23e 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 84 beta · 1633 experimental · 3 deprecated
+Symbols: 113 public · 84 beta · 1635 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
@@ -984,6 +984,7 @@ getMusicVolume: () => number
getSFXVolume: () => number
getSpectrum: (out: Uint8Array) => boolean
getUIVolume: () => number
+hasMixerGraph: () => boolean
invalidateBuffer: (url: string) => boolean
isBusMuted: (busName: string) => boolean
maxVoices: number
@@ -1200,6 +1201,11 @@ type: "audio"
(...bindings: Binding[]) => ActionDef
```
+## BUILTIN_AUDIO_BUSES — const @experimental
+```
+readonly [{ readonly name: "master"; readonly parent: null; readonly volume: 1; }, { readonly name: "music"; readonly parent: "master"; readonly volume: 0.8; }, { readonly name: "sfx"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "ui"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "voice"; readonly parent: "master"; readonly volume: 1; }]
+```
+
## BUILTIN_MESH_TEMPLATES — const @experimental
```
readonly BuiltinMeshTemplate[]
@@ -10571,6 +10577,11 @@ BtPlugin
(asset: TilesetAsset): WangIndices
```
+## builtinBusVolume — function @experimental
+```
+(name: string): number | null
+```
+
## builtinMeshTemplate — function @experimental
```
(ref: string): BuiltinMeshTemplate | undefined
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 8aa856ad8..9855df276 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.native
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 89 beta · 1652 experimental · 3 deprecated
+Symbols: 113 public · 89 beta · 1654 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
@@ -984,6 +984,7 @@ getMusicVolume: () => number
getSFXVolume: () => number
getSpectrum: (out: Uint8Array) => boolean
getUIVolume: () => number
+hasMixerGraph: () => boolean
invalidateBuffer: (url: string) => boolean
isBusMuted: (busName: string) => boolean
maxVoices: number
@@ -1200,6 +1201,11 @@ type: "audio"
(...bindings: Binding[]) => ActionDef
```
+## BUILTIN_AUDIO_BUSES — const @experimental
+```
+readonly [{ readonly name: "master"; readonly parent: null; readonly volume: 1; }, { readonly name: "music"; readonly parent: "master"; readonly volume: 0.8; }, { readonly name: "sfx"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "ui"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "voice"; readonly parent: "master"; readonly volume: 1; }]
+```
+
## BUILTIN_MESH_TEMPLATES — const @experimental
```
readonly BuiltinMeshTemplate[]
@@ -10779,6 +10785,11 @@ BtPlugin
(asset: TilesetAsset): WangIndices
```
+## builtinBusVolume — function @experimental
+```
+(name: string): number | null
+```
+
## builtinMeshTemplate — function @experimental
```
(ref: string): BuiltinMeshTemplate | undefined
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index e113086db..faba22f0f 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.node
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 86 beta · 1632 experimental · 3 deprecated
+Symbols: 113 public · 86 beta · 1634 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -979,6 +979,7 @@ getMusicVolume: () => number
getSFXVolume: () => number
getSpectrum: (out: Uint8Array) => boolean
getUIVolume: () => number
+hasMixerGraph: () => boolean
invalidateBuffer: (url: string) => boolean
isBusMuted: (busName: string) => boolean
maxVoices: number
@@ -1195,6 +1196,11 @@ type: "audio"
(...bindings: Binding[]) => ActionDef
```
+## BUILTIN_AUDIO_BUSES — const @experimental
+```
+readonly [{ readonly name: "master"; readonly parent: null; readonly volume: 1; }, { readonly name: "music"; readonly parent: "master"; readonly volume: 0.8; }, { readonly name: "sfx"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "ui"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "voice"; readonly parent: "master"; readonly volume: 1; }]
+```
+
## BUILTIN_MESH_TEMPLATES — const @experimental
```
readonly BuiltinMeshTemplate[]
@@ -10566,6 +10572,11 @@ BtPlugin
(asset: TilesetAsset): WangIndices
```
+## builtinBusVolume — function @experimental
+```
+(name: string): number | null
+```
+
## builtinMeshTemplate — function @experimental
```
(ref: string): BuiltinMeshTemplate | undefined
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 75baf97c7..ceaaec363 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/minigame
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 84 beta · 1654 experimental · 3 deprecated
+Symbols: 113 public · 84 beta · 1656 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -979,6 +979,7 @@ getMusicVolume: () => number
getSFXVolume: () => number
getSpectrum: (out: Uint8Array) => boolean
getUIVolume: () => number
+hasMixerGraph: () => boolean
invalidateBuffer: (url: string) => boolean
isBusMuted: (busName: string) => boolean
maxVoices: number
@@ -1195,6 +1196,11 @@ type: "audio"
(...bindings: Binding[]) => ActionDef
```
+## BUILTIN_AUDIO_BUSES — const @experimental
+```
+readonly [{ readonly name: "master"; readonly parent: null; readonly volume: 1; }, { readonly name: "music"; readonly parent: "master"; readonly volume: 0.8; }, { readonly name: "sfx"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "ui"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "voice"; readonly parent: "master"; readonly volume: 1; }]
+```
+
## BUILTIN_MESH_TEMPLATES — const @experimental
```
readonly BuiltinMeshTemplate[]
@@ -10818,6 +10824,11 @@ BtPlugin
(asset: TilesetAsset): WangIndices
```
+## builtinBusVolume — function @experimental
+```
+(name: string): number | null
+```
+
## builtinMeshTemplate — function @experimental
```
(ref: string): BuiltinMeshTemplate | undefined
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 7e304f59f..edd2492dc 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/wechat
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 84 beta · 1644 experimental · 3 deprecated
+Symbols: 113 public · 84 beta · 1646 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -979,6 +979,7 @@ getMusicVolume: () => number
getSFXVolume: () => number
getSpectrum: (out: Uint8Array) => boolean
getUIVolume: () => number
+hasMixerGraph: () => boolean
invalidateBuffer: (url: string) => boolean
isBusMuted: (busName: string) => boolean
maxVoices: number
@@ -1195,6 +1196,11 @@ type: "audio"
(...bindings: Binding[]) => ActionDef
```
+## BUILTIN_AUDIO_BUSES — const @experimental
+```
+readonly [{ readonly name: "master"; readonly parent: null; readonly volume: 1; }, { readonly name: "music"; readonly parent: "master"; readonly volume: 0.8; }, { readonly name: "sfx"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "ui"; readonly parent: "master"; readonly volume: 1; }, { readonly name: "voice"; readonly parent: "master"; readonly volume: 1; }]
+```
+
## BUILTIN_MESH_TEMPLATES — const @experimental
```
readonly BuiltinMeshTemplate[]
@@ -10594,6 +10600,11 @@ BtPlugin
(asset: TilesetAsset): WangIndices
```
+## builtinBusVolume — function @experimental
+```
+(name: string): number | null
+```
+
## builtinMeshTemplate — function @experimental
```
(ref: string): BuiltinMeshTemplate | undefined
diff --git a/sdk/src/audio/Audio.ts b/sdk/src/audio/Audio.ts
index dc23110b8..6b9280c42 100644
--- a/sdk/src/audio/Audio.ts
+++ b/sdk/src/audio/Audio.ts
@@ -626,6 +626,18 @@ export class AudioAPI {
}
}
+ /**
+ * Whether this backend has a mixer graph at all. @experimental
+ *
+ * The fact behind every `false` the bus calls below return, reported once so a
+ * reader does not have to infer a capability from a failed write. Without one,
+ * {@link applyAudioProjectConfig} applies `maxVoices` and stops before the bus
+ * list — so an authored mixer is not partly applied, it is not applied.
+ */
+ hasMixerGraph(): boolean {
+ return this.mixer_ !== null;
+ }
+
/** Ensure a named bus exists (creating it under `parent` ?? master).
* False on backends without a mixer graph. */
ensureBus(name: string, parent?: string): boolean {
diff --git a/sdk/src/audio/AudioMixer.ts b/sdk/src/audio/AudioMixer.ts
index dd4efbd50..3abd3f00c 100644
--- a/sdk/src/audio/AudioMixer.ts
+++ b/sdk/src/audio/AudioMixer.ts
@@ -32,7 +32,27 @@ interface DuckState {
data: Uint8Array;
}
-const DEFAULT_MUSIC_VOLUME = 0.8;
+/**
+ * The buses every mixer starts with, their parent, and what each rests at.
+ *
+ * Declared because a second reader needs it: an editor showing a project's
+ * overrides has to know what an override is a change FROM, and a copy of these
+ * numbers there would be a second author for a runtime fact.
+ */
+export const BUILTIN_AUDIO_BUSES = [
+ { name: 'master', parent: null, volume: 1.0 },
+ { name: 'music', parent: 'master', volume: 0.8 },
+ { name: 'sfx', parent: 'master', volume: 1.0 },
+ { name: 'ui', parent: 'master', volume: 1.0 },
+ { name: 'voice', parent: 'master', volume: 1.0 },
+] as const satisfies ReadonlyArray<{ name: string; parent: string | null; volume: number }>;
+
+/** A built-in bus's resting volume, or null when `name` is not one of them. */
+export function builtinBusVolume(name: string): number | null {
+ return BUILTIN_AUDIO_BUSES.find((b) => b.name === name)?.volume ?? null;
+}
+
+const volumeOf = (name: string) => builtinBusVolume(name) ?? 1.0;
export class AudioMixer {
readonly master: AudioBus;
@@ -47,19 +67,19 @@ export class AudioMixer {
constructor(context: AudioContext, config: AudioMixerConfig = {}) {
this.context_ = context;
- this.master = new AudioBus(context, { name: 'master', volume: config.masterVolume ?? 1.0 });
+ this.master = new AudioBus(context, { name: 'master', volume: config.masterVolume ?? volumeOf('master') });
this.master.connect(context.destination);
- this.music = new AudioBus(context, { name: 'music', volume: config.musicVolume ?? DEFAULT_MUSIC_VOLUME });
+ this.music = new AudioBus(context, { name: 'music', volume: config.musicVolume ?? volumeOf('music') });
this.master.addChild(this.music);
- this.sfx = new AudioBus(context, { name: 'sfx', volume: config.sfxVolume ?? 1.0 });
+ this.sfx = new AudioBus(context, { name: 'sfx', volume: config.sfxVolume ?? volumeOf('sfx') });
this.master.addChild(this.sfx);
- this.ui = new AudioBus(context, { name: 'ui', volume: config.uiVolume ?? 1.0 });
+ this.ui = new AudioBus(context, { name: 'ui', volume: config.uiVolume ?? volumeOf('ui') });
this.master.addChild(this.ui);
- this.voice = new AudioBus(context, { name: 'voice', volume: config.voiceVolume ?? 1.0 });
+ this.voice = new AudioBus(context, { name: 'voice', volume: config.voiceVolume ?? volumeOf('voice') });
this.master.addChild(this.voice);
this.buses_.set('master', this.master);
diff --git a/sdk/src/audio/index.ts b/sdk/src/audio/index.ts
index 549215683..eac178054 100644
--- a/sdk/src/audio/index.ts
+++ b/sdk/src/audio/index.ts
@@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
export { Audio, AudioAPI, type AudioBufferStats } from './Audio';
export { AudioBus, type AudioBusConfig } from './AudioBus';
-export { AudioMixer, type AudioMixerConfig, type BusDuckRule } from './AudioMixer';
+export { AudioMixer, BUILTIN_AUDIO_BUSES, builtinBusVolume, type AudioMixerConfig, type BusDuckRule } from './AudioMixer';
export {
buildEffectNodes, makeImpulseResponse, parseBusEffects,
type BusEffectDef, type FilterEffectDef, type ReverbEffectDef, type CompressorEffectDef,
diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.ts
index 5a8102744..10c483bdc 100644
--- a/sdk/src/core-content.ts
+++ b/sdk/src/core-content.ts
@@ -505,6 +505,8 @@ export {
AudioListener,
AudioBus,
AudioMixer,
+ BUILTIN_AUDIO_BUSES,
+ builtinBusVolume,
AudioPool,
parseBusEffects,
parseAudioProjectConfig,
diff --git a/tools/check-mutator-parity.mjs b/tools/check-mutator-parity.mjs
index ec75f18f6..237c9c6cc 100644
--- a/tools/check-mutator-parity.mjs
+++ b/tools/check-mutator-parity.mjs
@@ -50,8 +50,6 @@ const REACHED_VIA = {
* have without becoming a place to put the next one.
*/
const OWED = {
- setAudio: 'bus volumes, effects and duck rules ship in every build and there is no Mixer panel '
- + 'and no project.audio.* row — Audio Authoring v1',
setSpineVersion: 'which Spine runtime the project bundles, a size and compatibility decision with '
+ 'only a read-only diagnostics line in the UI',
};
diff --git a/tools/check-project-settings.mjs b/tools/check-project-settings.mjs
index cfb70973e..bd17dcb04 100644
--- a/tools/check-project-settings.mjs
+++ b/tools/check-project-settings.mjs
@@ -31,7 +31,10 @@
* asked whether a human could reach it at all. So it answers a different
* question, and it has its own vocabulary:
*
- * ui a row in the settings registry — the id is named and checked
+ * ui a row in the settings registry — the id is named and checked. That a
+ * row EXISTS, not that it writes: a control bound to nothing but React
+ * state passes here and fails check-mutator-parity, which is the half
+ * that asks whether a person's edit reaches the project
* manual deliberately manifest-only (advanced, or edited as a file), + why
* internal not creator-authored: derived, or a machine's business, + why
* owed creator-facing, reachable from no editor surface. Debt, recorded
@@ -122,11 +125,7 @@ const AUTHORING = {
steamAppId: { ui: 'project.packaging.desktop.steam.appId' },
physicsEnabled: { ui: 'project.physics.enabled' },
physicsConfig: { ui: ['project.physics.gravityX', 'project.physics.gravityY', 'project.physics.fixedTimestep'] },
- audioConfig: {
- owed: 'buses, effects and duck rules are forwarded to Play and shipped, and the only '
- + 'door into them is the automation surface (setSettings.audio) — ProjectStore.setAudio '
- + 'has no human caller, so a person authors the mixer by editing project.esproject',
- },
+ audioConfig: { ui: ['project.audio.maxVoices', 'project.audio.buses', 'project.audio.effects'] },
uiTheme: { ui: 'project.ui.theme' },
uiThemeColors: { ui: 'project.ui.color.' },
ySortLayers: { ui: 'project.rendering.ySortLayers' },
diff --git a/tools/lib/runtimeDecisions.mjs b/tools/lib/runtimeDecisions.mjs
index 22fdef75d..5bdd6d936 100644
--- a/tools/lib/runtimeDecisions.mjs
+++ b/tools/lib/runtimeDecisions.mjs
@@ -142,11 +142,7 @@ export const DECISIONS = [
kind: 'agent-parity',
owner: { path: 'desktop/src/project/ProjectStore.ts', probe: /async setAudio/ },
runtime: { has: true, cite: { path: 'pipeline/src/project/runtimeConfig.ts', probe: /audioConfig/ } },
- editor: {
- has: false,
- owed: 'setAudio has one caller and it is the automation facade; there is no Mixer panel and no '
- + 'project.audio.* settings row, so a person edits project.esproject by hand',
- },
+ editor: { has: true, cite: { path: 'desktop/src/settings/projectSettings.ts', probe: /'project\.audio\.buses'/ } },
agent: { has: true, cite: { path: 'desktop/src/main.tsx', probe: /audio: \(v\) => ProjectStore\.setAudio/ } },
},
];