Skip to content

replace NAudio with SoundFlow#16

Open
DaBultz wants to merge 8 commits into
Frogworks-Interactive:linux-compatfrom
DaBultz:replace-naudio-with-soundflow
Open

replace NAudio with SoundFlow#16
DaBultz wants to merge 8 commits into
Frogworks-Interactive:linux-compatfrom
DaBultz:replace-naudio-with-soundflow

Conversation

@DaBultz

@DaBultz DaBultz commented May 3, 2026

Copy link
Copy Markdown
Contributor

This is what i have when i replaced NAudio with SoundFlow, i'm not sure how we and if should handle:

  • Cases where no audio devices can be found (or would it be safe for us to assume there would always be 1)
  • Cases where the audio device are changed while the plugin is running (e.g from speakers to headset, vice versa)

I've being testing this during my merc runs yesterday, with no crashes and audio played as i would expect, as i'm unable to test NAudio, i can't tell if it works exactly the same (feedback would be required)

Fixes: #13

@codelastnight

codelastnight commented May 3, 2026

Copy link
Copy Markdown
Contributor

I've made a new branch - can you point the PR to merge into the linux-compat branch instead?. additionally, you should rebase the branch or something to get it up to speed with main

having the audio cut and be not overlap was actually an intentional decision on my end - i thought it would sound funnier that way. but I think now that you bring this up, i think the right solution is to have a checkmark on the settings page to enable/disable overlaping audio.

on your notes:

Cases where no audio devices can be found (or would it be safe for us to assume there would always be 1)

I would at minimum try to handle any exception that would be caused by no audio devices so our plugin doesn't crash the game. additionally, we should add a guard before we use the engine variable during play.

Cases where the audio device are changed while the plugin is running (e.g from speakers to headset, vice versa)

I'm not sure how to do this either. In an ideal world there would be a hook of some kind that can trigger a re-load for the default audio, but in reality I think what this would require is maybe a new button in the settings UI to "reload audio device" or more complex-ly, a drop-down list that users can change to target an audio device.

we can punt this off to focus on getting soundflow tested and working with various OS and audio files. this is a good idea for an improvement and we should include this in future versions.

again, thank you for your contribution and hard work!

@DaBultz

DaBultz commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

I've made a new branch - can you point the PR to merge into the linux-compat branch instead?. additionally, you should rebase the branch or something to get it up to speed with main

Changed it :)

having the audio cut and be not overlap was actually an intentional decision on my end - i thought it would sound funnier that way. but I think now that you bring this up, i think the right solution is to have a checkmark on the settings page to enable/disable overlaping audio.

Aight, i will get that included in this one as well :) as some might like it and others might not :)

I would at minimum try to handle any exception that would be caused by no audio devices so our plugin doesn't crash the game. additionally, we should add a guard before we use the engine variable during play.

I will check if SoundFlow uses exceptions, but it seems i can get the count of devices, so i can always check if there's 0 devices found.

I'm not sure how to do this either. In an ideal world there would be a hook of some kind that can trigger a re-load for the default audio, but in reality I think what this would require is maybe a new button in the settings UI to "reload audio device" or more complex-ly, a drop-down list that users can change to target an audio device.

the "reload audio device", does sound the easiest solution, i don't think we can get notified about devices being connected/disconnected. the reload audio device, could just dispose the SoundManager and recreate it.

@DaBultz DaBultz changed the base branch from main to linux-compat May 3, 2026 10:26
DaBultz added 3 commits May 3, 2026 12:30
# Conflicts:
#	OofPlugin/OofPlugin.csproj
The audio can now overlap if multiple people die in quick succession
@DaBultz DaBultz force-pushed the replace-naudio-with-soundflow branch from 478fe48 to b26dcfc Compare May 3, 2026 15:29
DaBultz added 4 commits May 3, 2026 17:29
now we keep track of all active players, instead of only 1. all
operations modifying the activePlayers is done via a Lock, to ensure
multiple tasks doesn't modify the list at the same time
Reintiialize/Initializing the audio device, will first safely dispose
the old one, before attempting to make a new one.
@DaBultz

DaBultz commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

I've managed to get it all, not sure how the config window should've looked like, attached a screenshot of the config window, overlapped audio is disabled by default.

image

Incase the initilized fails, this should prevent crashes from
happending, when it attempts to play an audio/stop one.

There might be a better way of handling this
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.

Game crashes when sound tries to play sometimes on Linux

2 participants