AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Change pitch for all sounds (https://forums.alliedmods.net/showthread.php?t=105419)

tolsty 10-04-2009 11:53

Change pitch for all sounds
 
is it possible to change the pitch for all sounds, or even better slow them down.
P.S.
i know that i can precache every sound and emit it,
too big effort for such thing xD

Arkshine 10-04-2009 13:30

Re: Change pitch for all sounds
 
You can change pitch only for sounds which are emitting.

Hook FM_EmitSound(), use emit_sound() to play the sound with the pitch changed then supercede to block original sound.

Will work only for server sound. ( all related to client-side sound can not be hooked )

ConnorMcLeod 10-04-2009 15:31

Re: Change pitch for all sounds
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"

#define NEW_PITCH    80

#define SENDAUDIO_MESSAGE_PITCH_ARG 3

public plugin_init()
{
    
register_plugin("Sounds Pitch"VERSION"ConnorMcLeod")

    
register_forward(FM_EmitSound"EmitSound")
    
register_forward(FM_EmitAmbientSound"EmitAmbientSound")
    
register_message(get_user_msgid("SendAudio"), "Message_SendAudio")
}

public 
EmitSound(const iEnt, const iChan, const szSample[], const Float:fVol, const Float:fAttn, const iFlags, const iPitch)
{
    
emit_sound(iEntiChanszSamplefVolfAttniFlagsNEW_PITCH)
    return 
FMRES_SUPERCEDE
}

public 
EmitAmbientSound(const iEnt, const Float:vecPos[3], const szSample[], const Float:fVol, const Float:fAttn, const iFlags, const iPitch)
{
    
engfuncEngFunc_EmitAmbientSoundiEntvecPosszSamplefVolfAttniFlagsNEW_PITCH)
    return 
FMRES_SUPERCEDE
}

public 
Message_SendAudio(const iMsgId, const iMsgDest, const id)
{
    
set_msg_arg_int(SENDAUDIO_MESSAGE_PITCH_ARGARG_SHORTNEW_PITCH)



tolsty 10-04-2009 19:02

Re: Change pitch for all sounds
 
<3 connor, + :crab:

why when i use it like this, theres an index out of bounds error ?

PHP Code:

public EmitSound(const iEnt, const iChan, const szSample[], const Float:fVol, const Float:fAttn, const iFlags, const iPitch)
{
    if( !
pev_valid(iEnt) )
        return 
FMRES_HANDLED
    
if (g_bInRadius[iEnt] == false )
        return 
FMRES_HANDLED
    emit_sound
(iEntiChanszSamplefVolfAttniFlagsNEW_PITCH)
    return 
FMRES_SUPERCEDE



ConnorMcLeod 10-05-2009 00:54

Re: Change pitch for all sounds
 
Because sounds can be emmitted by other ents than players (i guess your array is 33 sized).

tolsty 10-05-2009 11:23

Re: Change pitch for all sounds
 
yes it is, how big should it be ?

ConnorMcLeod 10-05-2009 11:32

Re: Change pitch for all sounds
 
33, but add this check that will fix the error (g_iMaxPlayers is a global var and it's value is get_maxplayers()):

PHP Code:

public EmitSound(const iEnt, const iChan, const szSample[], const Float:fVol, const Float:fAttn, const iFlags, const iPitch)
{
    if ( (
1<=iEnt<=g_iMaxPlayers) && g_bInRadius[iEnt] == false )
    {
        return 
FMRES_HANDLED
    
}
    
emit_sound(iEntiChanszSamplefVolfAttniFlagsNEW_PITCH)
    return 
FMRES_SUPERCEDE



tolsty 10-05-2009 11:45

Re: Change pitch for all sounds
 
Nevermind i figured it out my self, that i have to check is the ent a player xD, thanx anyway


All times are GMT -4. The time now is 22:42.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.