Skip to content

Improve alternate desktop sound playback with shared PCM mixer#11137

Open
Madwand99 wants to merge 3 commits into
Card-Forge:masterfrom
Madwand99:FixAlternateSoundSystem
Open

Improve alternate desktop sound playback with shared PCM mixer#11137
Madwand99 wants to merge 3 commits into
Card-Forge:masterfrom
Madwand99:FixAlternateSoundSystem

Conversation

@Madwand99

Copy link
Copy Markdown
Contributor

Summary

Reworks the desktop “Use Alternate Sound System” path to use a shared PCM mixer instead of opening a new SourceDataLine for every sound effect.

The previous alternate path avoided JavaSound Clip, but each effect still created and opened its own audio line. In bursty cases like dealing cards or auto-tapping lands, that caused irregular timing, overlapping artifacts, and poor rhythm. This change keeps the alternate path Clip-free while making playback much closer to the normal sound system.

Changes

  • Adds a shared alternate sound mixer thread for desktop sound effects.
  • Decodes and caches sound effects as PCM samples.
  • Mixes overlapping effects into one long-lived SourceDataLine.
  • Removes per-sound thread creation from the desktop alternate sound path.
  • Preserves synchronized-sound behavior and total playback caps.
  • Adds slightly wider repeat spacing for short repeated effects:
    • draw.mp3
    • tap.mp3
    • untap.mp3
  • Leaves mobile/libGDX sound paths untouched.
  • Adds no new dependency.

Why

This was motivated by intermittent desktop sound/lockup issues where the normal Clip path appeared to crash inside the Java/PipeWire audio stack. The alternate sound system avoided that path, but sounded noticeably wrong for repeated effects. A shared mixer avoids Clip and avoids per-effect audio-line setup jitter.

Thanks to Codex for help with code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant