createSoundSource: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <h3 style="display:none">Notes</h3> <dl class="command_description"> <!-- Note Section BEGIN --> <!-- Note Section END --> </dl> " to "")
m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments( \("local" or "global"\))?|Effects|Multiplayer Effects( \("local" or "global"\))?|Multiplayer Exe...)
Line 1: Line 1:
{{Command|Comments=
{{Command


| arma1 |Game name=
| arma1
http://community.bistudio.com/wiki?title=createSoundSource&action=edit
http://community.bistudio.com/wiki?title=createSoundSource&action=edit
|1.00|Game version=
|1.00


|arg= global |Multiplayer Arguments=
|arg= global


|eff= global |Multiplayer Effects=
|eff= global


|gr1= Broken Commands |GROUP1=
|gr1= Broken Commands
|gr2= Sounds |GROUP2=
|gr2= Sounds


| Creates a sound source of the given type (type is the name of the subclass of [[ArmA:_CfgVehicles|CfgVehicles]] which is pointing to the sound defined in [[CfgSFX]]). The actual sound object created is of type <tt>"#dynamicsound"</tt> and could be detected with [[allMissionObjects]]. If the markers array contains several marker names, the position of a random one is used, otherwise, the given position is used. The sound source is placed inside a circle with this position as its center and placement as its radius. Some of the vanilla classes pre-configured in Arma 3:
| Creates a sound source of the given type (type is the name of the subclass of [[ArmA:_CfgVehicles|CfgVehicles]] which is pointing to the sound defined in [[CfgSFX]]). The actual sound object created is of type <tt>"#dynamicsound"</tt> and could be detected with [[allMissionObjects]]. If the markers array contains several marker names, the position of a random one is used, otherwise, the given position is used. The sound source is placed inside a circle with this position as its center and placement as its radius. Some of the vanilla classes pre-configured in Arma 3:
Line 52: Line 52:
Note that the sound created by [[createSoundSource]] will always be looping. Also when [[CfgSFX]] sound definition contains more than 1 sound, there is no guarantee that the sound played will be the same on every PC in Multiplayer.
Note that the sound created by [[createSoundSource]] will always be looping. Also when [[CfgSFX]] sound definition contains more than 1 sound, there is no guarantee that the sound played will be the same on every PC in Multiplayer.


{{Important| For some unknown reason if at the moment of command execution the player is in first person view and is inside a vehicle, the sound created is greatly attenuated}}|DESCRIPTION=
{{Important| For some unknown reason if at the moment of command execution the player is in first person view and is inside a vehicle, the sound created is greatly attenuated}}


|'''createSoundSource''' [type, position, markers, placement] |SYNTAX=
|'''createSoundSource''' [type, position, markers, placement]


|p1= [type, position, markers, placement]: [[Array]] |PARAMETER1=
|p1= [type, position, markers, placement]: [[Array]]
|p2= type: [[String]] - [[CfgVehicles]] class |PARAMETER2=
|p2= type: [[String]] - [[CfgVehicles]] class
|p3= position:  [[PositionAGL]], [[Position2D]] or [[Object]] - Desired placement position|PARAMETER3=
|p3= position:  [[PositionAGL]], [[Position2D]] or [[Object]] - Desired placement position
|p4= markers: [[Array]] - If the markers array contains any markers, the position is randomly picked from array of given markers plus desired placement position. If any of the markers were given z coordinate with [[setMarkerPos]], the sound will also be created at given z coordinate|PARAMETER4=
|p4= markers: [[Array]] - If the markers array contains any markers, the position is randomly picked from array of given markers plus desired placement position. If any of the markers were given z coordinate with [[setMarkerPos]], the sound will also be created at given z coordinate
|p5= placement: [[Number]] - The sound is placed inside a circle with given position as center and placement as its radius |PARAMETER5=
|p5= placement: [[Number]] - The sound is placed inside a circle with given position as center and placement as its radius
| [[Object]] |RETURNVALUE=
| [[Object]]
   
   
|x1= <code>_soundSource = [[createSoundSource]] ["LittleDog", [[position]] [[player]], [], 0]</code> |EXAMPLE1=
|x1= <code>_soundSource = [[createSoundSource]] ["LittleDog", [[position]] [[player]], [], 0]</code>
|x2= <code>[] spawn  
|x2= <code>[] spawn  
{
{
Line 69: Line 69:
[[sleep]] 10;
[[sleep]] 10;
[[deleteVehicle]] _alarm; //stops alarm
[[deleteVehicle]] _alarm; //stops alarm
};</code> |EXAMPLE2=
};</code>


| [[playSound]], [[playSound3D]], [[sideRadio]], [[say]], [[say2D]], [[say3D]], [[playMusic]]|SEEALSO=
| [[playSound]], [[playSound3D]], [[sideRadio]], [[say]], [[say2D]], [[say3D]], [[playMusic]]


}}
}}

Revision as of 00:11, 18 January 2021

-wrong parameter ("1.00") defined!-[[:Category:Introduced with 1.00 version creates a sound source of the given type (type is the name of the subclass of cfgvehicles which is pointing to the sound defined in cfgsfx). the actual sound object created is of type "#dynamicsound" and could be detected with allmissionobjects. if the markers array contains several marker names, the position of a random one is used, otherwise, the given position is used. the sound source is placed inside a circle with this position as its center and placement as its radius. some of the vanilla classes pre-configured in arma 3:
  • "sound_alarm"
  • "sound_alarm2"
  • "sound_battlefieldexplosions"
  • "sound_battlefieldfirefight"
  • "sound_fire"
  • "sound_smokewreck1"
  • "sound_sparkleswreck1"
  • "sound_sparkleswreck2"
  • "sound_stream"

since arma 3 v1.69.141183 it is possible to define sounds for use with createsoundsource in mission config. as mentioned earlier, the sounds needed for this command should be defined inside cfgvehicles class, which itself references cfgsfx class. if given class searched in main config and is not found, the search will continue in description.ext. here is an example of suitable mission config definition:

// description.ext

class CfgSFX
{
	class MyOwl
	{
		sound0[] = {"@A3\Sounds_F\environment\animals\birds\owl1", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sound1[] = {"@A3\Sounds_F\environment\animals\birds\owl2", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sound2[] = {"@A3\Sounds_F\environment\animals\birds\owl3", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sounds[] = {sound0, sound1, sound2};
		empty[] = {"", 0, 0, 0, 0, 0, 0, 0};
	};
};

class CfgVehicles
{
	class MyOwlSound // class name to be used with createSoundSource
	{
		sound = "MyOwl"; // reference to CfgSFX class
	};
};

_owl = createsoundsource ["myowlsound", position player, [], 0];

note that the sound created by createsoundsource will always be looping. also when cfgsfx sound definition contains more than 1 sound, there is no guarantee that the sound played will be the same on every pc in multiplayer.

for some unknown reason if at the moment of command execution the player is in first person view and is inside a vehicle, the sound created is greatly attenuated
|CREATES A SOUND SOURCE OF THE GIVEN TYPE (TYPE IS THE NAME OF THE SUBCLASS OF CFGVEHICLES WHICH IS POINTING TO THE SOUND DEFINED IN CFGSFX). THE ACTUAL SOUND OBJECT CREATED IS OF TYPE "#DYNAMICSOUND" AND COULD BE DETECTED WITH ALLMISSIONOBJECTS. IF THE MARKERS ARRAY CONTAINS SEVERAL MARKER NAMES, THE POSITION OF A RANDOM ONE IS USED, OTHERWISE, THE GIVEN POSITION IS USED. THE SOUND SOURCE IS PLACED INSIDE A CIRCLE WITH THIS POSITION AS ITS CENTER AND PLACEMENT AS ITS RADIUS. SOME OF THE VANILLA CLASSES PRE-CONFIGURED IN ARMA 3:
  • "SOUND_ALARM"
  • "SOUND_ALARM2"
  • "SOUND_BATTLEFIELDEXPLOSIONS"
  • "SOUND_BATTLEFIELDFIREFIGHT"
  • "SOUND_FIRE"
  • "SOUND_SMOKEWRECK1"
  • "SOUND_SPARKLESWRECK1"
  • "SOUND_SPARKLESWRECK2"
  • "SOUND_STREAM"

SINCE ARMA 3 V1.69.141183 IT IS POSSIBLE TO DEFINE SOUNDS FOR USE WITH CREATESOUNDSOURCE IN MISSION CONFIG. AS MENTIONED EARLIER, THE SOUNDS NEEDED FOR THIS COMMAND SHOULD BE DEFINED INSIDE CFGVEHICLES CLASS, WHICH ITSELF REFERENCES CFGSFX CLASS. IF GIVEN CLASS SEARCHED IN MAIN CONFIG AND IS NOT FOUND, THE SEARCH WILL CONTINUE IN DESCRIPTION.EXT. HERE IS AN EXAMPLE OF SUITABLE MISSION CONFIG DEFINITION:

// description.ext

class CfgSFX
{
	class MyOwl
	{
		sound0[] = {"@A3\Sounds_F\environment\animals\birds\owl1", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sound1[] = {"@A3\Sounds_F\environment\animals\birds\owl2", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sound2[] = {"@A3\Sounds_F\environment\animals\birds\owl3", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sounds[] = {sound0, sound1, sound2};
		empty[] = {"", 0, 0, 0, 0, 0, 0, 0};
	};
};

class CfgVehicles
{
	class MyOwlSound // class name to be used with createSoundSource
	{
		sound = "MyOwl"; // reference to CfgSFX class
	};
};

_OWL = CREATESOUNDSOURCE ["MYOWLSOUND", POSITION PLAYER, [], 0];

NOTE THAT THE SOUND CREATED BY CREATESOUNDSOURCE WILL ALWAYS BE LOOPING. ALSO WHEN CFGSFX SOUND DEFINITION CONTAINS MORE THAN 1 SOUND, THERE IS NO GUARANTEE THAT THE SOUND PLAYED WILL BE THE SAME ON EVERY PC IN MULTIPLAYER.

FOR SOME UNKNOWN REASON IF AT THE MOMENT OF COMMAND EXECUTION THE PLAYER IS IN FIRST PERSON VIEW AND IS INSIDE A VEHICLE, THE SOUND CREATED IS GREATLY ATTENUATED
]]
Hover & click on the images for description

Description

Description:
createSoundSource [type, position, markers, placement]
Groups:
Broken CommandsSounds

Syntax

Syntax:
Object
Parameters:
[type, position, markers, placement]: Array
type: String - CfgVehicles class
position: PositionAGL, Position2D or Object - Desired placement position
markers: Array - If the markers array contains any markers, the position is randomly picked from array of given markers plus desired placement position. If any of the markers were given z coordinate with setMarkerPos, the sound will also be created at given z coordinate
placement: Number - The sound is placed inside a circle with given position as center and placement as its radius
Return Value:
playSound, playSound3D, sideRadio, say, say2D, say3D, playMusic

Examples

Example 1:
_soundSource = createSoundSource ["LittleDog", position player, [], 0]
Example 2:
[] spawn { _alarm = createSoundSource ["Sound_Alarm", position player, [], 0]; //starts alarm sleep 10; deleteVehicle _alarm; //stops alarm };

Additional Information

See also:
See also needed

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

[[Category:Introduced with 1.00 version Creates a sound source of the given type (type is the name of the subclass of CfgVehicles which is pointing to the sound defined in CfgSFX). The actual sound object created is of type "#dynamicsound" and could be detected with allMissionObjects. If the markers array contains several marker names, the position of a random one is used, otherwise, the given position is used. The sound source is placed inside a circle with this position as its center and placement as its radius. Some of the vanilla classes pre-configured in Arma 3:

  • "Sound_Alarm"
  • "Sound_Alarm2"
  • "Sound_BattlefieldExplosions"
  • "Sound_BattlefieldFirefight"
  • "Sound_Fire"
  • "Sound_SmokeWreck1"
  • "Sound_SparklesWreck1"
  • "Sound_SparklesWreck2"
  • "Sound_Stream"

Since Arma 3 v1.69.141183 it is possible to define sounds for use with createSoundSource in mission config. As mentioned earlier, the sounds needed for this command should be defined inside CfgVehicles class, which itself references CfgSFX class. If given class searched in main config and is not found, the search will continue in description.ext. Here is an example of suitable mission config definition:

// description.ext

class CfgSFX
{
	class MyOwl
	{
		sound0[] = {"@A3\Sounds_F\environment\animals\birds\owl1", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sound1[] = {"@A3\Sounds_F\environment\animals\birds\owl2", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sound2[] = {"@A3\Sounds_F\environment\animals\birds\owl3", db-10, 1.0, 1000, 0.2, 0, 15, 30};  // path to addon sound
		sounds[] = {sound0, sound1, sound2};
		empty[] = {"", 0, 0, 0, 0, 0, 0, 0};
	};
};

class CfgVehicles
{
	class MyOwlSound // class name to be used with createSoundSource
	{
		sound = "MyOwl"; // reference to CfgSFX class
	};
};

_owl = createSoundSource ["MyOwlSound", position player, [], 0];

Note that the sound created by createSoundSource will always be looping. Also when CfgSFX sound definition contains more than 1 sound, there is no guarantee that the sound played will be the same on every PC in Multiplayer.

For some unknown reason if at the moment of command execution the player is in first person view and is inside a vehicle, the sound created is greatly attenuated

]][[ Category: 1.00: New Scripting Commands | CREATESOUNDSOURCE]][[ Category: 1.00: Scripting Commands | CREATESOUNDSOURCE]]

Bottom Section