playSound3D: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "(\| * )+\}\}" to "}}")
(Add note about leading antislash, thanks ilbinek)
 
(74 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Command
{{RV|type=command


| arma3
|game1= arma3
 
|version1= 0.50
|0.50


|arg= global
|arg= global
Line 11: Line 10:
|gr1= Sounds
|gr1= Sounds


| Plays positional sound with given filename on every computer on network. At least 2 parameters must be specified.
|descr= Plays positional sound with given ''filename'' on every computer on network.
{{Important | Since A3 v1.91.145537 the maximum volume allowed is '''5'''. Exceeding this will result in sound not being played when executed remotely.}}


| [[playSound3D]] [filename, soundSource, isInside, soundPosition, volume, soundPitch, distance, offset]
|s1= [[playSound3D]] [filename, soundSource, isInside, soundPosition, volume, soundPitch, distance, offset, local]


|p1= filename: [[String]] - see [[Arma 3: Sound Files]] for available filenames or [[#Examples|Example 3]] to use mission files.
|p1= filename: [[String]] - see [[Arma 3: Sound Files]] for available file names or {{Link|#Example 3}} to use mission files


|p2= soundSource: [[Object]] - the object emitting the sound. If "sound position" is specified this parameter is ignored
{{Feature|important|
Since {{GVI|arma3|2.10|size= 0.75}} the file name can start with a leading backslash {{hl|'''\'''a3\...}}.<br>
However a leading backslash must '''not''' be used for an '''addon''' sound file.
}}


|p3= isInside: [[Boolean]] - (Optional, default [[false]])
|p2= soundSource: [[Object]] - the object emitting the sound. If ''soundPosition'' below is specified this parameter is ignored


|p4= soundPosition: [[PositionASL]] - (Optional, default [0,0,0]) position for sound emitter, will override "sound source" position.
|p3= isInside: [[Boolean]] - (Optional, default [[false]]) - [[true]] to simulate a sound played inside a building or similar


|p5= volume: [[Number]] - (Optional, default 1) Maximum value: 5 (limited since A3 v1.91.145537)
|p4= soundPosition: [[Array]] format [[Position#PositionASL|PositionASL]] - (Optional, default [0,0,0]) position for sound emitter, overrides ''soundSource''
{{Feature|informative|If a following parameter has to be used, simply use <sqf inline>getPosASL _soundSource</sqf> for ''soundPosition'' instead of <sqf inline>_soundSource</sqf> for ''soundSource''.}}
{{Feature|important|This parameter also takes [[Object]] but their [[Position#PositionAGL|AGL]] position is used instead of [[Position#PositionASL|ASL]] resulting in sound source being underground if they're above ground, always use [[Position#PositionASL|PositionASL]] instead.}}


|p6= soundPitch: [[Number]] - (Optional, default 1) 1: Normal, 0.5: Darth Vader, 2: Chipmunks, etc.
|p5= volume: [[Number]] - (Optional, default 1) sound volume. A value greater than 5 gets capped


|p7= distance: [[Number]] - (Optional, default 0) How far is sound audible (0 {{=}} no max distance)
|p6= soundPitch: [[Number]] - (Optional, default 1)
* 1.0 &rarr; normal
* 0.5 &rarr; Darth Vader
* 2.0 &rarr; Chipmunks


|p8= offset: [[Scalar]] - (Optional, default 0) Offset in seconds. Same as with [[playMusic]] {{Since|arma3|1.99.146480|true}}
|p7= distance: [[Number]] - (Optional, default 0) how far the sound is audible, in meters. {{hl|0}} means no maximum distance


| [[Nothing]]
|p8= offset: [[Number]] - (Optional, default 0) offset in seconds. Same as with [[playMusic]]
|p8since= arma3 2.00


|x1= <code>[[playSound3D]] ["A3\Sounds_F\sfx\blip1.wav", [[player]]]</code>
|p9= local: [[Boolean]] - (Optional, default [[false]]) if [[true]] the sound will not be broadcast over network
|p9since= arma3 2.06


|x2= <code>[[playSound3D]] ["A3\Sounds_F\sfx\blip1.wav", [[player]], [[false]], [[getPosASL]] [[player]], 1, 1, 0]</code>
|r1= [[Number]] - id of the sound (0..65535) (was [[Nothing]] before {{GVI|arma3|2.12|size= 0.75}})


|x3= <code>[[playSound3D]] [<nowiki/>[[getMissionPath]] "mySound.ogg", [[player]]]; {{cc|to play a mission directory sound}}</code>
|x1= <sqf>playSound3D ["A3\Sounds_F\sfx\blip1.wss", player];</sqf>


|x4= Sound file extension must be specified even if a config entry has none:
|x2= <sqf>playSound3D ["A3\Sounds_F\sfx\blip1.wss", player, false, getPosASL player, 1, 1, 0];</sqf>
<code>[[playSound3D]] ["A3\Sounds_F\sfx\alarm_independent", [[player]]]; {{cc|no sound}}
[[playSound3D]] ["A3\Sounds_F\sfx\alarm_independent.wss", [[player]]]; {{cc|alarm}}</code>


|x3= <sqf>playSound3D [getMissionPath "mySound.ogg", player]; // to play a mission directory sound</sqf>


| [[say3D]], [[playSound]], [[say2D]], [[say]], [[createSoundSource]], [[setRandomLip]], [[getMissionPath]]
|x4= Sound file extension must be specified even if a config entry has none:
<sqf>
playSound3D ["A3\Sounds_F\sfx\alarm_independent", player]; // no sound
playSound3D ["A3\Sounds_F\sfx\alarm_independent.wss", player]; // alarm
</sqf>


|seealso= [[say3D]] [[playSound]] [[say2D]] [[say]] [[createSoundSource]] [[setRandomLip]] [[getMissionPath]] [[playSoundUI]]
}}
}}


<dl class='command_description'>
{{Note
<!-- Note Section BEGIN -->
|user= Killzone_Kid
|timestamp= 20140926091800
|text= 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 class="notedate">Posted on September 26, 2014 - 09:18 (UTC)</dd>
{{Note
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
|user= Killzone_Kid
<dd class="note">
|timestamp= 20141108214800
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.
|text= 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>
</dd>
One other important note: If <i>soundSource</i> param is [[objNull]] then this command develops the same bug with first person view as [[createSoundSource]] and [[say3D]]. If ''soundSource'' 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 class="notedate">Posted on November 8, 2014 - 21:48 (UTC)</dd>
{{Note
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
|user= R3vo
<dd class="note">
|timestamp= 20201007122400
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.
|text= The sound will be distorted according to the {{Link|https://en.wikipedia.org/wiki/Doppler_effect}} when passing by the sound source quickly.
</dd>
}}


<!-- Note Section END -->
{{Note
</dl>
|user= Hypoxic125
|timestamp= 20230514135752
|text= Wait for sound to end:


 
<sqf>
<!-- CONTINUE Notes -->
private _sound = playSound3D ["A3\Sounds_F\sfx\blip1.wss", player];
<dl class="command_description">
waitUntil { soundParams _sound isEqualTo [] };
<dd class="notedate">Posted on October 7, 2020 - 12:24 (UTC)</dd>
</sqf>
<dt class="note">[[User:R3vo|R3vo]]</dt>
}}
<dd class="note">
The sound will be distorted according to the [https://en.wikipedia.org/wiki/Doppler_effect doppler effect] when passing by the sound source quickly.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 20:54, 28 May 2024

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
Since Arma 3 logo black.png2.10 the file name can start with a leading backslash \a3\....
However a leading backslash must not be used for an addon sound file.
soundSource: Object - the object emitting the sound. If soundPosition below is specified this parameter is ignored
isInside: Boolean - (Optional, default false) - true to simulate a sound played inside a building or similar
soundPosition: Array format PositionASL - (Optional, default [0,0,0]) position for sound emitter, overrides soundSource
If a following parameter has to be used, simply use getPosASL _soundSource for soundPosition instead of _soundSource for soundSource.
This parameter also takes Object but their AGL position is used instead of ASL resulting in sound source being underground if they're above ground, always use PositionASL instead.
volume: Number - (Optional, default 1) sound volume. A value greater than 5 gets capped
soundPitch: Number - (Optional, default 1)
  • 1.0 → normal
  • 0.5 → Darth Vader
  • 2.0 → Chipmunks
distance: Number - (Optional, default 0) how far the sound is audible, in meters. 0 means no maximum distance
since Arma 3 logo black.png2.00
offset: Number - (Optional, default 0) offset in seconds. Same as with playMusic
since Arma 3 logo black.png2.06
local: Boolean - (Optional, default false) if true the sound will not be broadcast over network
Return Value:
Number - id of the sound (0..65535) (was Nothing before Arma 3 logo black.png2.12)

Examples

Example 1:
playSound3D ["A3\Sounds_F\sfx\blip1.wss", player];
Example 2:
playSound3D ["A3\Sounds_F\sfx\blip1.wss", 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:
say3D playSound say2D say createSoundSource setRandomLip getMissionPath playSoundUI

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
Killzone_Kid - c
Posted on Sep 26, 2014 - 09:18 (UTC)
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.
Killzone_Kid - c
Posted on Nov 08, 2014 - 21:48 (UTC)
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 this command develops the same bug with first person view as createSoundSource and say3D. If soundSource 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.
R3vo - c
Posted on Oct 07, 2020 - 12:24 (UTC)
The sound will be distorted according to the Doppler effect when passing by the sound source quickly.
Hypoxic125 - c
Posted on May 14, 2023 - 13:57 (UTC)
Wait for sound to end:
private _sound = playSound3D ["A3\Sounds_F\sfx\blip1.wss", player]; waitUntil { soundParams _sound isEqualTo [] };