Raised This Month: $51 Target: $400
 12% 

Solved Emitting sound *from* origin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kinsi
Senior Member
Join Date: Apr 2013
Old 05-10-2017 , 09:55   Emitting sound *from* origin?
Reply With Quote #1

Hey there,

i am currently in need to emit a sound from a given origin, similar to how gunfire works (You turn away from it and it still sounds like its coming from the origin, and not .. well .. everywhere).

I tried EmitAmbientSound with a given origin, the sound does get louder the closer i get to the origin (And originate from it according to snd_visualize) but changing my rotation to the origin still results in it playing from "everywhere" instead of having a "stereo" effect like gunfire. EmitSoundToAll didnt bring much of a change either.

Am i missing something? Do i really need a speaker entity?

PHP Code:
EmitAmbientSound("weapons/m4a1/m4a1_02.wav"view_as<float>({3960.1, -2585.7, -15241.9})); 
Thanks!

Last edited by Kinsi; 05-13-2017 at 13:31.
Kinsi is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 05-12-2017 , 05:48   Re: Emitting sound *from* origin?
Reply With Quote #2

Why not..
PHP Code:
int playerCount 0totalplayers[MAXPLAYERS+1];

for (
int i 1<= MaxClientsi++)
{
    if (!
IsClientInGame(i) || IsFakeClient(i))
    {
        continue;
    }
    
    
totalPlayers[playerCount++] = i;
}

float fSoundPos[3];
fSoundPos[0] = 3960.1;
fSoundPos[1] = -2585.7;
fSoundPos[2] = -15241.9;

EmitSound(totalPlayersplayerCount"weapons/m4a1/m4a1_02.wav"SOUND_FROM_WORLDSNDCHAN_WEAPON_____fSoundPos); 
?
cravenge is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 05-12-2017 , 11:14   Re: Emitting sound *from* origin?
Reply With Quote #3

Just tried it, your version suffers from the same issue. The sound does get louder the closer i am to the given origin, but its not "stereo", as in it seems to play from everywhere, and not from the given origin.
Kinsi is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 05-13-2017 , 00:20   Re: Emitting sound *from* origin?
Reply With Quote #4

Weapon sounds are actually played in mono but the file is stereo. The Left line is the near sound, right is the far away sound (or mirrored dunno).
Just tell the engine to use special sound chacaters in the path.
PHP Code:
EmitAmbientSound(")weapons/m4a1/m4a1_02.wav"view_as<float>({3960.1, -2585.7, -15241.9})); 
or just use the names from the game_sounds*.txt
Code:
"Weapon_AWP.Single"
{
	"channel"		"CHAN_WEAPON"
	"soundlevel"		"SNDLVL_TALKING"
	"wave"		")weapons/awp/gunfire/awp1.wav"
}
PHP Code:
EmitAmbientGameSound("Weapon_AWP.Single"view_as<float>({3960.1, -2585.7, -15241.9})); 
Timocop is offline
Kinsi
Senior Member
Join Date: Apr 2013
Old 05-13-2017 , 13:31   Re: Emitting sound *from* origin?
Reply With Quote #5

Never knew that existed, that indeed was the solution. Thanks a lot!
Kinsi 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 18:31.


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