Difference between revisions of "playSound3D"

From Bohemia Interactive Community
Jump to navigation Jump to search
(see also)
 
(43 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Command|= Comments
+
{{RV|type=command
____________________________________________________________________________________________
 
  
| arma3 |= Game name
+
|game1= arma3
 +
|version1= 0.50
  
|0.50|= Game version
+
|arg= global
  
|arg= global |= Arguments in MP
+
|eff= global
  
|eff= global |= Effects in MP
+
|gr1= Sounds
____________________________________________________________________________________________
 
  
| Plays positional sound with given filename on every computer on network. At least 2 parameters must be specified.  |DESCRIPTION=
+
|descr= Plays positional sound with given ''filename'' on every computer on network.
____________________________________________________________________________________________
 
  
| '''playSound3D''' [filename, soundSource, isInside, soundPosition, volume, soundPitch, distance] |SYNTAX=
+
|s1= [[playSound3D]] [filename, soundSource, isInside, soundPosition, volume, soundPitch, distance, offset, local]
  
|p1= [filename, soundSource, isInside, soundPosition, volume, soundPitch, distance]: [[Array]] |PARAMETER1=
+
|p1= filename: [[String]] - See [[Arma 3: Sound Files]] for available file names or [[#Examples|Example 3]] to use mission files
  
|p2= filename: [[String]] - see [[Arma_3:_SoundFiles]] for available filenames |PARAMETER2=
+
|p2= soundSource: [[Object]] - The object emitting the sound. If "sound position" is specified this parameter is ignored
  
|p3= soundSource: [[Object]] - the object emitting the sound. If "sound position" is specified this param is ignored |PARAMETER3=
+
|p3= isInside: [[Boolean]] - (Optional, default [[false]]) - [[true|True]] to simulate a sound played inside a building or similar
  
|p4= isInside: [[Boolean]] (optional) Default: [[false]]|PARAMETER4=
+
|p4= soundPosition: [[PositionASL]] - (Optional, default [0,0,0]) Position for sound emitter. Will override "soundSource" position.
  
|p5= soundPosition: [[PositionASL]] (optional) - position for sound emitter, will override "sound source" position. Default: [0,0,0]  |PARAMETER5=
+
|p5= volume: [[Number]] - (Optional, default 1) Sound volume. A value {{ic|>5}} get capped at 5
  
|p6= volume: [[Number]] (optional) Default: 1 |PARAMETER6=
+
|p6= soundPitch: [[Number]] - (Optional, default 1)
 +
* 1 → Normal
 +
* 0.5 → Darth Vader
 +
* 2 → Chipmunks
  
|p7= soundPitch: [[Number]] (optional) - 1: Normal, 0.5: Darth Vader, 2: Chipmunks, etc. Default: 1    |PARAMETER7=
+
|p7= distance: [[Number]] - (Optional, default 0) How far the sound is audible. {{ic|0}} means no maximum distance
  
|p8= distance: [[Number]] (optional) - How far is sound audible (0 <nowiki>=</nowiki> no max distance) Default: 0. |PARAMETER8=
+
|p8= offset: [[Number]] - (Optional, default 0) Offset in seconds. Same as with [[playMusic]] {{Since|arma3|2.00|true}}
  
| [[Nothing]] |RETURNVALUE=
+
|p9= local: [[Boolean]] - (Optional, default [[false]]) If [[true]] the sound will not be broadcast over network {{Since|arma3|2.05.147858|true}}
  
 +
|r1= [[Nothing]]
  
|x1= <code>[[playSound3D]] ["A3\Sounds_F\sfx\blip1.wav", [[player]]]</code>|EXAMPLE1=
+
|x1= <code>[[playSound3D]] ["A3\Sounds_F\sfx\blip1.wav", [[player]]]</code>
|x2= <code>[[playSound3D]] ["A3\Sounds_F\sfx\blip1.wav", [[player]], [[false]], [[getPosASL]] [[player]], 1, 1, 0]</code>|EXAMPLE2=
 
|x3= Sound file extension must be specified even if a config entry has none:
 
<code>[[playSound3D]] ["A3\Sounds_F\sfx\alarm_independent", [[player]]]; //no sound
 
[[playSound3D]] ["A3\Sounds_F\sfx\alarm_independent.wss", [[player]]]; //alarm</code>|EXAMPLE3=
 
  
____________________________________________________________________________________________
+
|x2= <code>[[playSound3D]] ["A3\Sounds_F\sfx\blip1.wav", [[player]], [[false]], [[getPosASL]] [[player]], 1, 1, 0]</code>
  
| [[say3D]], [[playSound]], [[say2D]], [[say]], [[createSoundSource]] [[setRandomLip]] |SEEALSO=
+
|x3= <code>[[playSound3D]] [<nowiki/>[[getMissionPath]] "mySound.ogg", [[player]]]; {{cc|to play a mission directory sound}}</code>
  
| |MPBEHAVIOUR=  
+
|x4= Sound file extension must be specified even if a config entry has none:
____________________________________________________________________________________________
+
<code>[[playSound3D]] ["A3\Sounds_F\sfx\alarm_independent", [[player]]]; {{cc|no sound}}
 +
[[playSound3D]] ["A3\Sounds_F\sfx\alarm_independent.wss", [[player]]]; {{cc|alarm}}</code>
 +
 
 +
|seealso= [[say3D]], [[playSound]], [[say2D]], [[say]], [[createSoundSource]], [[setRandomLip]], [[getMissionPath]]
 
}}
 
}}
  
<h3 style='display:none'>Notes</h3>
+
<dl class="command_description">
<dl class='command_description'>
 
<!-- Note Section BEGIN -->
 
  
<dd class="notedate">Posted on September 23, 2013
+
<dt><dt>
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''
 
<dd class="note">This command works well with addon sounds, however getting it to play mission sound files is a bit tricky. Follow [http://killzonekid.com/arma-scripting-tutorials-mission-root/ this guide]
 
<br><br>
 
 
 
 
 
<!-- Note Section END -->
 
</dl>
 
 
 
<h3 style='display:none'>Bottom Section</h3>
 
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
 
 
 
<!-- CONTINUE Notes -->
 
<dl class="command_description">
 
 
<dd class="notedate">Posted on September 26, 2014 - 09:18 (UTC)</dd>
 
<dd class="notedate">Posted on September 26, 2014 - 09:18 (UTC)</dd>
 
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
 
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
Line 74: Line 58:
 
Currently, [[playSound3D]] is not JIP compatible, so joining players will not hear the sound if is started before and is still playing when player joins.
 
Currently, [[playSound3D]] is not JIP compatible, so joining players will not hear the sound if is started before and is still playing when player joins.
 
</dd>
 
</dd>
</dl>
 
<!-- DISCONTINUE Notes -->
 
  
<!-- CONTINUE Notes -->
+
<dt><dt>
<dl class="command_description">
 
<dd class="notedate">Posted on October 16, 2013 - 08:21 (UTC)
 
<dt class="note">'''[[User:JacmacBrian|Jacmac]]'''
 
<dd class="note">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:
 
<code>_soundPath = [([[str]] [[missionConfigFile]]), 0, -15] call BIS_fnc_trimString;
 
_soundToPlay = _soundPath + "sounds\some_sound_file.ogg";
 
playSound3D [_soundToPlay, _sourceObject, [[false]], getPos _sourceObject, 10, 1, 50];
 
//Volume db+10, volume drops off to 0 at 50 meters from _sourceObject</code>
 
</dd>
 
</dl>
 
<dl class="command_description">
 
 
<dd class="notedate">Posted on November 8, 2014 - 21:48 (UTC)</dd>
 
<dd class="notedate">Posted on November 8, 2014 - 21:48 (UTC)</dd>
 
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
 
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
Line 94: Line 65:
 
When object is supplied but not a position, the position is taken from object, otherwise the position is taken from supplied position. That doesn't mean that when position is taken from object it is going to follow object when it changes position. The sound is generated at object position and it stays there.<br><br>One other important note: If <i>soundSource</i> param is [[objNull]] then his command develops the same bug with first person view as [[createSoundSource]] and [[say3D]]. If <i>soundSource</i> param is [[player]] then the bug is inverted. It seems that passing [[vehicle]] [[player]] as <i>soundSource</i> param is the only way to make it behave correctly when vehicles involved.
 
When object is supplied but not a position, the position is taken from object, otherwise the position is taken from supplied position. That doesn't mean that when position is taken from object it is going to follow object when it changes position. The sound is generated at object position and it stays there.<br><br>One other important note: If <i>soundSource</i> param is [[objNull]] then his command develops the same bug with first person view as [[createSoundSource]] and [[say3D]]. If <i>soundSource</i> param is [[player]] then the bug is inverted. It seems that passing [[vehicle]] [[player]] as <i>soundSource</i> param is the only way to make it behave correctly when vehicles involved.
 
</dd>
 
</dd>
 +
 +
<dt></dt>
 +
<dd class="notedate">Posted on October 7, 2020 - 12:24 (UTC)</dd>
 +
<dt class="note">[[User:R3vo|R3vo]]</dt>
 +
<dd class="note">
 +
The sound will be distorted according to the {{Wikipedia|Doppler_effect|doppler effect}} when passing by the sound source quickly.
 +
</dd>
 +
 
</dl>
 
</dl>
<!-- DISCONTINUE Notes -->
 

Latest revision as of 16:34, 6 July 2021

Hover & click on the images for description

Description

Description:
Plays positional sound with given filename on every computer on network.
Groups:
Sounds

Syntax

Syntax:
playSound3D [filename, soundSource, isInside, soundPosition, volume, soundPitch, distance, offset, local]
Parameters:
filename: String - See Arma 3: Sound Files for available file names or Example 3 to use mission files
soundSource: Object - The object emitting the sound. If "sound position" is specified this parameter is ignored
isInside: Boolean - (Optional, default false) - True to simulate a sound played inside a building or similar
soundPosition: PositionASL - (Optional, default [0,0,0]) Position for sound emitter. Will override "soundSource" position.
volume: Number - (Optional, default 1) Sound volume. A value >5 get capped at 5
soundPitch: Number - (Optional, default 1)
  • 1 → Normal
  • 0.5 → Darth Vader
  • 2 → Chipmunks
distance: Number - (Optional, default 0) How far the sound is audible. 0 means no maximum distance
offset: Number - (Optional, default 0) Offset in seconds. Same as with playMusic Since Arma 3 v2.00
local: Boolean - (Optional, default false) If true the sound will not be broadcast over network Since Arma 3 v2.05.147858
Return Value:
Nothing

Examples

Example 1:
playSound3D ["A3\Sounds_F\sfx\blip1.wav", player]
Example 2:
playSound3D ["A3\Sounds_F\sfx\blip1.wav", player, false, getPosASL player, 1, 1, 0]
Example 3:
playSound3D [getMissionPath "mySound.ogg", player]; // to play a mission directory sound
Example 4:
Sound file extension must be specified even if a config entry has none: playSound3D ["A3\Sounds_F\sfx\alarm_independent", player]; // no sound playSound3D ["A3\Sounds_F\sfx\alarm_independent.wss", player]; // alarm

Additional Information

See also:
say3DplaySoundsay2DsaycreateSoundSourcesetRandomLipgetMissionPath

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Posted on September 26, 2014 - 09:18 (UTC)
Killzone Kid
Currently, playSound3D is not JIP compatible, so joining players will not hear the sound if is started before and is still playing when player joins.
Posted on November 8, 2014 - 21:48 (UTC)
Killzone Kid
When object is supplied but not a position, the position is taken from object, otherwise the position is taken from supplied position. That doesn't mean that when position is taken from object it is going to follow object when it changes position. The sound is generated at object position and it stays there.

One other important note: If soundSource param is objNull then his command develops the same bug with first person view as createSoundSource and say3D. If soundSource param is player then the bug is inverted. It seems that passing vehicle player as soundSource param is the only way to make it behave correctly when vehicles involved.
Posted on October 7, 2020 - 12:24 (UTC)
R3vo
The sound will be distorted according to the doppler effect when passing by the sound source quickly.