Sound hook (changing pitch of ALL sounds played)

So what I’m thinking about is making a part of my gamemode slow-motion. I have achieved the physics/timescale part of it with host_timescale just fine.

However, the sounds are the same pitch, making for an unrealistic effect when playing in slow-motion.

I’ve searched the wiki to look for any sort of “EmitSound” hook but to no avail. I know that when you emit sounds you can change their pitch, but GM seems to be lacking a hook to allow me to alter the sounds in any way on a massive-scale.

Any help?

Thanks!

That’s the only thing I know of that could help you.

You are a god. Thanks, that’s a great start! Looks like I can’t turn the pitch down but there is a lowpass which should have a similar effect.

Thanks!

Well, turns out I figured it out myself.

After learning that Lua is pretty much the most awesome language ever, I decided to crack into the metatables and redirected EmitSound() to my own function. The only downside is that you have to do it through a SWEP. Here’s the code for ‘shared.lua’

[lua]

– Hook our sound!
function SWEP:Initialize()
if(g_oldes == nil) then
if(SERVER) then Log.Dbg(“Hooking all SENT/SWEP sounds.”) end
tb = getmetatable(self)
g_oldes = tb.MetaBaseClass.EmitSound
tb.MetaBaseClass.EmitSound = function(a, b, c, d)

        if(c == nil) then c = 100 end
        
        if(d == nil) then d = 100 end
        d = d /2
        
        g_oldes(a, b, c, d)
    end
end

end
[/lua]

EDIT: Oh, and just replace Log.Dbg with your Msg/MsgN function :]