kcat / openal-soft

OpenAL Soft is a software implementation of the OpenAL 3D audio API.
Other
2.16k stars 522 forks source link

Looping sound won't stop mid-loop #995

Open anttiah opened 4 months ago

anttiah commented 4 months ago

When playing old Battlefield 2 based games or mods with OpenAL Soft, some looping sounds never stop mid-loop. E.g. vehicle engine sound keeps playing for a while after exiting the vehicle. This happens with unmodified game and also with mods built for the same Refractor 2 game engine.

Please see the following videos for examples.

Expected: Engine sound stops immediately upon exit https://1drv.ms/v/s!AnhtECQ4lmzWgZkI29z4-R7cVRX6LQ?e=I9qIvd

Actual: Engine sound keeps playing for a couple of seconds https://1drv.ms/v/s!AnhtECQ4lmzWgZkHbvDqzVBjX7i5MA?e=D3uvyt

Log:

[ALSOFT] (II) Initializing library v1.23.1-d3875f33 master
[ALSOFT] (II) Supported backends: wasapi, dsound, winmm, null, wave
[ALSOFT] (II) Loading config C:\Users\<redacted>\AppData\Roaming\alsoft.ini...
[ALSOFT] (II)  found 'hrtf-paths' = '$USERPROFILE/Documents/OpenAL Soft/HRTF,'
[ALSOFT] (II)  found 'default-hrtf' = 'IRC_1041'
[ALSOFT] (II)  found 'stereo-mode' = 'headphones'
[ALSOFT] (II)  found 'stereo-encoding' = 'hrtf'
[ALSOFT] (II)  found 'resampler' = 'cubic'
[ALSOFT] (II)  found 'decoder/hq-mode' = 'true'
[ALSOFT] (II)  found 'decoder/nfc' = 'false'
[ALSOFT] (II) Got binary: D:\Games\EA Games\Battlefield 2 Complete Collection, BF2.exe
[ALSOFT] (II) Loading config D:\Games\EA Games\Battlefield 2 Complete Collection\alsoft.ini...
[ALSOFT] (II) Key disable-cpu-exts not found
[ALSOFT] (II) Vendor ID: ""
[ALSOFT] (II) Name: "13th Gen Intel(R) Core(TM) i9-13900KF"
[ALSOFT] (II) Extensions: +SSE +SSE2 +SSE3 +SSE4.1
[ALSOFT] (II) Key rt-prio not found
[ALSOFT] (II) Key rt-time-limit not found
[ALSOFT] (II) Key game_compat/enable-sub-data-ext not found
[ALSOFT] (II) Key game_compat/reverse-x not found
[ALSOFT] (II) Key game_compat/reverse-y not found
[ALSOFT] (II) Key game_compat/reverse-z not found
[ALSOFT] (II) Key game_compat/nfc-scale not found
[ALSOFT] (II) Found resampler = "cubic"
[ALSOFT] (II) Key uhj/decode-filter not found
[ALSOFT] (II) Key uhj/filter not found
[ALSOFT] (II) Key uhj/encode-filter not found
[ALSOFT] (II) Key trap-al-error not found
[ALSOFT] (II) Key trap-alc-error not found
[ALSOFT] (II) Key reverb/boost not found
[ALSOFT] (II) Key drivers not found
[ALSOFT] (II) Initialized backend "wasapi"
[ALSOFT] (II) Added "wasapi" for playback
[ALSOFT] (II) Added "wasapi" for capture
[ALSOFT] (II) Key excludefx not found
[ALSOFT] (II) Key default-reverb not found
[ALSOFT] (II) Key eax/enable not found
[ALSOFT] (II) Opening default playback device
[ALSOFT] (II) Starting message thread
[ALSOFT] (II) Starting message loop
[ALSOFT] (II) Got message "Open Device" (0x0000, this=068aca98, param=00000000)
[ALSOFT] (II) Created device 06110050, "OpenAL Soft on Headphones (G432 Gaming Headset)"
[ALSOFT] (II) Key frequency not found
[ALSOFT] (II) Key period_size not found
[ALSOFT] (II) Key periods not found
[ALSOFT] (II) Key sample-type not found
[ALSOFT] (II) Key channels not found
[ALSOFT] (II) Key ambi-format not found
[ALSOFT] (II) Key hrtf not found
[ALSOFT] (II) Found stereo-encoding = "hrtf"
[ALSOFT] (II) ALC_FREQUENCY = 44100
[ALSOFT] (II) Pre-reset: Stereo, Float32, *44100hz, 882 / 2646 buffer
[ALSOFT] (II) Got message "Reset Device" (0x0001, this=068aca98, param=00000000)
[ALSOFT] (II) Device mix format:
    FormatTag      = 0xfffe
    Channels       = 2
    SamplesPerSec  = 44100
    AvgBytesPerSec = 352800
    BlockAlign     = 8
    BitsPerSample  = 32
    Size           = 22
    Samples        = 32
    ChannelMask    = 0x3
    SubFormat      = {00000003-0000-0010-8000-00aa00389b71}
[ALSOFT] (II) Requesting playback format:
    FormatTag      = 0xfffe
    Channels       = 2
    SamplesPerSec  = 44100
    AvgBytesPerSec = 352800
    BlockAlign     = 8
    BitsPerSample  = 32
    Size           = 22
    Samples        = 32
    ChannelMask    = 0x3
    SubFormat      = {00000003-0000-0010-8000-00aa00389b71}
[ALSOFT] (II) Post-reset: Stereo, Float32, 44100hz, 882 / 2646 buffer
[ALSOFT] (II) Found stereo-mode = "headphones"
[ALSOFT] (II) Found hrtf-paths = "C:\Users\<redacted>/Documents/OpenAL Soft/HRTF,"
[ALSOFT] (II) Searching C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\*.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\CIAIR.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1013.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1021.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1031.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1041.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1042.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1043.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\MIT_KEMAR.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\MIT_KEMAR_large_pinna_sofa.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\MIT_KEMAR_sofa.mhr
[ALSOFT] (II)  got C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\SCUT_KEMAR.mhr
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\CIAIR.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1013.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1021.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1031.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1041.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1042.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1043.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\MIT_KEMAR.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\MIT_KEMAR_large_pinna_sofa.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\MIT_KEMAR_sofa.mhr"
[ALSOFT] (II) Adding file entry "C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\SCUT_KEMAR.mhr"
[ALSOFT] (II) Searching D:\Games\EA Games\Battlefield 2 Complete Collection\*.mhr
[ALSOFT] (II) Searching C:\Users\<redacted>\AppData\Roaming\openal\hrtf\*.mhr
[ALSOFT] (II) Searching C:\ProgramData\openal\hrtf\*.mhr
[ALSOFT] (II) Adding built-in entry "!1_Built-In HRTF"
[ALSOFT] (II) Found default-hrtf = "IRC_1041"
[ALSOFT] (II) Loading C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1041.mhr...
[ALSOFT] (II) Detected data set format v3
[ALSOFT] (II) Loaded HRTF IRC_1041 for sample rate 44100hz, 64-sample filter
[ALSOFT] (II) Key hrtf-size not found
[ALSOFT] (II) Key hrtf-mode not found
[ALSOFT] (II) 1st order + Full HRTF rendering enabled, using "IRC_1041"
[ALSOFT] (II) Channel config, Main: 4, Real: 2
[ALSOFT] (II) Allocating 6 channels, 24576 bytes
[ALSOFT] (II) Min delay: 3.25, max delay: 23.25, FIR length: 64
[ALSOFT] (II) New max delay: 20.00, FIR length: 84
[ALSOFT] (II) Found decoder/nfc = "false"
[ALSOFT] (II) Key sources not found
[ALSOFT] (II) Key sends not found
[ALSOFT] (II) Max sources: 256 (255 + 1), effect slots: 64, sends: 4
[ALSOFT] (II) Key dither not found
[ALSOFT] (II) Key dither-depth not found
[ALSOFT] (II) Dithering disabled
[ALSOFT] (II) Key output-limiter not found
[ALSOFT] (II) Output limiter disabled
[ALSOFT] (II) Fixed device latency: 0ns
[ALSOFT] (II) Got message "Start Device" (0x0002, this=068aca98, param=00000000)
[ALSOFT] (II) Post-start: Stereo, Float32, 44100hz, 882 / 2646 buffer
[ALSOFT] (II) Increasing allocated voices to 256
[ALSOFT] (II) Key volume-adjust not found
[ALSOFT] (II) Created context 068cbdb0
[ALSOFT] (II) Increasing allocated voice properties to 32
[ALSOFT] (II) Increasing allocated effect slots to 4
[ALSOFT] (II) Got message "Stop Device" (0x0003, this=068aca98, param=00000000)
[ALSOFT] (II) Freeing context 068cbdb0
[ALSOFT] (II) Freed unapplied AuxiliaryEffectSlot update 067e0aa0
[ALSOFT] (II) Freed unapplied AuxiliaryEffectSlot update 067e0b38
[ALSOFT] (II) Freed unapplied AuxiliaryEffectSlot update 067e0d00
[ALSOFT] (II) Freed 2 context property objects
[ALSOFT] (II) Freed 2 AuxiliaryEffectSlot property objects
[ALSOFT] (II) Freeing device 06110050
[ALSOFT] (II) Got message "Close Device" (0x0004, this=068aca98, param=00000000)
[ALSOFT] (II) Message loop finished
[ALSOFT] (II) HrtfStore 0615fc30 decreasing refcount to 0
[ALSOFT] (II) Unloading unused HRTF C:\Users\<redacted>\Documents\OpenAL Soft\HRTF\IRC_1041.mhr
jeremywh7 commented 2 weeks ago

@kcat By any chance, might Try to fix EAX obstruction, occlusion, and exclusion help this? I'm gonna try to 'test' this over the weekend, if the wife will let me. 😹

kcat commented 2 weeks ago

I doubt it, it doesn't really have anything to do with sounds stopping.

Out of curiosity, for the expected behavior, what is that using? Is it DirectSound instead of OpenAL? Or some internal sound mixer/processor? I think the information I could get about this suggested that it may be an issue with the way the game uses OpenAL when a looping sound should stop; it disables looping on the source and leaves it to stop on its own, rather than being explicitly stopped. There's nothing OpenAL Soft would be able to do in that case, if that's the actual problem.

It may be helpful to compare to Generic Software or some OpenAL hardware driver, if the game can be made to use them.

jeremywh7 commented 1 week ago

Out of curiosity, for the expected behavior, what is that using? Is it DirectSound instead of OpenAL? Or some internal sound mixer/processor?

The BF2 default uses Creative's OpenAL32.dll renamed to BF2OpenAL.dll (Creative Labs OpenAL32, v2.1.8.1, Copyright 2007, US).

Fwiw, the audio engine is SoundEngine.dll renamed to BF2Audio.dll (BF2 SoundEngine, v1.0.0.1, Copyright 2003, Sweden).