Beginnings of a global volume control system

This commit is contained in:
ShadowLarkens
2020-08-14 16:49:13 -07:00
committed by Rykka
parent 2636620dce
commit 7aaa40b62c
14 changed files with 227 additions and 57 deletions

View File

@@ -1,4 +1,4 @@
/proc/playsound(atom/source, soundin, vol as num, vary, extrarange as num, falloff, is_global, frequency = null, channel = 0, pressure_affected = TRUE, ignore_walls = TRUE, preference = null)
/proc/playsound(atom/source, soundin, vol as num, vary, extrarange as num, falloff, is_global, frequency = null, channel = 0, pressure_affected = TRUE, ignore_walls = TRUE, preference = null, volume_channel = null)
if(isarea(source))
throw EXCEPTION("playsound(): source is an area")
return
@@ -23,9 +23,9 @@
if(distance <= maxdistance)
if(T && T.z == turf_source.z)
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, is_global, channel, pressure_affected, S, preference)
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, is_global, channel, pressure_affected, S, preference, volume_channel)
/mob/proc/playsound_local(turf/turf_source, soundin, vol as num, vary, frequency, falloff, is_global, channel = 0, pressure_affected = TRUE, sound/S, preference)
/mob/proc/playsound_local(turf/turf_source, soundin, vol as num, vary, frequency, falloff, is_global, channel = 0, pressure_affected = TRUE, sound/S, preference, volume_channel = null)
if(!client || ear_deaf > 0)
return
if(preference && !client.is_preference_enabled(preference))
@@ -36,6 +36,11 @@
S.wait = 0 //No queue
S.channel = channel || open_sound_channel()
// I'm not sure if you can modify S.volume, but I'd rather not try to find out what
// horrible things lurk in BYOND's internals, so we're just gonna do vol *=
vol *= client.get_preference_volume_channel(volume_channel)
vol *= client.get_preference_volume_channel(VOLUME_CHANNEL_MASTER)
S.volume = vol
if(vary)