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

Fix muffled audio/low quality audio for Windows #15536

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
</section>
<assets path='art/readme.txt' rename='do NOT readme.txt' />

<!-- OpenAL config -->
<section if="desktop">
<assets path="alsoft.txt" rename="plugins/alsoft.ini" type="text" if="windows"/>
<assets path="alsoft.txt" rename="plugins/alsoft.conf" type="text" unless="windows"/>
</section>

<!-- _______________________________ Libraries ______________________________ -->

<haxelib name="flixel" />
Expand Down
14 changes: 14 additions & 0 deletions alsoft.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[general]
sample-type=float32
stereo-mode=speakers
stereo-encoding=panpot
hrtf=false
cf_level=0
resampler=fast_bsinc24
front-stablizer=false
output-limiter=false
volume-adjust=0
[decoder]
hq-mode=false
distance-comp=false
nfc=false
4 changes: 4 additions & 0 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import states.TitleState;
import lime.graphics.Image;
#end

#if desktop
import backend.ALSoftConfig; // Just to make sure DCE doesn't remove this, since it's not directly referenced anywhere else.
#end

//crash handler stuff
#if CRASH_HANDLER
import openfl.events.UncaughtErrorEvent;
Expand Down
29 changes: 29 additions & 0 deletions source/backend/ALSoftConfig.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package backend;

import haxe.io.Path;

/*
A class that simply points OpenALSoft to a custom configuration file when the game starts up.

The config overrides a few global OpenALSoft settings with the aim of improving audio quality on desktop targets.
*/
@:keep class ALSoftConfig
{
#if desktop
static function __init__():Void
{
var origin:String = #if hl Sys.getCwd() #else Sys.programPath() #end;

var configPath:String = Path.directory(Path.withoutExtension(origin));
#if windows
configPath += "/plugins/alsoft.ini";
#elseif mac
configPath = Path.directory(configPath) + "/Resources/plugins/alsoft.conf";
#else
configPath += "/plugins/alsoft.conf";
#end

Sys.putEnv("ALSOFT_CONF", configPath);
}
#end
}
Loading