Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Lua audio samples silent for specific sound configuration #391

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Flower35
Copy link
Contributor

Lua audio samples (music streams and sound effects) are no longed playing, while the game window has no focus and the config option "Mute When Window Unfocused" is set to True.

This behaves similar to the check in buffer_audio() from src/pc/pc_main.c.

You might still hear a sample that is already playing while the player clicks out of the window, but no more audio samples will be audible as long as the focus is lost.

@Isaac0-dev
Copy link
Collaborator

this looks like it will stop all audio streams and samples without starting them again when you tab back
that would cause some mods to have their music completely stopped, which will sound like a bug.

@AgentXLP
Copy link
Contributor

AgentXLP commented Nov 7, 2024

This just makes it so when audio sample/stream play is called while the window is unfocused, it sets the volume to 0. More efficiently, it could just not be played at all, but this solution still works.
Ideally, the audio would be able to change back and forth in realtime, but that would require either updating the volume every frame, or having it update the audio when the window focus status changes and setup an event for that in the window managers. Maybe that would be something worth looking into.

@Isaac0-dev
Copy link
Collaborator

Isaac0-dev commented Nov 7, 2024

having it update when tabbing in would be best because the audio could be restored to its original volume

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.

3 participants