Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

5.1 sound for Windows #925

Open
wzdev-ci opened this issue Sep 13, 2009 · 44 comments
Open

5.1 sound for Windows #925

wzdev-ci opened this issue Sep 13, 2009 · 44 comments

Comments

@wzdev-ci
Copy link
Contributor

resolution_ type_bug | by anonymous


5.1 sound for Windows


Issue migrated from trac:925 at 2022-04-15 19:14:39 -0700

@wzdev-ci
Copy link
Contributor Author

i-NoD commented


O_o You're jocking, right?

@wzdev-ci
Copy link
Contributor Author

BlueMaxima commented


...what the hell.

@wzdev-ci
Copy link
Contributor Author

BlueMaxima <bluemaximax011@...> commented


OK, now that I've had a moment to think about it - he wants 5.1 Surround Sound in the game.

Which, in the state of the game's source, is as ridiculous as trying to travel backwards in time.

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed status from new to closed

@wzdev-ci
Copy link
Contributor Author

cybersphinx set resolution to invalid

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


I think this is a configuration issue of OpenAL, on my Linux system it defaults to stereo (in /etc/openal/alsoft.conf). Afaik the game itself doesn't limit the sound channels and should do as many as OpenAL is configured to use. I don't know how to configure it in Windows, if you find out, please post it here or in the forums.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Sep 14, 2009

anonymous commented


Replying to [#925 anonymous]:

I REMIND HERO i-NoD PLEASE MAKE 5.1 SOUND!

ROFLOL!

Dude, your such a brownnoser, the title should be BRAIN NEED! :P

Replying to Warzone2100/old-trac-import#925 (comment:4):

I think this is a configuration issue of OpenAL, on my Linux system it defaults to stereo (in /etc/openal/alsoft.conf). Afaik the game itself doesn't limit the sound channels and should do as many as OpenAL is configured to use. I don't know how to configure it in Windows, if you find out, please post it here or in the forums.

"OpenAL itself can't get or set the speaker mode for your sound card -- that's done at the OS level.

OpenAL will default to using your currently-selected speaker setting for your currently-selected card. You can determine this setup by going to the "Sounds and Audio Devices Properties" control panel. If you have 5.1 output selected on your SoundBlaster Audigy 2 for instance, then when you position a source behind the listener and play it, you'll get sound from the two rear speakers."

@wzdev-ci
Copy link
Contributor Author

i-NoD changed type from task to defect

@wzdev-ci
Copy link
Contributor Author

i-NoD changed resolution from invalid to ``

@wzdev-ci
Copy link
Contributor Author

i-NoD edited the issue description

@wzdev-ci
Copy link
Contributor Author

i-NoD changed title from 5.1 SOUND NEED! to 5.1 sound for Windows

@wzdev-ci
Copy link
Contributor Author

i-NoD commented


Hmm... trollercoaster?!

The problem with the multichannel (>2) sound on Windows is caused by a hack in sound wz system (lib/sound/openal_track.c). Current implementation is always using generic software renderer instead of using a system default one (excluding the case with some poor systems where only generic OpenAL renderer exists). And the
"Generic Software" device will only output stereo. If that hack is removed I can use a true 5.1 sound with native OpenAL renderer from built-in sound card if Windows is configured for multichannel environment (it's not some external card, so it only supports 62 sources but it's enough for wz). I've created a patch which allows user to select wz sound mode (sound parameter in config file) through options. It's compatible with current config file settings, so user can safely upgrade to the new configuration. For non-Windows users options are: On[sound=2] and Off[sound=0], for Windows users options are: On(Compatible)[sound=1], On[sound=2] and Off[sound=0]. Compatible setting is a default one for Windows, so there are no changes for usual users.

@wzdev-ci
Copy link
Contributor Author

i-NoD changed status from closed to reopened

@wzdev-ci
Copy link
Contributor Author

i-NoD uploaded file win_sound.patch (21.1 KiB)

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


Hm, so it actually is Warzone's fault, with a Windows-specific hack...

How about a generic OpenAl device selection? No need for system-specific hacks, and it isn't limited to hardcoded choices. Might also be useful on other systems, though most Linuxes configure OpenAL correctly these days.

Also, you included some unrelated changes, at least the vertical text in the menus (which you could just commit separately).

@wzdev-ci
Copy link
Contributor Author

anonymous commented


I tried this on Vista, nothing changed in the 5.1 area but it is worse when you have more than 16 sounds at once. All my games that are 5.1 in XP are stereo in Vista.

The default should be like it is now with the generic software device to prevent sound corruption.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Sep 18, 2009

i-NoD commented


Replying to Warzone2100/old-trac-import#925 (comment:8):

I tried this on Vista, nothing changed in the 5.1 area but it is worse when you have more than 16 sounds at once. All my games that are 5.1 in XP are stereo in Vista.

If you can play 5.1 sound on your system, but can't hear 5.1 in WZ then I guess you just have a "Generic Software" renderer as a default one for OpenAL (not for the system). I just run into this with my new Radeon card. The only way to get 5.1 sound for me now is to force the wanted device by name. You can check currently selected device in wz log with my patch (using --debug all), smth like

sound   |11:53:39: [sound_InitLibrary] Current audio device: Realtek HDMI Output (ATI HDMI Audio)

If you have "Generic Software" device it explains why do you still have stereo... but I dunno how sound can be worse in that case.

The default should be like it is now with the generic software device to prevent sound corruption.

Who is removing the joy of "Generic Software" renderer as a default one?

@wzdev-ci
Copy link
Contributor Author

Zarel commented


Instead of calling the options "On (compatible)", "On", and "Off", we should call them "On (compatible)", "On (surround)", and "Off".

@wzdev-ci
Copy link
Contributor Author

cybersphinx uploaded file wz-sounddevice.patch (6.8 KiB)

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


Above patch implements audio device selection. It basically works here, by saving the changed device on quit and using it on the next run (like the video options), problem with that is that some sound devices may hang on init, and then the config file has to be edited to change it.

A better alternative would be switching sound in-game, then it might hang as well, but at least the non-working option isn't saved. Unfortunately the sound lib cannot be restarted, at least not in the simple way I used (by just doing "sound_Shutdown();sound_Init();"), after that any sounds fail with "sound |02:23:04: [sound_CheckTrack] Track number 2 outside max 0".

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


Hm, actually sound still works after the sound engine restart once you load new sounds, just the already loaded menu blips don't work anymore (so in-game sounds work, and after that menu sounds work again as well).

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 5, 2009

i-NoD uploaded file wz-sounddevice_v2.patch (7.5 KiB)

Reworked version.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 5, 2009

i-NoD changed milestone from 2.2.5 to 2.3

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 5, 2009

i-NoD commented


This version works with current trunk and MSVC. Gives used device name straight on start, no more need for default.

Considering the current sound infrastructure I'd say we should force a restart on device change. A small nuisance for less bugs. If sound code would be less troublesome we can change this later on.
In current form it should be like

   cdAudio_Stop();
   ..all other audio stops..
   audio_Shutdown();
   audio_Init(droidAudioTrackStopped);

not the sound_... sub-calls...

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 6, 2009

Zarel commented


Just an invisible restart of the soundsystem, not like a restart of the game, right?

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 6, 2009

i-NoD commented


Nope, a complete quit game/launch game cycle, similar to resolution change. I don't see any problems here at all: a default device will be used by the vast majority... and should be switched only once in a while by advanced user. It takes <10 sec on my laptop...

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 6, 2009

Zarel commented


...no way. People have to restart the game just to plug in headphones? That's ridiculous! What's wrong with the current way?

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 6, 2009

i-NoD commented


Headphones? We're are talking about endpoints at all... :-/ And I think we should n't touch them, let the system handle this matter.

It seems to me that you're assumed something unrelated to device selection. Please define 'the current way' for you and try applying the patch then.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 6, 2009

Zarel commented


Hmm. What do you mean by "device change", then? I can't really just apply the patch and see what's changed, if I don't know what's changed...

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Dec 12, 2009

Buginator commented


Replying to Warzone2100/old-trac-import#925 (comment:17):

Headphones? We're are talking about endpoints at all... :-/ And I think we should n't touch them, let the system handle this matter.

It seems to me that you're assumed something unrelated to device selection. Please define 'the current way' for you and try applying the patch then.

i-Nod, looks good. Commit it.

@wzdev-ci
Copy link
Contributor Author

Buginator commented


Replying to [comment:19 Buginator]:

Replying to [comment:17 i-NoD]:

Headphones? We're are talking about endpoints at all... :-/ And I think we should n't touch them, let the system handle this matter.

It seems to me that you're assumed something unrelated to device selection. Please define 'the current way' for you and try applying the patch then.

i-Nod, looks good. Commit it.

Actually, we talked about this on IRC, it might still have issues.
'... Anyway, the problem with the patch is, when a device doesn't work, the game hangs. At that point the new device should not have been written to the config file, i.e. exit&restart game to change device is bad.'

@wzdev-ci
Copy link
Contributor Author

Crymson commented


I tried the patch and it does break the game when I moved the warzone folder to my other machine.
Is there anyway to detect the exact hardware first, and if it doesn't match, use defaults?

@wzdev-ci
Copy link
Contributor Author

Buginator changed priority from major to minor

@wzdev-ci
Copy link
Contributor Author

Buginator changed milestone from `` to unspecified

@wzdev-ci
Copy link
Contributor Author

Buginator commented


Replying to [comment:21 Crymson]:

I tried the patch and it does break the game when I moved the warzone folder to my other machine.
Is there anyway to detect the exact hardware first, and if it doesn't match, use defaults?

Not at this time.

@wzdev-ci
Copy link
Contributor Author

Ezio commented


made simple patch to detect default audio device,
debug results:
3.1 RC-3

sound   |02:30:50: [sound_InitLibrary:173] Current audio device: DirectSound Default
sound   |02:30:50: [sound_InitLibrary:197] OpenAL Vendor: OpenAL Community
sound   |02:30:50: [sound_InitLibrary:201] OpenAL Version: 1.1 ALSOFT 1.13
sound   |02:30:50: [sound_InitLibrary:205] OpenAL Renderer: OpenAL Soft
sound   |02:30:50: [sound_InitLibrary:209] OpenAL Extensions: AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_sub_data AL_SOFT_loop_points
sound   |02:30:50: [PlayList_Read:126] Added song track1.ogg to playlist
sound   |02:30:50: [PlayList_Read:126] Added song track2.ogg to playlist
sound   |02:30:50: [PlayList_Read:126] Added song track3.ogg to playlist
sound   |02:30:50: [cdAudio_Open:54] called(music)
sound   |02:30:51: [cdAudio_PlayTrack:138] called(0)
sound   |02:30:51: [cdAudio_OpenTrack:86] called(music/menu.ogg)
sound   |02:30:51: [cdAudio_Stop:171] called, cdStream=00000000
sound   |02:30:51: [cdAudio_OpenTrack:108] successful(music/menu.ogg)
sound   |02:31:02: [cdAudio_Close:66] called
sound   |02:31:02: [cdAudio_Stop:171] called, cdStream=07A407F8
sound   |02:31:02: [sound_ShutdownLibrary:243] starting shutdown
sound   |02:31:02: [sound_ShutdownLibrary:256] make default context NULL
sound   |02:31:02: [sound_ShutdownLibrary:260] destroy previous context
sound   |02:31:02: [sound_ShutdownLibrary:264] close device

Compiled

sound   |02:27:36: [sound_InitLibrary:181] Current audio device: Generic Software
sound   |02:27:36: [sound_InitLibrary:205] OpenAL Vendor: Creative Labs Inc.
sound   |02:27:36: [sound_InitLibrary:209] OpenAL Version: 1.1
sound   |02:27:36: [sound_InitLibrary:213] OpenAL Renderer: Software
sound   |02:27:36: [sound_InitLibrary:217] OpenAL Extensions: EAX EAX2.0 EAX3.0 EAX4.0 EAX5.0 EAX3.0EMULATED EAX4.0EMULATED AL_EXT_OFFSET AL_EXT_LINEAR_DISTANCE AL_EXT_EXPONENT_DISTANCE
sound   |02:27:36: [PlayList_Read:126] Added song track1.ogg to playlist
sound   |02:27:36: [PlayList_Read:126] Added song track2.ogg to playlist
sound   |02:27:36: [PlayList_Read:126] Added song track3.ogg to playlist
sound   |02:27:36: [cdAudio_Open:54] called(music)
sound   |02:28:36: [cdAudio_PlayTrack:138] called(0)
sound   |02:28:36: [cdAudio_OpenTrack:86] called(music/menu.ogg)
sound   |02:28:36: [cdAudio_Stop:171] called, cdStream=00000000
sound   |02:28:36: [cdAudio_OpenTrack:108] successful(music/menu.ogg)
sound   |02:29:00: [cdAudio_Close:66] called
sound   |02:29:00: [cdAudio_Stop:171] called, cdStream=0A0EA1C0
sound   |02:29:00: [sound_ShutdownLibrary:251] starting shutdown
sound   |02:29:00: [sound_ShutdownLibrary:264] make default context NULL
sound   |02:29:00: [sound_ShutdownLibrary:268] destroy previous context
sound   |02:29:00: [sound_ShutdownLibrary:272] close device

@wzdev-ci
Copy link
Contributor Author

Ezio uploaded file 0001-should-detect-default-devive-better.patch (1.6 KiB)

@wzdev-ci
Copy link
Contributor Author

Ezio uploaded file 0001-added-windows-sound-device.patch (26.1 KiB)

edited i-nod patch

@wzdev-ci
Copy link
Contributor Author

Ezio uploaded file 0001-will-now-try-to-test-saved-sound-device.patch (1.4 KiB)

tiny change for patch above

@wzdev-ci
Copy link
Contributor Author

Ezio changed _comment0 which not transferred by tractive

@wzdev-ci
Copy link
Contributor Author

Ezio commented


new patch added i edited i-nod patch, since i only have 1 sound device i only test save and load config. and if saved device can't be mounted

0001-added-windows-sound-device.patch only add a some line that i forgot :P

@wzdev-ci
Copy link
Contributor Author

clueless commented


I am not sure if this is related or not but, on a windows laptop, the game's sound wouldn't work at all, until the supplied openAL file was installed.
Looking at the list of libs it says it is using openAL soft, so why is that file still needed?

@wzdev-ci
Copy link
Contributor Author

clueless commented


oalinst.exe is the file that was required.

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Aug 2, 2015

klasskill commented


doesn't openalsoft handle this on windows already?

OpenAL Soft's code has been improved to support mono, stereo, 4-channel, 5.1, 6.1, 7.1, and HRTF output. OpenAL Soft does not support the Vorbis and MP3 extensions however, these are considered deprecated. It does, though, support some of the newer extensions like AL_EXT_FLOAT32 and AL_EXT_MCFORMATS for multi-channel and floating-point formats, as well as ALC_EXT_EFX for environmental audio effects, and others.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant