Air absorption in spring

Air absorption in spring

Discuss sound effects, game music, and the creation thereof.

Moderator: Moderators

User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Air absorption in spring

Post by hoijui »

in latest master (since 23. Feb. 2010, or 195a5e71fbe1c95e63dd466dd4f5eba957cb8364), spring uses OpenAL air absorption. Details can be seen here (straight forward, easy to understand code):
http://github.com/spring/spring/commit/ ... a957cb8364

Effectively this means, in addition to decaying volume by distance, there is a low pass filter (also distance relative). So from far away, you will only hear the low frequency sounds. While the decay in volume does not happen when zooming out, just for (x,z) distance, the air-absorption uses the real 3D distance, so eg. laser sounds will not be hearable from far away, while explosions usually are still heard.

This is currently set to a fixed factor (0.1f). The reasons for the change are realism and to make the general sounds less annoying (additionally you could say for health, as high frequency sounds will damage the ears more over time, though... well ;-)).

soo.. please test this! and give feedback.
installer with this change can be found here:
http://buildbot.eat-peet.net/spring/ins ... b00aef.exe

side note: as you can see from the code, this needs the ALC_EXT_EFX OpenAL extension to work, and there will be an warning message in infolog if your system/OpenAL version does not support this, though it will work for most modern distributions.
User avatar
Beherith
Moderator
Posts: 5010
Joined: 26 Oct 2007, 16:21

Re: Air absorption in spring

Post by Beherith »

I found this very interesting, so I tested:

- I really couldn't hear the difference, and i was testing with a 24 by 24 map, used the sounds of thuds and llts firing.

Other stuff:
- If I zoomed out all the way, I could hear all sounds on the map just as if I was zoomed in, even from areas that were out of view. Meaning the sounds didn't get neither quieter nor low-passed as I increased Y. Is this intentional?
- If I zoomed in to normal view, I could only hear the sounds of stuff nearby, but also couldn't notice the low pass filter :(


Your avatar reminds of Mashed Potato Johnson btw :)
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Air absorption in spring

Post by Auswaschbar »

Beherith wrote:- I really couldn't hear the difference, and i was testing with a 24 by 24 map, used the sounds of thuds and llts firing.
Me neither
Beherith wrote:- If I zoomed out all the way, I could hear all sounds on the map just as if I was zoomed in, even from areas that were out of view. Meaning the sounds didn't get neither quieter nor low-passed as I increased Y. Is this intentional?
That it won't become quieter is intentional. But what I get from hoijui, it still should be low-passed.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Air absorption in spring

Post by hoijui »

did the two of you check infolog, relevant messages would be right after the OpenAL initial messages of vendor and version and such.
User avatar
Beherith
Moderator
Posts: 5010
Joined: 26 Oct 2007, 16:21

Re: Air absorption in spring

Post by Beherith »

ah ok, your right:

Code: Select all

[      0] Sound:   Vendor:     Creative Labs Inc.
[      0] Sound:   Version:    1.1
[      0] Sound:   Renderer:   Software
[      0] Sound:   AL 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
[      0] Sound:   ALC Extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_EFX
[      0] Sound:   Device:     Generic Software
[      0] Sound:   Available Devices:  
[      0] Sound:                       Generic Software
[      0] Sound: air absorption disabled, reason: ALC_EXT_EFX not supported
[      0] Sound:  parsed 25 sounds from gamedata/sounds.lua
That does beg the question though, what sound cards or drivers support this?
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Air absorption in spring

Post by aegis »

soft-openal... does this work with creative's openal?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Air absorption in spring

Post by hoijui »

that is what i get:

Code: Select all

Sound: OpenAL info:
Sound:   Vendor:     OpenAL Community
Sound:   Version:    1.1 ALSOFT 1.9.563
Sound:   Renderer:   OpenAL Soft
Sound:   AL Extensions: AL_EXTX_buffer_sub_data AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET AL_EXTX_sample_buffer_object AL_EXTX_source_distance_model AL_LOKI_quadriphonic
Sound:   ALC Extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_disconnect ALC_EXT_EFX ALC_EXTX_thread_local_context
Sound:   Device:     ALSA Software
Sound:   Available Devices:  
Sound:                       ALSA Software
Sound: air absorption enabled, value: 0.1
what you get is really strange, as ALC_EXT_EFX is in your list of supported extensions, but the explicit test seems to fail :/

this (Source.cpp:301):

Code: Select all

alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")
seems to return true, while this (SoundSource.cpp:288):

Code: Select all

alcIsExtensionPresent(NULL, "ALC_EXT_EFX")
returns true for you, according to your infolog, even doh both these extensions are listed there :/
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Air absorption in spring

Post by hoijui »

hmm.. maybe we have to use the actual device, instead of NULL for this test.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Air absorption in spring

Post by hoijui »

done what i talked about in the last post, its on master now, windows executable here:
http://buildbot.eat-peet.net/spring/exe ... c8ae78.zip
that is enough if you have the installer i posted earlier, if not, new installer is here:
http://buildbot.eat-peet.net/spring/ins ... c8ae78.exe

please try again :-)
and sorry for tripple post
User avatar
Hobo Joe
Posts: 1001
Joined: 02 Jan 2008, 21:55

Re: Air absorption in spring

Post by Hobo Joe »

On a somewhat related note, there should be a way to prevent being able to hear things that shouldn't be heard from across the map. For example, in the current spring you can easily guess the location of your opponent very early on in the game (most noticeably by the sounds of a lab building), because the sound is (as far as I know) only controlled by the position of your camera, not the position of your units. It'd be nice if sound volume was changed based on the location of your nearest unit, although I don't know how easy that would be to code or how well it would perform.

It's not a huge issue (it's not like it's hard to find the enemy with scouts), but it would be nice to have it fixed, to add some amount of unpredictability.
User avatar
Beherith
Moderator
Posts: 5010
Joined: 26 Oct 2007, 16:21

Re: Air absorption in spring

Post by Beherith »

Beherith wrote:ah ok, your right:

Code: Select all

[      0] Sound:   Vendor:     Creative Labs Inc.
[      0] Sound:   Version:    1.1
[      0] Sound:   Renderer:   Software
[      0] Sound:   AL 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
[      0] Sound:   ALC Extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_EFX
[      0] Sound:   Device:     Generic Software
[      0] Sound:   Available Devices:  
[      0] Sound:                       Generic Software
[      0] Sound: air absorption disabled, reason: ALC_EXT_EFX not supported
[      0] Sound:  parsed 25 sounds from gamedata/sounds.lua
That does beg the question though, what sound cards or drivers support this?
I just noticed, I DO have this extension.
User avatar
1v0ry_k1ng
Posts: 4656
Joined: 10 Mar 2006, 10:24

Re: Air absorption in spring

Post by 1v0ry_k1ng »

why not have it depend on zoom out height too?
User avatar
Beherith
Moderator
Posts: 5010
Joined: 26 Oct 2007, 16:21

Re: Air absorption in spring

Post by Beherith »

now is says air distortion is enabled, with 0.1
Im testing with BA and still not hearing much of a difference.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Air absorption in spring

Post by hoijui »

air absorption does use 3D distance, which includes zoom-out. volume uses a 2D distance (basically), this is nothing new though. the reason for this is, as i guess, so you do not have to manually adjust your speaker volume whenever you zoom in or out. this would be especially bad on big maps, where you TAB out while the game is quiet, adjust volume so you still hear stuff, and when battle starts, TAB right into the action -> BAWW! -> *heart attack* -> spring devs being sued -> community revolting -> civil war -> extinction of humanity -> NO MORE SPRING GAMES GETTING PLAYED!
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: Air absorption in spring

Post by Auswaschbar »

Distance is always 3d, so air absorption should be unaffected wherever you go away vertically or horizontally.
User avatar
Beherith
Moderator
Posts: 5010
Joined: 26 Oct 2007, 16:21

Re: Air absorption in spring

Post by Beherith »

Aus, can you hear the difference? Cause I cant, even tho its on :(
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Air absorption in spring

Post by Kloot »

On a related dev-note, these commits mute (ie. totally silence, regardless of volume) all sounds for me, which I can fix only by commenting the airAbsorption = factor assignment in SoundSource::SetAirAbsorption. Any value > 0.0 will cause this, so it seems alSourcef is broken / unimplemented for AL_AIR_ABSORPTION_FACTOR. Details if you need them:
Sound: OpenAL info:
Sound: Vendor: OpenAL Community
Sound: Version: 1.1
Sound: Renderer: OpenAL Soft
Sound: AL Extensions: AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET AL_LOKI_quadriphonic
Sound: ALC Extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_EFX
Sound: Device: ALSA Software on default
Sound: Available Devices:
Sound: ALSA Software on default
Sound: ALSA Software on Audigy 2 ZS [SB0350]
Sound: ALSA Software on USB Device 0x46d:0x8d9
Sound: OSS Software
Sound: Wave File Writer
Sound: air absorption enabled, value: 0.1
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Air absorption in spring

Post by hoijui »

hmm strange!
my AL version shows as "1.1 ALSOFT 1.9.563", and you two (Behe and Kloot) only get "1.1", pretty bad it does not show the full version.

and about the muting.. :/
guess i will leave it at 0.0 by default, and make it configurable through spring settings.

edit:
Behe, maybe try setting the factor to something higher (eg 1.0), and see if it changes anything... that would be VERY noticeable.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Air absorption in spring

Post by hoijui »

talked to the OpenAL Soft chief again:
if openal soft is only showing version "1.1" it's a really old version.

EFX was added to openal soft in 1.2, and I think I added the extended version info around 1.4 or so.

normally what I've seen done with binary apps in Linux, they provide their own libopenal.so.1 with their other libs (eg. SDL, stdc++). users that want to use the system openal can just rename the provided one, and it'll fall back to it.
Auswaschbar packaged OpenAL Soft with mingwlibs now, i do not know which version though, but.. this is likely to be the problem here (too old OpenAL versions).

about the last paragraph/sentence (libopenal.so.1): i would say it is not worth doing this for spring, just for air-absorption.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Air absorption in spring

Post by CarRepairer »

This idea sounds awesome, I hope it works for me on the next release.

But there are some infamous mappers who will grow angry at the use of air absorption because some maps don't have air. They will claim it ruins immersion and tramples on mapper's rights.
Post Reply

Return to “Sound Effects & Music”