CfgSFX

From Bohemia Interactive Community
Jump to: navigation, search

Description

CfgSFX class is used to configure repeating and random sound effects with range of parameters. Currently sounds from CfgSFX could be played either directly with setSoundEffect command or indirectly with createSoundSource command. The config class can be used in mission config, campaign config or main config. Sound is searched in mission config first, then in campaign config and then in main config.

Class Structure

Each config consists of 2 main entries, the sounds[] param and empty[] param.

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

The required sounds[] array contains references to actual sound definitions, the naming of which is not important as long as they match both in the array and in entry. sounds[] can also be an empty array sounds[] = {};. empty[] is required param and serves as fallback sound definition.

Sound Definition Format

The sound definitions as well as empty[] param all have the following format:

{soundPath, soundVolume, soundPitch, maxDistance, probability, minDelay, midDelay, maxDelay}
  • soundPath String - the path to the sound file. In mission config, this is relative to the mission folder
  • soundVolume Number - the standard definition of sound volume
  • soundPitch Number - sound pitch, 1 - normal pitch.
  • maxDistance Number - how far the sound is heard
  • probability Number - how often the sound is chosen randomly. Range (0-1)
  • minDelay, midDelay, maxDelay Numbers - time to wait before playing next sound (or the same sound in the loop). The result is calculated according to Gaussian distribution, see random Alt Syntax

Note that probability is ignored when defined in empty[] param.

How It Works

The probability param is used as weight when calculating which sound to play randomly. The higher the value the more chance for the sound to be selected. If no sound is selected from sounds[], the sound defined in empty[] is played. Once the sound is selected, it is played and the next sound then queued to play after set delay is up.
time to next sound = duration of current sound + random delay

If delay is negative, the sound will not play until the end (depending on the value of negative delay) and next sound will start immediately after. It is possible to have just empty[] sound defined, in which case it will be repeated over and over with set delay. Delay only matters after 1st sound is played, when CfgSFX sound is started for the first time, there is no delay.

Multiplayer

The next sound is chosen randomly on each computer, therefore in multiplayer each client may hear different sounds.

Engine Specific

Objects of Church kind (simulation = "church";) have church bells sounds that are directly called by the engine and therefore the config for those will be different than the rest of CfgSFX. There are only 2 entries for large bell and small bell:

class CfgSFX
{
	class Church
	{
		largeBell[] = {"A3\Sounds_F\environment\structures\church\bell_big",0.891251,1,250};
		smallBell[] = {"A3\Sounds_F\environment\structures\church\bell_small",0.891251,1,250};
	};
};

Another engine class is Preview, used for playing samples when adjusting Audio Options sliders:

class CfgSFX
{
	class Preview
	{
		effect[] = {"A3\Sounds_f\sfx\UI\volume_preview\sfx.wss",1,1};
		speech[] = {"A3\sounds_f\sfx\UI\volume_preview\radio.wss",1,1};
		music[] = {"A3\sounds_f\sfx\UI\volume_preview\music.wss",1,1};
	};
};

The Use of Addon Sounds in Mission Config

Since Arma 3 v1.69.141183 it is possible to reference addon sounds in mission config. Normally, when SFX config is defined in description.ext, the sound is searched relative to mission folder. However, prefixing the file path with @ will instruct the engine to look for sound in main config. For example, if the following is used in mission config, sound0 will not be found, as it will be searched relative to mission folder and fail, but sound1 will be found, as it has special character @, switching the search to the main config instead:

class CfgSFX
{
	class MyOwlSound
	{
		sound0[] = {"A3\Sounds_F\environment\animals\birds\owl1", db-10, 1.0, 1000, 0.2, 0, 15, 30}; // not found
		sound1[] = {"@A3\Sounds_F\environment\animals\birds\owl2", db-10, 1.0, 1000, 0.2, 0, 15, 30}; // found
		sounds[] = {sound0, sound1};
		empty[] = {"", 0, 0, 0, 0, 0, 0, 0};
	};
};