ID:2273757
 
BYOND Version:511
Operating System:Windows 10 Pro 64-bit
Web Browser:Firefox 54.0
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
When creating sounds for players, any change to the sound's environment var is applied, globally, to all sounds.

Needless to say, this is problematic; if you want a particular sound to have an environment applied applied to it, you only want it to be for that particular instance of sound, and not all other sounds (or even future sounds).

/mob/proc/sound()
var/sound/S = sound('rawr.ogg')
S.environemnt = 10
src << S

/mob/proc/sound_2()
src << sound('rawr.ogg')

/mob/proc/play_two_sounds()
sound()
sound_2()


When play_two_sounds is called on a mob, you would expect the first case to apply a significant effect/reverb to the sound, but the second would be clean and crisp.

This isn't the case; both sounds will have the reverb applied, and all future sounds played will have the same environment set until you explicitly create a new sound and explicitly reset its environment.

Expanding on this further:

/mob/proc/sound()
var/sound/S = sound('rawr.ogg')
S.environemnt = 10
src << S

/mob/proc/sound_2()
src << sound('rawr.ogg')

/mob/proc/sound_3()
var/sound/S = sound('rawr.ogg')
S.environemnt = -1
src << S

/mob/proc/sound_4()
src << sound('rawr.ogg')

/mob/proc/play_four_sounds()
sound()
sound_2()
sound_3()
sound_4()


If play_four_sounds is called, the first sound will have reverb, the second will, as well, despite not having its enviornment variable set, the third one will sounds normal as it has has the environment set back to the default, and, of course, the fourth will also sound normal because the last sound to be played that had its enviornmental variable set was -1.
I don't believe this is necessarily a bug so much as a limitation in the sound system. I'd like to move away from the EAX stuff in general toward something more robust in the future, though, because that's a much older sound technology.

However it's worth a second look to see if maybe there's something wrong about the implementation that can be fixed. For all I know I'm mistaken and maybe it is possible to get the sound channels to handle this independently.
Changes the environmental reverb for all 3D sounds until another environment is specified. Only 3D sounds react to the environment. Please see the EAX2 documentation at http://developer.creative.com/ for detailed information about these settings.

If anything, putting the environment var under a global or static subtree in the ref would avoid confusion. (as well as making it act like one, since it is)

If you can make it act properly on the sound channel, that would also be cool.
Thanks Lummox.

Another question. What are the inner working of channel 0 selection? It states that it will select any channel not currently in use; does it do this randomly, incrementally, or something else?

Likewise, if you play 2 sounds, one after the other---both with a channel 0 var, will the channel be relinquished after use?

for example, the first would play on channel 1, then the second sound would play, but because the first sound is done playing and it wouldn't cause conflict, it, too, will play on channel 1.
In response to Fox P McCloud
I forget the exact inner workings, but I believe that's the gist of it. Reusing IDs that are no longer in use is sort of a staple of any project like this, and as a result that concept appears frequently under the hood.
Hi, there's still a lot of interest in making more use of sound environments but with this issue still existing it's still very difficult. Is this possibly something that could be looked at in a future version still? :)
something like this would be really nice
Yeah, sound environments are somewhat unusable unless you reset the environment before every play due to this.