Raised This Month: $ Target: $400
 0% 

Change pitch for all sounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tolsty
Senior Member
Join Date: Feb 2008
Location: Latvia
Old 10-04-2009 , 11:53   Change pitch for all sounds
Reply With Quote #1

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
__________________
[IMG]http://img2.**************/img2/7173/signfp.jpg[/IMG]
tolsty is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-04-2009 , 13:30   Re: Change pitch for all sounds
Reply With Quote #2

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 )
__________________
Arkshine is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-04-2009 , 15:31   Re: Change pitch for all sounds
Reply With Quote #3

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)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
tolsty
Senior Member
Join Date: Feb 2008
Location: Latvia
Old 10-04-2009 , 19:02   Re: Change pitch for all sounds
Reply With Quote #4

<3 connor, +

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

__________________
[IMG]http://img2.**************/img2/7173/signfp.jpg[/IMG]

Last edited by tolsty; 10-04-2009 at 19:28.
tolsty is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-05-2009 , 00:54   Re: Change pitch for all sounds
Reply With Quote #5

Because sounds can be emmitted by other ents than players (i guess your array is 33 sized).
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
tolsty
Senior Member
Join Date: Feb 2008
Location: Latvia
Old 10-05-2009 , 11:23   Re: Change pitch for all sounds
Reply With Quote #6

yes it is, how big should it be ?
__________________
[IMG]http://img2.**************/img2/7173/signfp.jpg[/IMG]
tolsty is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-05-2009 , 11:32   Re: Change pitch for all sounds
Reply With Quote #7

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

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
tolsty
Senior Member
Join Date: Feb 2008
Location: Latvia
Old 10-05-2009 , 11:45   Re: Change pitch for all sounds
Reply With Quote #8

Nevermind i figured it out my self, that i have to check is the ent a player xD, thanx anyway
__________________
[IMG]http://img2.**************/img2/7173/signfp.jpg[/IMG]
tolsty is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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