From 4b80c293ad0b9893cb593ae434edcccd275e8b31 Mon Sep 17 00:00:00 2001 From: VerySoft Date: Sun, 20 Feb 2022 07:15:56 -0500 Subject: [PATCH] Attempt to reduce sound based lag So, I am not sure how much this will help or hurt. We have noticed that, there is a lot of lag that happens under heavy radio use, and Ascian noted that the playsound proc was seriously overloaded during those times. Notably, presently every radio in the game uses playsound to play the radio sound any time anything sends a radio message, even if the radio in question doesn't have the channel the message was sent to. And if you are unaware, playsound figures out who's in range of every source of sound and their distance from its source to adjust the sounds so that it sounds like it's coming from the right place in the world. Problem is, if the server's decently busy, that's possibly a hundred things doing that work every time any message comes over a radio. I thought it would be better if, since the radio systems are ALREADY doing the work of figuring out who can see the radio message, that playsound doesn't actually need to do that work again for tons of different sources. ADDITIONALLY, the thing to determine if the sound should be played based on preferences is also a part of playsound, meaning that it STILL RUNS PLAYSOUND EVEN IF THE PREFERENCE IS OFF So! I used byond's direct sound thing which, I THINK just makes your client play the sound and ought to use next to no extra server resources for it. The only downside is that we lose pitch shifting on the radio sounds, and we lose the sense of 'audio presence' for the sounds in the world. In short, this means that the radio sound will just, always sound the same no matter where it is in relation to your character. If you receive a radio message, the sound will play on your client. The sound should also only ever play once for you per message, rather than stacking like it does when lots of people/radios are in the same place. ASSUMING THIS WORKS HOW I THINK IT DOES, this should reduce a lot of computer work for playsound on busy shifts. (And ideally, increase performance) This change does also use and respect the same preference that already exists for radio sounds, so there will be no change in how that works. --- code/game/machinery/telecomms/broadcaster.dm | 10 ++++++++++ code/game/objects/items/devices/radio/headset.dm | 4 ++-- sound/effects/radio_common_quieter.ogg | Bin 0 -> 5190 bytes 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 sound/effects/radio_common_quieter.ogg diff --git a/code/game/machinery/telecomms/broadcaster.dm b/code/game/machinery/telecomms/broadcaster.dm index 6cf3d624c71..549546b3887 100644 --- a/code/game/machinery/telecomms/broadcaster.dm +++ b/code/game/machinery/telecomms/broadcaster.dm @@ -511,27 +511,37 @@ var/message_delay = 0 // To make sure restarting the recentmessages list is kept if(length(heard_masked)) for (var/mob/R in heard_masked) R.hear_radio(message_pieces, verbage, part_a, part_b, part_c, M, 0, name) + if(R.is_preference_enabled(/datum/client_preference/radio_sounds)) + R << 'sound/effects/radio_common_quieter.ogg' /* --- Process all the mobs that heard the voice normally (understood) --- */ if(length(heard_normal)) for (var/mob/R in heard_normal) R.hear_radio(message_pieces, verbage, part_a, part_b, part_c, M, 0, realname) + if(R.is_preference_enabled(/datum/client_preference/radio_sounds)) + R << 'sound/effects/radio_common_quieter.ogg' /* --- Process all the mobs that heard the voice normally (did not understand) --- */ if(length(heard_voice)) for (var/mob/R in heard_voice) R.hear_radio(message_pieces, verbage, part_a, part_b, part_c, M,0, vname) + if(R.is_preference_enabled(/datum/client_preference/radio_sounds)) + R << 'sound/effects/radio_common_quieter.ogg' /* --- Process all the mobs that heard a garbled voice (did not understand) --- */ // Displays garbled message (ie "f*c* **u, **i*er!") if(length(heard_garbled)) for (var/mob/R in heard_garbled) R.hear_radio(message_pieces, verbage, part_a, part_b, part_c, M, 1, vname) + if(R.is_preference_enabled(/datum/client_preference/radio_sounds)) + R << 'sound/effects/radio_common_quieter.ogg' /* --- Complete gibberish. Usually happens when there's a compressed message --- */ if(length(heard_gibberish)) for (var/mob/R in heard_gibberish) R.hear_radio(message_pieces, verbage, part_a, part_b, part_c, M, 1) + if(R.is_preference_enabled(/datum/client_preference/radio_sounds)) + R << 'sound/effects/radio_common_quieter.ogg' return 1 diff --git a/code/game/objects/items/devices/radio/headset.dm b/code/game/objects/items/devices/radio/headset.dm index a7ba535c3bb..e456f22b26a 100644 --- a/code/game/objects/items/devices/radio/headset.dm +++ b/code/game/objects/items/devices/radio/headset.dm @@ -62,12 +62,12 @@ /obj/item/device/radio/headset/receive_range(freq, level, aiOverride = 0) if (aiOverride) - playsound(loc, 'sound/effects/radio_common.ogg', 20, 1, 1, preference = /datum/client_preference/radio_sounds) + //playsound(loc, 'sound/effects/radio_common.ogg', 20, 1, 1, preference = /datum/client_preference/radio_sounds) return ..(freq, level) if(ishuman(src.loc)) var/mob/living/carbon/human/H = src.loc if(H.l_ear == src || H.r_ear == src) - playsound(loc, 'sound/effects/radio_common.ogg', 20, 1, 1, preference = /datum/client_preference/radio_sounds) + //playsound(loc, 'sound/effects/radio_common.ogg', 20, 1, 1, preference = /datum/client_preference/radio_sounds) return ..(freq, level) return -1 diff --git a/sound/effects/radio_common_quieter.ogg b/sound/effects/radio_common_quieter.ogg new file mode 100644 index 0000000000000000000000000000000000000000..b4686b58ea6decd8660c5c364505d09f7aa087bd GIT binary patch literal 5190 zcmai1d0f(2*T3$#Prox##@OB`_f&1gL^P z+r5x^;&aJhpvoeZ9b31>Ch-+4mDRQLl4JuFC2?LQP@(yEQ)ntAWq#G&`v3a=k7l4Y z4`UCd;YrDf%L2D0U^XYkhAP1^6pXVI!P&{#X$1xs$lH>Xyp6->Y}t-iAggH1t6KZ6 z3RM9l0BrauyERh2sR(KA8)Wtr?c2khG4ow(um|nDHmb{(Utm>H?wb>Z%jhd$0)@g} zpHyR!*au-Hvh@lt%*1*@Du)PpNeUj)_piZ^moYTA)chZ!GHasWKPY5fO_;7?(H`Pyj&r37q%@P6uh;r~_^Q zfFuPQUr#~bJb=F0fYwDUh|o}Y7XjCi#TDfIXXHYgh(cRsAJ46E=xS7UXQetBfS_PK zzZ7FFrCuBWh;nzaG+ZoA6i?*jBShJ?sz3;UI^4!(Rfwm*WOXltIU?iT|3{B1=9nqf zp%0M*N%7U1IZkS3n#y~CW(W<$PIBR2P8Oo5`X{vOh@)js%OmtlsSQNSGIG+|D{KeBUjni$>||H*WqyPOX5Un=DE;F zZe0_dikC|0I!gaxpznP(&Eg7z709tU_{y?vI(Aj_?!+jr27th~=zass|MWNLUIW`; zL)aY$om~e*{FnmHNU$z=;Sy-%6>RJ`=)&wbVFj<`1-o$uU0ES+EM_P# zte6)i6WlN1-2ae1`j5`iQXbI|0FS~Y_(E%Z;Zyf~8wx4$h8-YjDl$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