Jump to content
Sign in to follow this  
dragonsyr

play sounds on object position?????

Recommended Posts

I need to play a sound in position of an object.

i have this code

while{(_vehPlayer distance _helitarget > 10) && isEngineOn _vehPlayer} do {
		waitUntil {isEngineOn _vehPlayer};player say3D "contact"; //i want the pilot say this loud, so the crew of the heli hear that sound also
		hint"Your Engines is on";sleep 1;
                                      speaker playsound3d "c\sounds\mysound.ogg" //no errors but i cant hear nothing.
                                      speaker say3d "mysound";//i can hear it from anywere.

i found also that

_soundSource = createSoundSource ["LittleDog", position player, [], 0]

i dont now if this do that i want.

I want when a condition happents , to play a sound from the speaker pole (i dont want to hear the sound the caller, if is far from the speaker pole. only the players that is close to the speaker.)

is this possible?

Share this post


Link to post
Share on other sites

This works for me to play a sound at a flag pole in 3d. Can't be heard if too far away, and the sound lowers the further you are away. The below examples are tried and tested many many times. Unless 1.6 changed something.

flag1 say3D "Captured";

class CfgSounds 
{

  sounds[]={contested,captured,lostZone,neutral};

    class contested
    {
      name="contested";
      sound[]={"sounds\contested.ogg",.5,1};
      titles[]={};
    };

    class captured
    {
      name="captured";
      sound[]={"sounds\captured.ogg",.5,1};
      titles[]={};
    };

    class LostZone
    {
      name="LostZone";
      sound[]={"sounds\lostZone.ogg",.5,1};
      titles[]={};
    };

    class Neutral
    {
      name="Neutral";
      sound[]={"sounds\Neutral.ogg",.5,1};
      titles[]={};
    };


};

---------- Post added at 04:41 ---------- Previous post was at 04:39 ----------

If you want sound to work properly inside of a vehicle you need to use:

playSound ["SoundName", true];

Share this post


Link to post
Share on other sites

When you're in a vehicle and play a sound, it will be muffled unless using array overload and pass true as the second parameter.

if (player == assignedDriver (vehicle player)) then {
  playSound ["SoundName", true];
};

Should work fine to broadcast sound to a specific unit only (driver in this case). Then it couldn't possibly be broadcasted all over the map :)

Edited by Iceman77

Share this post


Link to post
Share on other sites

i need the player , in this case as driver , to speak in the chopper and the other players can hear the sound. next sound in code sequence is one sound to the speaker pole say3d . when i do that, when i m in heli and im 500 meters away of the pole, i hear the sound of the pole loud and clear. i dont know if the sound broadcasting from the pole.

with this

if (player == assignedDriver (vehicle player)) then {

playSound ["SoundName", true];

};

hears only the caller. i cant see in this code where play the sound . i need speakers for multiplayer not singleplay.

---------- Post added at 17:59 ---------- Previous post was at 17:57 ----------

what this does??

_soundSource = createSoundSource ["LittleDog", position player, [], 0]

Share this post


Link to post
Share on other sites

1. say3d is what you need. I've posted a working example from a finished project in post #2.

2. It was simply an example of how to get sounds to work properly in a vehicle :). You can run the sound on whatever client(s) you want, whenever you want.

3. Not sure what that does. I've never messed with it and I can't ever remember seeing it.

Edited by Iceman77

Share this post


Link to post
Share on other sites

this give me an error missing ;

_speakerheli playSound ["PrepForLand", true];

Share this post


Link to post
Share on other sites

Yeah I don't believe that's the correct syntax. It should be playSound ["SoundName", true]; as in post #2 at the bottom. Also, i thought you wanted to play a 3d sound so it isn't heard across the map? The playsound array overload was just an extra bit of useful info...

---------- Post added at 07:12 ---------- Previous post was at 07:10 ----------

1. say3d is what you need. I've posted a working example from a finished project in post #2.

2. It was simply an example of how to get sounds to work properly in a vehicle :). You can run the sound on whatever client(s) you want, whenever you want.

3. Not sure what that does. I've never messed with it and I can't ever remember seeing it.

^^^^^

Share this post


Link to post
Share on other sites

Playsound3d seems to work better for me.

I have a siren on a car, it's loud inside slightly louder out and fades at distance, fade distance is adjustable.

There is also an option to hear it inside and almost nothing outside the vehicle.

http://community.bistudio.com/wiki/playSound3D

Share this post


Link to post
Share on other sites

Very nice. say3d works great for me, I haven't even looked into playsound3D. More parameters eh?

Share this post


Link to post
Share on other sites

ok i make a test. i put the pole 2 miles away and it broadcast the sound... 2 miles for 50%sound loss ?????????????????? ok its working .... i need to lower db's i think....

its not only the code that i made but requires many files (sounds and other scripts) give me some time please so to have something for public right now everything is a total mesh :-))))) i try to figure out how things working

please give me some time

Share this post


Link to post
Share on other sites
ok its working .... i need to lower db's i think....

Good. You may want to look into what F2 has posted. Playsound3D looks much more robust.

Share this post


Link to post
Share on other sites
Playsound3d seems to work better for me.

I have a siren on a car, it's loud inside slightly louder out and fades at distance, fade distance is adjustable.

There is also an option to hear it inside and almost nothing outside the vehicle.

http://community.bistudio.com/wiki/playSound3D

i need this fade distance param

---------- Post added at 18:20 ---------- Previous post was at 18:19 ----------

@ F2k sel my mistake sorry iceman :-)

speaker playsound3d "c\sounds\mysound.ogg" //no errors but i cant hear nothing.

Edited by dragonsyr

Share this post


Link to post
Share on other sites

I've never fiddled with playsound3D. I will soon though because it's what I'll use over say3D lol. I'll post some working results as soon as I can. Or maybe someone else can post a working example in the mean time.

Share this post


Link to post
Share on other sites

To get the sound to work you need the right path it's slightly different but it is explained at the bottom of the page

You need to get the correct path for custom mission sounds. Use missionConfigFile with BIS_fnc_trimString (to trim off "description.ext"), then add your mission's sound directory and sound file:

_soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString;
_soundToPlay = _soundPath + "sounds\some_sound_file.ogg";// your path goes here
playSound3D [_soundToPlay, _sourceObject, false, getPos _sourceObject, 10, 1, 50]; //Volume db+10, volume drops off to 0 at 50 meters from _sourceObject

_sourceObject woud be vehicle object or unit

false = sound loud inside and outside of vehicle.

true = sound is like that of a radio loud inside fades quickly outside

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thanks. That'll save me the hassle once I get home haha. Much appreciated.

Share this post


Link to post
Share on other sites
_soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString;
_soundToPlay = _soundPath + "sounds\some_sound_file.ogg";// your path goes here
playSound3D [_soundToPlay, _sourceObject, false, getPos _sourceObject, 10, 1, 50]; //Volume db+10, volume drops off to 0 at 50 meters from _sourceObject

_sourceObject woud be vehicle object or unit

false = sound loud inside and outside of vehicle.

true = sound is like that of a radio loud inside fades quickly outside

is this right?

ex

//.............................................defines....................

_sound1 = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString;
_soundToPlay1 = _sound1 + "sounds\sound_0.ogg";// your path goes here
_sound2 = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString;
_soundToPlay2 = _sound2 + "sounds\sound_1.ogg";// your path goes here
//..............................................................................

playSound3D [_soundToPlay1, _myobject1, true, getPos _myobject1, 10, 1, 50];  // this is the command for use ?

playSound3D [_soundToPlay2, _myobject2, true, getPos _myobject2, 10, 1, 50]; // other command on same script
//..............................................................................


Edited by dragonsyr

Share this post


Link to post
Share on other sites

I don't see anything wrong but then I never tried two sounds.

You still need to create the class CfgSounds in description.ext as usual

Share this post


Link to post
Share on other sites

working !! thanks!

---------- Post added at 05:07 ---------- Previous post was at 03:42 ----------

Edited by dragonsyr

Share this post


Link to post
Share on other sites

i notice that the playsound3d is for static objects because if the object is on the move , then the sound hears to the position that you call the sound

ex. you r pilot flying and you call the sound like this

playSound3D [_sdplay3, player, true, getPos player, 10, 1, 20];

if you want to hear the sound , you must stop to the position that you call the script.

how can i stick the sound source to the player until the sound ends??

Share this post


Link to post
Share on other sites
On 12/7/2013 at 3:56 PM, dragonsyr said:

i notice that the playsound3d is for static objects because if the object is on the move , then the sound hears to the position that you call the sound

9 years old thread and im facing the same issue lol
say3d works but cant pump the volume up

Share this post


Link to post
Share on other sites
2 hours ago, AirShark said:

9 years old thread and im facing the same issue lol
say3d works but cant pump the volume up

You can increase volume using CfgSounds. This part:

// filename, volume, pitch, distance (optional)
sound[] = { "fx\wolf1.ogg", 1, 1, 100 };

Be sure to make distance sufficiently high, otherwise it will cap the volume.

Share this post


Link to post
Share on other sites
1 hour ago, _foley said:

You can increase volume using CfgSounds. This part:


// filename, volume, pitch, distance (optional)
sound[] = { "fx\wolf1.ogg", 1, 1, 100 };

Be sure to make distance sufficiently high, otherwise it will cap the volume.

 

the problem is that the volume in say3d is capped in first person view when you are inside the vehicle, as soon as you exit the vehicle or switch the view, your ears will explode lol 
i think say3d is more for scripted conversation rather than effects. and playsound3D uses ASL position and cannot be attached to moveable objects.

though i didnt try createSoundSource, i wonder if it can make the job done.

Share this post


Link to post
Share on other sites

The big yellow warning on wiki page for createSoundSource doesn't bode well 😅

Features like sirens on gendamerie van from the base game don't handle this well either. Afaik there is no way around this issue for sounds located in the 3D world.

  • Sad 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×