playSound3D: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "PositionASL" to "PositionASL")
No edit summary
(31 intermediate revisions by 4 users not shown)
Line 10: Line 10:
|gr1= Sounds
|gr1= Sounds


|descr= Plays positional sound with given ''filename'' on every computer on network.
|descr= Plays positional sound with given ''filename'' on every computer on network. Since Arma 2.10 the leading slash in file path will be ignored.


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


|p1= filename: [[String]] - See [[Arma 3: Sound Files]] for available file names or {{HashLink|#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
{{Feature|important|Before {{arma3}} v2.10, ''filename'' must '''not''' start with a leading slash {{hl|'''\'''a3\...}}.}}


|p2= soundSource: [[Object]] - The object emitting the sound. If "sound position" is specified this parameter is ignored
|p2= soundSource: [[Object]] - The object emitting the sound. If "sound position" is specified this parameter is ignored
Line 20: Line 21:
|p3= isInside: [[Boolean]] - (Optional, default [[false]]) - [[true]] to simulate a sound played inside a building or similar
|p3= isInside: [[Boolean]] - (Optional, default [[false]]) - [[true]] to simulate a sound played inside a building or similar


|p4= soundPosition: [[Position#PositionASL|PositionASL]] - (Optional, default [0,0,0]) Position for sound emitter. Will override "soundSource" position.
|p4= soundPosition: [[Array]] format [[Position#PositionASL|PositionASL]] - (Optional, default [0,0,0]) Position for sound emitter. Will override "soundSource" position.


|p5= volume: [[Number]] - (Optional, default 1) Sound volume. A value greater than 5 gets capped
|p5= volume: [[Number]] - (Optional, default 1) Sound volume. A value greater than 5 gets capped
Line 29: Line 30:
* 2.0 → Chipmunks
* 2.0 → Chipmunks


|p7= distance: [[Number]] - (Optional, default 0) How far the sound is audible, in meters. {{ic|0}} means no maximum distance
|p7= distance: [[Number]] - (Optional, default 0) How far the sound is audible, in meters. {{hl|0}} means no maximum distance


|p8= offset: [[Number]] - (Optional, default 0) Offset in seconds. Same as with [[playMusic]]
|p8= offset: [[Number]] - (Optional, default 0) Offset in seconds. Same as with [[playMusic]]
Line 37: Line 38:
|p9since= arma3 2.06
|p9since= arma3 2.06


|r1= [[Nothing]]
|r1= [[Nothing]] or [[Number]] - id of the sound (0...65535), since v2.14


|x1= <code>[[playSound3D]] ["A3\Sounds_F\sfx\blip1.wav", [[player]]]</code>
|x1= <sqf>playSound3D ["A3\Sounds_F\sfx\blip1.wss", player]</sqf>


|x2= <code>[[playSound3D]] ["A3\Sounds_F\sfx\blip1.wav", [[player]], [[false]], [[getPosASL]] [[player]], 1, 1, 0]</code>
|x2= <sqf>playSound3D ["A3\Sounds_F\sfx\blip1.wss", player, false, getPosASL player, 1, 1, 0]</sqf>


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


|x4= Sound file extension must be specified even if a config entry has none:
|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}}
<sqf>playSound3D ["A3\Sounds_F\sfx\alarm_independent", player]; // no sound
[[playSound3D]] ["A3\Sounds_F\sfx\alarm_independent.wss", [[player]]]; {{cc|alarm}}</code>
playSound3D ["A3\Sounds_F\sfx\alarm_independent.wss", player]; // alarm</sqf>


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


<dl class="command_description">
{{Note
|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.
}}


<dt><dt>
{{Note
<dd class="notedate">Posted on September 26, 2014 - 09:18 (UTC)</dd>
|user= Killzone_Kid
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
|timestamp= 20141108214800
<dd class="note">
|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>
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>
 
<dt><dt>
<dd class="notedate">Posted on November 8, 2014 - 21:48 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
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 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.
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>
}}


<dt></dt>
{{Note
<dd class="notedate">Posted on October 7, 2020 - 12:24 (UTC)</dd>
|user= R3vo
<dt class="note">[[User:R3vo|R3vo]]</dt>
|timestamp= 20201007122400
<dd class="note">
|text= The sound will be distorted according to the {{Link|https://en.wikipedia.org/wiki/Doppler_effect}} when passing by the sound source quickly.
The sound will be distorted according to the {{Wikipedia|Doppler effect}} when passing by the sound source quickly.
}}
</dd>
 
</dl>

Revision as of 16:18, 24 February 2023

Hover & click on the images for description

Description

Description:
Plays positional sound with given filename on every computer on network. Since Arma 2.10 the leading slash in file path will be ignored.
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
Before Arma 3 v2.10, filename must not start with a leading slash \a3\....
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: Array format PositionASL - (Optional, default [0,0,0]) Position for sound emitter. Will override "soundSource" position.
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:
Nothing or Number - id of the sound (0...65535), since v2.14

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.