Skip to content

Document audio device listing and selection APIs - #20

Merged
JamieW105 merged 3 commits into
mainfrom
feat/audio-device-selection
Oct 11, 2026
Merged

JamieW105 merged 3 commits into
mainfrom
feat/audio-device-selection

Conversation

@JamieW105

@JamieW105 JamieW105 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Document Audio.get_output_devices, get_input_devices, set_output_device, and set_input_device in all scripting languages. Explain Windows support, device record/ID lifetimes, default selection, output switching, failure handling, and the current lack of microphone capture. Update the published API index and navigation description.

Validation: production build, lint with zero warnings, TypeScript, security audit (zero vulnerabilities), seven documentation tests, and API example checks passed.

Companion engine implementation: Rustic-Game-Engine/engine#28

@JamieW105 JamieW105 added area:website Documentation website type:docs Documentation changes labels Oct 11, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T08:31:07.292258Z 5286581 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@JamieW105 JamieW105 self-assigned this Oct 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba5a891555

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +156 to +157
- `Audio.get_output_devices() / get_input_devices()`
- `Audio.set_output_device(id = null) / set_input_device(id = null)`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add generated examples for the new device calls

These additions make the required npm run check:api-examples CI step fail: scripts/check-api-examples.mjs extracts qualified calls from this section, but the audio entries in lib/api-example-data.json contain neither Audio.get_output_devices nor Audio.set_output_device, producing No example for published call audio/Audio.get_output_devices. Add all four device APIs to the generated per-language examples so the published reference remains complete and the quality workflow can pass.

Useful? React with 👍 / 👎.


- Provide assets/music.ogg before Play. The voice fades in over two seconds, starts fading out at five seconds and stops at six.
- Windows player output uses the default audio device. Other platforms currently mix PCM headlessly, so successful playback may produce no device sound.
- Windows player output starts on the default audio device; `Audio.set_output_device` can change it. Other platforms currently mix PCM headlessly, so successful playback may produce no device sound.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the playback guide for switched outputs

When a script calls Audio.set_output_device, this new text correctly says playback can leave the system default, but the separately published docs/Scripting/gameplayActions/audio.md guide still states at lines 41–42 that Windows output feeds the default audio device. Update that guide as part of this change so users do not receive contradictory routing behavior depending on which audio page they read.

Useful? React with 👍 / 👎.

@JamieW105
JamieW105 merged commit 72bad7f into main Oct 11, 2026
1 check passed
@JamieW105
JamieW105 deleted the feat/audio-device-selection branch October 11, 2026 08:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5286581cd7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +156 to +157
- `Audio.get_output_devices() / get_input_devices()`
- `Audio.set_output_device(id = null) / set_input_device(id = null)`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Register the device methods in the API reference

These calls are added to the Markdown but not to the audio category in lib/api-reference.ts. Because docGroups converts api/audio to an api-category: source and buildApiCategoryMarkdown renders that route solely from apiCategories, the entire new device section and all four methods are absent from the published /docs/api/audio page, per-call routes, navigation, and search. Independently of adding the generated language examples, add the four signatures and the renderer metadata needed for their call pages.

Useful? React with 👍 / 👎.

Comment thread lib/docs-catalog.ts
{ slug: "api/physics-actions/queries", title: "Physics queries", description: "Find primitive colliders with raycasts, sphere casts and overlaps.", source: "docs/Scripting/API/physics-actions/queries.md", parent: "api/physics-actions" },
{ slug: "api/physics-actions/forces", title: "Physics forces", description: "Apply forces, impulses and velocity changes to simulated bodies.", source: "docs/Scripting/API/physics-actions/forces.md", parent: "api/physics-actions" },
{ slug: "api/effects", title: "Effects", description: "Fade, flash, shake and pulse entity properties with shared easing.", source: "docs/Scripting/API/effects.md" },
{ slug: "api/audio", title: "Audio", description: "List and select Windows audio devices, load reusable audio in Lua/Luau, and play and fade WAV, MP3, AAC, FLAC, and OGG voices.", source: "docs/Scripting/API/audio.md" },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove the duplicate Audio catalog entry

Adding a second entry with the same api/audio slug causes docGroups to expand the Audio category and all of its child calls twice. The published sidebar therefore renders duplicate Audio trees with duplicate React keys, the search index contains duplicate results, and pagination/static parameters repeat the same routes; update the existing entry's description instead of inserting another entry.

AGENTS.md reference: AGENTS.md:L3-L4

Useful? React with 👍 / 👎.

Comment on lines +106 to +108
- `Audio.set_input_device(id)` validates and retains the scene's selected input
device. **Microphone recording/capture is not implemented**, so this call does
not produce microphone samples or route microphone sound to playback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Qualify the claim that microphone capture is unavailable

For Windows Lua/Luau users, this unqualified statement says microphone recording and capture are not implemented, but the same page later documents working microphone recording via startRecording(..., {source = "microphone"}) and live capture via startHotMic(). Clarify that set_input_device does not itself start capture, or that the selected ID is not yet consumed by those APIs, rather than denying the documented capture functionality.

AGENTS.md reference: AGENTS.md:L3-L6

Useful? React with 👍 / 👎.

Comment on lines +149 to +151
Unknown/stale IDs, IDs from the other direction, unavailable devices, missing
system defaults and native driver failures raise a script error. A non-string
argument also raises an error. Check the Console; list devices again after

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exempt null from the invalid-argument warning

When callers reset either selection to the current system default, the preceding API instructions explicitly require null (or its language equivalent), but this blanket statement says every non-string argument raises an error. Since null is not a string, this contradicts the documented reset path; qualify the failure case as a non-string, non-null argument.

Useful? React with 👍 / 👎.

JamieW105 added a commit to Rustic-Game-Engine/engine that referenced this pull request Oct 11, 2026
Scripts can now list and choose audio devices through
`Audio.get_output_devices()`, `get_input_devices()`,
`set_output_device(id)`, and `set_input_device(id)` in all language
bindings. Lists return opaque IDs and names; passing null chooses the
system default.

Windows output switching opens the replacement stream before dropping
the current stream, preserving playback on failure. Input selection
validates and retains a device; microphone capture is not implemented.
Headless platforms return empty lists and report unavailable selection.
IDs are scene-local snapshots and must be refreshed after another
enumeration of the same direction.

Companion website documentation:
Rustic-Game-Engine/docs#20

Validation:
- 96 engine-play and engine-scripting tests passed; targeted device
tests rerun after the final C parser adjustment.
- Formatting and Clippy for both changed crates passed with warnings
denied.
- Windows native audio module cross-target check and Clippy passed
against rodio 0.21.1/cpal 0.16.0.
- C17 transport test (including escaped Unicode and result lifetime),
C++20 compilation, JavaScript syntax and Python compilation passed.
- Website build, lint, TypeScript, security audit, documentation tests
and API example checks passed.
- Windows installer build is pending in this PR's CI; local execution
requires Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:website Documentation website type:docs Documentation changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants