Raised This Month: $ Target: $400
 0% 

[Solved]Spk/Speak Volume-Undesired Outcome Ingame


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tryout101
Member
Join Date: Mar 2009
Old 02-05-2013 , 20:22   [Solved]Spk/Speak Volume-Undesired Outcome Ingame
Reply With Quote #1

Hi there guys,

I have a weather plugin, not of my own code, but am trying to edit a part of it. But that is not what this post is about. It is just background info.

I know very little about scripting pawn, but enough to be able to customize plugins to my wants.

Anyways, a function within that weather plugin calls to emit an ambience rain sound on all clients [rain.wav] in condition zero when entity rain is in effect. However in game, it plays too loud and players dislike it.

So I did my research and found bits an pieces on how to control the spk command volume as follows :

1. client_cmd(0, "spk ambience/rain(v40)");
2. client_cmd(0, "spk ambience/rain.wav",40);

I went ahead to make a simple test plugin to see the results in action :

PHP Code:
#include <amxmodx>

public plugin_init(){
    
register_plugin("Volume Control""1""Meh..");
    
register_clcmd("say a","volume_c0");
    
register_clcmd("say s","volume_c1");
}

public 
volume_c0(){
    
client_cmd(0"spk ambience/rain.wav",40);
}

public 
volume_c1(){
   
client_cmd(0"spk ambience/rain(v40)");

The problem here is, in CS:CZ, is that the results are not favorable. What actually happens is, when the sound file activates it plays at normal volume[loud]. But when I shoot or knife the ground it only then changes to specified volume in the command. In addition the volume slowly raises back to normal volume within seconds if I remain idle.

Does anyone know whats going on and how this can be fixed?

Last edited by tryout101; 02-12-2013 at 20:39. Reason: Solved
tryout101 is offline
Kard1nal
Senior Member
Join Date: Dec 2012
Location: Russia
Old 02-06-2013 , 10:48   Re: Spk param volume unable emit static specified vol
Reply With Quote #2

If you want to fix volume, use emit_sound.
PHP Code:
emit_sound (indexchannelsample[], Float:volFloat:att,flagspitch

Float:vol - volume.

Last edited by Kard1nal; 02-06-2013 at 10:49.
Kard1nal is offline
Send a message via Skype™ to Kard1nal
tryout101
Member
Join Date: Mar 2009
Old 02-06-2013 , 14:35   Re: Spk param volume unable emit static specified vol
Reply With Quote #3

I see.. I did learn of that command, but what I understood of it was that it emits sound from a specific area/origin and spreads to a defined area units or whole area... unless I'm wrong?

I feel executing the spk command on all clients is the right way to handle rain ambience sound that comes with rain entity created; am I right to assume so?

If so, how can I have the volume stay at a fixed rate without it starting out at normal volume and or raising back to normal 100% volume? If not, how would i go about setting up emit_sound...

PHP Code:

emit_sound 
indexchannel, const sample[], Float:volFloat:attflagspitch 

emit_sound (32CHAN_AUTO"ambience/rain.wav"0.3 0.0PITCH_NORM 
With [index of 32 players], [channel of stream? or auto?], [volume of 0.3 float], and are the rest of the values correct?

I would appreciate that. Thank you.

Last edited by tryout101; 02-07-2013 at 01:36.
tryout101 is offline
dejan
Senior Member
Join Date: Mar 2009
Location: Sweden
Old 02-07-2013 , 09:20   Re: Volume for spk does not take effect ingame.
Reply With Quote #4

if you want to play the sound for everybody set index to 0

if you want to config emit_sound how you want it click Here
__________________
dejan is offline
Send a message via Skype™ to dejan
tryout101
Member
Join Date: Mar 2009
Old 02-11-2013 , 00:20   Re: Volume for spk does not take effect ingame.
Reply With Quote #5

Fine enough.. but as a final to this call of help. I would like to know why [spk] command doesn't apply the volume parameter, if anyone knows? and why emit_sound is better in the situation of emitting rain ambience sound is better than spk?

Please I would appreciate it.
tryout101 is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 02-11-2013 , 08:37   Re: Volume for spk does not take effect ingame.
Reply With Quote #6

Quote:
Originally Posted by dejan View Post
if you want to play the sound for everybody set index to 0

if you want to config emit_sound how you want it click Here
I don't think that's correct. The first parameter is the index of an entity the sound should come from, if it's 0, the server will most likely crash or you'll get an error in the log. If you want to play it for everyone, use the client command spk or find an entity that could be used for this.


Quote:
Fine enough.. but as a final to this call of help. I would like to know why [spk] command doesn't apply the volume parameter, if anyone knows? and why emit_sound is better in the situation of emitting rain ambience sound is better than spk?
The spk command plays a sound for the player, it uses the volume from their settings. emit_sound is not better for such things overall - first off if this sound wasn't already precached, you'd have to use precache_sound instead of precache_generic and more easily fill up your 512 precache limit. spk also allows the clients to stop the sound by using the stopsound command - you should select which to use while taking these two facts in mind.

Last edited by Backstabnoob; 02-11-2013 at 08:40.
Backstabnoob is offline
tryout101
Member
Join Date: Mar 2009
Old 02-11-2013 , 18:35   Re: Volume for spk does not take effect ingame.
Reply With Quote #7

That is correct, the user notes stated that for emit_sound on one the wiki page for that command that the index was for player values of between 1-32, unless if I am mistaken?

And thank you very much for the details of information you provided on both commands @Backstab. I thank you for that.

The ambience sound file [rain.wav] appears to be part of the game files that come with the game. Because as of yet it hasn't ever forced anyone to download it either through server or http. So I am good on that note.

It is interesting to know that spk command uses the clients value for sound volume. Which brings me to a specific but perhaps off topic question.

Why is it condition zero, that the volume bar for the game sounds (likely wav files) does not function properly? For example, the difference in 1% to full length 100% scroll, is indistinguishable. And when the bar is lower < 1.0 it takes effect on the volume level.

And even then, in-game the volume specified does not take effect until I have shot or hit something with knife, and even then the volume returns to client specified volume rather than command specified volume.

Perhaps @backstab you may know something on this, or is it a cz bug? Thank you.

Last edited by tryout101; 02-11-2013 at 18:37.
tryout101 is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 02-12-2013 , 09:49   Re: Volume for spk does not take effect ingame.
Reply With Quote #8

Quote:
Originally Posted by Backstabnoob View Post
I don't think that's correct. The first parameter is the index of an entity the sound should come from, if it's 0, the server will most likely crash or you'll get an error in the log. If you want to play it for everyone, use the client command spk or find an entity that could be used for this.
Code:
static cell AMX_NATIVE_CALL emit_sound(AMX *amx, cell *params) /* 7 param */ {     int len;     char* szSample = get_amxstring(amx, params[3], 0, len);     REAL vol = amx_ctof(params[4]);     REAL att = amx_ctof(params[5]);     int channel = params[2];     int pitch = params[7];     int flags = params[6];     if (params[1] == 0)     {         for (int i = 1; i <= gpGlobals->maxClients ; ++i)         {             CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);                         if (pPlayer->ingame)                 EMIT_SOUND_DYN2(pPlayer->pEdict, channel, szSample, vol, att, flags, pitch);         }     } else {         edict_t* pEdict = INDEXENT(params[1]);                 if (!FNullEnt(pEdict))             EMIT_SOUND_DYN2(pEdict, channel, szSample, vol, att, flags, pitch);     }     return 1; }

Nice one buddy
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
tryout101
Member
Join Date: Mar 2009
Old 02-12-2013 , 14:42   Re: Volume for spk does not take effect ingame.
Reply With Quote #9

Thank you for your reply @Metalic.

I wish you had explained more for an easier understanding, but.. from what I can pick up, does it mean?

That the index is for players only?

In any case, I have been experimenting with the following code, and the sound and volume emits fine which solves my problem, but.. it creates a new issue, the sound is not emitted the way it is with [speak]. For example :

With [emit_sound] the ambience sound file emits sounds from different speakers at varying distances. If I face a certain direction, the sound emits from one of my speakers while the other remains silent. The same happens if I face the opposite of that direction. And I am left with only able to hear the rain sound at equal volume from both speakers facing only two opposing directions, while as I turn with mouse the sound switches speakers.

What I would like to achieve is, the sound coming equally from both speakers for all clients as the way speak command handles it?

PHP Code:
#include <amxmodx>

public plugin_init(){
    
register_plugin("Volume Control""1.0""SKLS");
    
register_clcmd("say a","volume_a");
    
register_clcmd("say s","volume_s");
    
register_clcmd("say d","volume_stop");
    
register_clcmd("say f","volume_emitt");
}

public 
plugin_precache(){
    
precache_sound("ambience/rain.wav");
    
precache_sound("ambience/thunder_clap.wav");
    
//weather_ent = CREATE_ENTITY("env_rain")
}

public 
volume_a(){
    
emit_sound (32CHAN_STREAM"ambience/rain.wav"0.3ATTN_NONE0PITCH_NORM);
    
//client_cmd(0, "speak ambience/rain.wav",10);
    
return PLUGIN_HANDLED;
}

public 
volume_s(){
    
emit_sound (32CHAN_BODY"ambience/rain.wav"0.3ATTN_NONE0PITCH_NORM);
    
//client_cmd(0, "speak ambience/rain(v1)");
    
return PLUGIN_HANDLED;
}

public 
volume_stop(){
    
client_cmd(0"stopsound");
    return 
PLUGIN_HANDLED;
}

public 
volume_emitt(){
     
emit_sound (32CHAN_STATIC"ambience/rain.wav"0.3ATTN_NONE0PITCH_NORM);
     return 
PLUGIN_HANDLED;
    
//emit_sound ( index, channel, const sample[], Float:vol, Float:att, flags, pitch );


The channels, (BODY/STREAM/STATIC), does not have any effect on the outcome. And if I change the value of ATTN to anything but NONE, the sound is not emitted.

Last edited by tryout101; 02-12-2013 at 14:46.
tryout101 is offline
tryout101
Member
Join Date: Mar 2009
Old 02-12-2013 , 15:10   Re: [Solved]Spk/Speak Volume-Undesired Outcome Ingame
Reply With Quote #10

Alright guys... Thank you to each one of you who contributed.

I somehow got it solved by inserting the command in the original weather plugin, and the sound emits fine at the volume specified, and emits correctly through both speakers in disregards to direction of view.

The following is the command that was inserted :
PHP Code:

emit_sound
(1CHAN_STREAM"ambience/rain.wav"0.3ATTN_NORM0PITCH_NORM); 
Which replaced :

PHP Code:
client_cmd(id"speak ambience/rain.wav"); 
Now I don't know why it worked in the original plugin with ATTN_NORM and not in my test plugin. And I don't know of the index is correct, but either way I can change the index between 1-32 if any issues arises.

If someone has more to share on the issue, please do so. ^_^

Last edited by tryout101; 02-12-2013 at 15:45.
tryout101 is offline
Reply



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 03:59.


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