[PR #5685] [MERGED] Keep a few sound channels for sounds played to the listener #6432

Closed
opened 2026-11-03 06:20:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5685
Author: @Stink-O
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: sound-channels-for-the-listener


📝 Commits (5)

  • 9fdf206 Keep crater break sounds from silencing sounds played to the player
  • dd658dc Merge main into #5685
  • 19a4e7c feat(extras): the UI sound channel reserve is an extra, off by default
  • 66ac203 refactor(extras): the UI sound reserve's match arms on lines of their own
  • 4070424 Merge main into #5685: uiSoundReserve beside main's splitscreen extra

📊 Changes

5 files changed (+101 additions, -3 deletions)

View changed files

📝 crates/horizon-client-render/src/audio.rs (+9 -0)
📝 crates/horizon-client-render/src/extras.rs (+19 -2)
📝 crates/horizon-client-render/src/sound_engine.rs (+59 -1)
📝 crates/horizon-client/src/game/music.rs (+2 -0)
📝 docs/extras.md (+12 -0)

📄 Description

🤖 Opened by Stink-O's AI agent (Claude Code, Claude Opus 5.5), not by Stink-O personally.

What and why

Fixes #5683. Found while porting Orbital Laser to native hooks (tracking:
#5727), but the problem is general: a big explosion, /fill … destroy or a mod breaking hundreds of blocks near the
player fills all 247 static sound channels, and until those sounds end every new sound fails to start, the pause
menu's clicks included. Vanilla 26.3 behaves the same (Library.acquireChannel returns null when the pool is full).

A new extra, Extras > Sound > "Keep channels for UI sounds" (uiSoundReserve in horizon-extras.txt, off by
default): with it on, positional sounds start only while 16 of the 247 static channels are free, so UI clicks and
other sounds played to the listener (relative, or no attenuation) can still start. With it off nothing changes:
the pool is vanilla's. Below 231 sounds at once nothing changes either way. Streaming sounds are untouched.

  • crates/horizon-client-render/src/sound_engine.rs: SoundEngine.listener_reserve (0, or HEARD_RESERVE = 16),
    checked when a static channel is taken.
  • extras.rs, audio.rs (Audio::set_listener_reserve), game/music.rs (sets it each sound tick from the
    extra), docs/extras.md (the extra's section).

Kind

  • extra: Horizon-only, off by default

Vanilla reference

SoundEngine.play → ChannelAccess.createHandle → Library.acquireChannel (null when the pool is full, and the
play fails). With the extra off Horizon does exactly that.

Other projects' code

None from other projects. The reserve was first written in the author's own fork of Horizon (Stink-O/horizon, MIT,
same license as Horizon): a72b65ea3; the extra is new here.

How it was tested

  • cargo test -p horizon-client-render --lib sound_engine::tests::world_sounds_leave_channels_for_the_listener_only_with_the_extra
    → test result: ok. 1 passed: with the reserve off, 247 positional sounds start and then a UI click fails, as vanilla; with it
    on, 231 start and the click still starts.
  • cargo test -p horizon-client-render --lib extras::tests::everything_is_off_by_default_and_round_trips →
    test result: ok. 1 passed (the new extra is off by default and round-trips through horizon-extras.txt).
  • python3 tools/parity.py sound_engine: not run here. This machine's prepared vanilla data predates the current
    research-lock.json ("Manifest checksum changed"), so the harness refuses it. With the extra off by default the
    harness's 252-sound "Channel pools" script sees vanilla's pool, unchanged from main; CI's run-parity runs it.

For the merge

  • Depends on: nothing. Independent of the rest of #5727's series; merge in any order.
  • Conflicts: it touches sound_engine.rs, audio.rs, extras.rs, game/music.rs and docs/extras.md.
    #5675 (martipops, splitscreen) adds an extra to the same extras.rs. Test-merged both ways onto main, one
    hunk conflicts: Extras::serialize's one-line format string, where each adds a key. Keep both keys
    (uiSoundReserve:{} and splitscreen:{}, with both bool_text arguments). Our match arms sit on lines of
    their own so nothing else meets. Main was merged in on 2026-11-01 (5edb339a7).
  • Verify after merging: the two tests above, and parity with run-parity (sound_engine).
  • Risk: none with the extra off (the default): the reserve is 0. Rollback: git revert -m 1 <merge commit>.
    A saved uiSoundReserve:true line is then ignored, as unknown keys are.

Self-check

pr_ready (Rust 1.99.1, tools/pr_ready.py --quick on DESKTOP-SNGRNA4-LINUX, against origin/main at 5edb339a7, 23 min 1 s)

Check Result
Scope ✅ 5 files, +101 −3
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 511 passed (1 min 35 s)
rustfmt ✅ (19 s)
clippy ✅ (6 min 45 s)
tests: horizon-client, horizon-client-render ✅ 2495 passed (14 min 17 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 364 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 352 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

CI's two clippy commands on Rust 1.99 (cargo clippy --workspace --all-targets -- -D warnings, cargo clippy -p horizon-client --all-targets --no-default-features -- -D warnings): both pass.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5685 **Author:** [@Stink-O](https://github.com/Stink-O) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `sound-channels-for-the-listener` --- ### 📝 Commits (5) - [`9fdf206`](https://github.com/horizon-rust/horizon/commit/9fdf206c4b2ed4b4f74ebb1e616f58e15098fe81) Keep crater break sounds from silencing sounds played to the player - [`dd658dc`](https://github.com/horizon-rust/horizon/commit/dd658dc0b3381a0851966d35cfb7e73672c7584e) Merge main into #5685 - [`19a4e7c`](https://github.com/horizon-rust/horizon/commit/19a4e7c31c50beb2e45c77eb787a118aed1a0b6f) feat(extras): the UI sound channel reserve is an extra, off by default - [`66ac203`](https://github.com/horizon-rust/horizon/commit/66ac20304e4fc9b07f01d25d2f83835714d244e9) refactor(extras): the UI sound reserve's match arms on lines of their own - [`4070424`](https://github.com/horizon-rust/horizon/commit/40704247c732f3bb1bf0a3128e9dceac6a397f93) Merge main into #5685: uiSoundReserve beside main's splitscreen extra ### 📊 Changes **5 files changed** (+101 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/audio.rs` (+9 -0) 📝 `crates/horizon-client-render/src/extras.rs` (+19 -2) 📝 `crates/horizon-client-render/src/sound_engine.rs` (+59 -1) 📝 `crates/horizon-client/src/game/music.rs` (+2 -0) 📝 `docs/extras.md` (+12 -0) </details> ### 📄 Description > 🤖 Opened by Stink-O's AI agent (Claude Code, Claude Opus 5.5), not by Stink-O personally. ## What and why Fixes #5683. Found while porting [Orbital Laser](https://github.com/Stink-O/orbital-laser) to native hooks (tracking: #5727), but the problem is general: a big explosion, `/fill … destroy` or a mod breaking hundreds of blocks near the player fills all 247 static sound channels, and until those sounds end every new sound fails to start, the pause menu's clicks included. Vanilla 26.3 behaves the same (`Library.acquireChannel` returns null when the pool is full). A new extra, **Extras > Sound > "Keep channels for UI sounds"** (`uiSoundReserve` in `horizon-extras.txt`, off by default): with it on, positional sounds start only while 16 of the 247 static channels are free, so UI clicks and other sounds played to the listener (`relative`, or no attenuation) can still start. With it off nothing changes: the pool is vanilla's. Below 231 sounds at once nothing changes either way. Streaming sounds are untouched. - `crates/horizon-client-render/src/sound_engine.rs`: `SoundEngine.listener_reserve` (0, or `HEARD_RESERVE` = 16), checked when a static channel is taken. - `extras.rs`, `audio.rs` (`Audio::set_listener_reserve`), `game/music.rs` (sets it each sound tick from the extra), `docs/extras.md` (the extra's section). ## Kind - [x] extra: Horizon-only, off by default ## Vanilla reference `SoundEngine.play` → `ChannelAccess.createHandle` → `Library.acquireChannel` (null when the pool is full, and the play fails). With the extra off Horizon does exactly that. ## Other projects' code None from other projects. The reserve was first written in the author's own fork of Horizon (Stink-O/horizon, MIT, same license as Horizon): [a72b65ea3](https://github.com/Stink-O/horizon/commit/a72b65ea3); the extra is new here. ## How it was tested - `cargo test -p horizon-client-render --lib sound_engine::tests::world_sounds_leave_channels_for_the_listener_only_with_the_extra` → `test result: ok. 1 passed`: with the reserve off, 247 positional sounds start and then a UI click fails, as vanilla; with it on, 231 start and the click still starts. - `cargo test -p horizon-client-render --lib extras::tests::everything_is_off_by_default_and_round_trips` → `test result: ok. 1 passed` (the new extra is off by default and round-trips through `horizon-extras.txt`). - `python3 tools/parity.py sound_engine`: not run here. This machine's prepared vanilla data predates the current `research-lock.json` ("Manifest checksum changed"), so the harness refuses it. With the extra off by default the harness's 252-sound "Channel pools" script sees vanilla's pool, unchanged from main; CI's `run-parity` runs it. ## For the merge - **Depends on:** nothing. Independent of the rest of #5727's series; merge in any order. - **Conflicts:** it touches `sound_engine.rs`, `audio.rs`, `extras.rs`, `game/music.rs` and `docs/extras.md`. #5675 (martipops, splitscreen) adds an extra to the same `extras.rs`. Test-merged both ways onto main, one hunk conflicts: `Extras::serialize`'s one-line format string, where each adds a key. Keep both keys (`uiSoundReserve:{}` and `splitscreen:{}`, with both `bool_text` arguments). Our match arms sit on lines of their own so nothing else meets. Main was merged in on 2026-11-01 (5edb339a7). - **Verify after merging:** the two tests above, and `parity` with `run-parity` (`sound_engine`). - **Risk:** none with the extra off (the default): the reserve is 0. **Rollback:** `git revert -m 1 <merge commit>`. A saved `uiSoundReserve:true` line is then ignored, as unknown keys are. ## Self-check **pr_ready** (Rust 1.99.1, `tools/pr_ready.py --quick` on DESKTOP-SNGRNA4-LINUX, against origin/main at 5edb339a7, 23 min 1 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +101 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 511 passed (1 min 35 s) | | rustfmt | ✅ (19 s) | | clippy | ✅ (6 min 45 s) | | tests: horizon-client, horizon-client-render | ✅ 2495 passed (14 min 17 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 364 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 352 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | CI's two clippy commands on Rust 1.99 (`cargo clippy --workspace --all-targets -- -D warnings`, `cargo clippy -p horizon-client --all-targets --no-default-features -- -D warnings`): both pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:20:32 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6432
No description provided.