Difference between revisions of "Arma 3: Sound: Filters"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - ";[ ]+ " to "; ")
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Filters ==
+
{{TOC|side}}
 
+
== Distance Frequency Attenuation ==
 
 
=== Distance Frequency Attenuation ===
 
  
 
Every sound in the game is attenuated by a frequency Low Pass Filter, the frequency cutoff changes with distance.
 
Every sound in the game is attenuated by a frequency Low Pass Filter, the frequency cutoff changes with distance.
Line 10: Line 8:
 
All Distance Frequency Attenuation Filters must be configured in the base class '''CfgDistanceFilters'''.
 
All Distance Frequency Attenuation Filters must be configured in the base class '''CfgDistanceFilters'''.
  
{| class="wikitable" style="color:black; background-color:#fefefe;"
+
{| class="wikitable"
  
 
|-
 
|-
!parameter
+
! Parameter
!unit/values
+
! Unit/values
!default
+
! Default
!descriptions
+
! Description
  
 
|-
 
|-
!''type''
+
! ''type''
 
| Fitler Type name
 
| Fitler Type name
 
| "lowPassFilter"
 
| "lowPassFilter"
Line 26: Line 24:
  
 
|-
 
|-
!''minCutoffFrequency''
+
! ''minCutoffFrequency''
 
| [Hz]
 
| [Hz]
 
| 300
 
| 300
 
|
 
|
* minimal cutoff frequency (see: [https://en.wikipedia.org/wiki/Cutoff_frequency Cutoff Frequency] on Wikipedia))
+
* minimal cutoff frequency (see: {{Wikipedia|Cutoff_frequency|Cutoff Frequency}} on Wikipedia))
  
 
|-
 
|-
!''qFactor''
+
! ''qFactor''
 
| float (0..1)
 
| float (0..1)
 
| 1
 
| 1
 
|
 
|
* slope of attenuation curve in frequency spectrum (see [https://en.wikipedia.org/wiki/Q_factor Q factor] on Wikipedia
+
* slope of attenuation curve in frequency spectrum (see {{Wikipedia|Q_factor|Q factor}} on Wikipedia
  
 
|-
 
|-
!''innerRange''
+
! ''innerRange''
 
| [m]
 
| [m]
 
| 100
 
| 100
Line 48: Line 46:
  
 
|-
 
|-
!''range''
+
! ''range''
 
| [m]
 
| [m]
 
| 1500
 
| 1500
Line 56: Line 54:
  
 
|-
 
|-
!''powerFactor''
+
! ''powerFactor''
 
| (0..100)
 
| (0..100)
 
| 2
 
| 2
Line 64: Line 62:
 
|}
 
|}
  
<code>class CfgDistanceFilters
+
<syntaxhighlight lang="cpp">
 +
class CfgDistanceFilters
 
{
 
{
 
class defaultDistanceFreqAttenuationFilter
 
class defaultDistanceFreqAttenuationFilter
Line 76: Line 75:
 
};
 
};
 
};
 
};
</code>
+
</syntaxhighlight>
  
=== Sound Effects ===
+
== Sound Effects ==
  
''Sound Effects'' is an older ArmA 3 audio feature which handles sound filtering of a specific group of sounds, like radio protocol, underwater, or interior attenuation.
+
''Sound Effects'' is an older Arma 3 audio feature which handles sound filtering of a specific group of sounds, like radio protocol, underwater, or interior attenuation.
  
==== Attenuation Effects ====
+
=== Attenuation Effects ===
  
 
All attenuation effects have to be configured within class '''AttenuationsEffects''' (base class '''CfgSoundEffects''').
 
All attenuation effects have to be configured within class '''AttenuationsEffects''' (base class '''CfgSoundEffects''').
  
It is represented by class containing predefined filter chain (2x4 band equalizer + echo), which is applied on specific groups of sounds witch are considered to come "from outside" of a vehicle or building.
+
It is represented by class containing predefined filter chain (''2x4 band equalizer + echo''), which is applied on specific groups of sounds witch are considered to come "from outside" of a vehicle or building.
  
{| class="wikitable" style="color:black; background-color:#eeeeff;"
+
{{Feature | informative
 
|
 
|
* Configuration for vehicles is handled by parameter ''attenuationEffectType'' within the vehicle configuration class. It links the vehicle to a specific attenuation class ( e.g.: attenuationEffectType = "CarAttenuation";  
+
* Configuration for vehicles is handled by parameter ''attenuationEffectType'' within the vehicle configuration class. It links the vehicle to a specific attenuation class ( e.g.: attenuationEffectType {{=}} "CarAttenuation";
 
* A special case is attenuation of sounds related to building interiors, there is no parameter that defines which attenuation class should be used, the expected class name is hard-coded instead: ''HouseAttenuation''
 
* A special case is attenuation of sounds related to building interiors, there is no parameter that defines which attenuation class should be used, the expected class name is hard-coded instead: ''HouseAttenuation''
|}
+
}}
  
<code>class CfgSoundEffects
+
<syntaxhighlight lang="cpp">
 +
class CfgSoundEffects
 
{
 
{
 
class AttenuationsEffects
 
class AttenuationsEffects
Line 121: Line 121:
 
};
 
};
 
};
 
};
</code>
+
</syntaxhighlight>
  
==== Special Filters ====
+
=== Special Filters ===
  
 
Special Filters are used to filter sounds within specific gameplay conditions like underwater or in an unconscious state.
 
Special Filters are used to filter sounds within specific gameplay conditions like underwater or in an unconscious state.
Line 131: Line 131:
 
All of following have to be configured in base class '''CfgSoundEffects'''.
 
All of following have to be configured in base class '''CfgSoundEffects'''.
  
'''Underwater Filters'''
+
==== Underwater Filters ====
<code>class CfgSoundEffects
+
<syntaxhighlight lang="cpp">
 +
class CfgSoundEffects
 
{
 
{
 
class UnderWaterEffects
 
class UnderWaterEffects
Line 153: Line 154:
 
};
 
};
 
};
 
};
</code>
+
</syntaxhighlight>
  
'''Unconscious State Effect'''
+
==== Unconscious State Effect ====
<code>class CfgSoundEffects
+
<syntaxhighlight lang="cpp">
 +
class CfgSoundEffects
 
{
 
{
 
class UnconsciousStateEffect
 
class UnconsciousStateEffect
Line 187: Line 189:
 
};
 
};
 
};
 
};
</code>
+
</syntaxhighlight>
  
'''Radio Protocol Filters'''
+
==== Radio Protocol Filters ====
<code>class CfgSoundEffects
+
<syntaxhighlight lang="cpp">
 +
class CfgSoundEffects
 
{
 
{
 
class RadioFilterEffects
 
class RadioFilterEffects
Line 197: Line 200:
 
{
 
{
 
// Equalizer
 
// Equalizer
center[] = { 370, 900, 6000, 10000 }; // frequencies
+
center[] = { 370, 900, 6000, 10000 }; // frequencies
bandwidth[] = { 1, 2, 1, 1.2 };     // must be between 0.1 and 2.0
+
bandwidth[] = { 1, 2, 1, 1.2 }; // must be between 0.1 and 2.0
gain[] = { db0, db4, db4, db5 }; // +/- 18dB
+
gain[] = { db0, db4, db4, db5 }; // +/- 18dB
 
// Limiter
 
// Limiter
 
lim_limit = 1;
 
lim_limit = 1;
Line 210: Line 213:
 
// low pass filter
 
// low pass filter
 
filter_cut_off = 650;
 
filter_cut_off = 650;
// Filter radian frequency calculated as (2 * sin(pi * (desired filter cutoff frequency) / sampleRate)).
+
/* Filter radian frequency calculated as (2 * sin(pi * (desired filter cutoff frequency) / sampleRate)).
// The frequency must be greater than or equal to 0 and less than or equal to XAUDIO2_MAX_FILTER_FREQUENCY
+
The frequency must be greater than or equal to 0 and less than or equal to XAUDIO2_MAX_FILTER_FREQUENCY
// frequency == 11025, cuttoff > 1837 = 1
+
frequency == 11025, cuttoff > 1837 = 1 */
 
filter_one_over_Q = 0.5;
 
filter_one_over_Q = 0.5;
// 0 - 1, Reciprocal of Q factor. Controls how quickly frequencies beyond Frequency are dampened.
+
/* 0 - 1, Reciprocal of Q factor. Controls how quickly frequencies beyond Frequency are dampened.
//Larger values result in quicker dampening while smaller values cause dampening to occur more gradually
+
Larger values result in quicker dampening while smaller values cause dampening to occur more gradually */
 
filter_enabled = true;
 
filter_enabled = true;
 
};
 
};
Line 237: Line 240:
 
};
 
};
 
};
 
};
</code>
+
</syntaxhighlight>
 +
 
 +
 
 +
{{GameCategory|arma3|Sound}}

Latest revision as of 01:55, 8 August 2021

Distance Frequency Attenuation

Every sound in the game is attenuated by a frequency Low Pass Filter, the frequency cutoff changes with distance.

Default filter is configured in CfgSoundGlobals, however it is possible to define a custom distance attenuation filter for each SoundSet using parameter distanceFilter.

All Distance Frequency Attenuation Filters must be configured in the base class CfgDistanceFilters.

Parameter Unit/values Default Description
type Fitler Type name "lowPassFilter"
  • type of filter (note: currently, there only Low Pass Filter is possible)
minCutoffFrequency [Hz] 300
qFactor float (0..1) 1
  • slope of attenuation curve in frequency spectrum (see Q factor on Wikipedia
innerRange [m] 100
  • radius of sphere with sound source in its' center
  • within innerRange distance, no filter is applied
range [m] 1500
  • radius of sphere with sound source in its' center
  • outside the range distance, cutoff frequency of filtering stops at minCutoffFrequency
powerFactor (0..100) 2
  • relationship between cutoff frequency and distance
  • higher value means faster attanuation
class CfgDistanceFilters
{
	class defaultDistanceFreqAttenuationFilter
	{
		type = "lowPassFilter";
		minCutoffFrequency = 150;
		qFactor = 1;
		innerRange = 10;
		range = 1000;
		powerFactor = 32;
	};
};

Sound Effects

Sound Effects is an older Arma 3 audio feature which handles sound filtering of a specific group of sounds, like radio protocol, underwater, or interior attenuation.

Attenuation Effects

All attenuation effects have to be configured within class AttenuationsEffects (base class CfgSoundEffects).

It is represented by class containing predefined filter chain (2x4 band equalizer + echo), which is applied on specific groups of sounds witch are considered to come "from outside" of a vehicle or building.

  • Configuration for vehicles is handled by parameter attenuationEffectType within the vehicle configuration class. It links the vehicle to a specific attenuation class ( e.g.: attenuationEffectType = "CarAttenuation";
  • A special case is attenuation of sounds related to building interiors, there is no parameter that defines which attenuation class should be used, the expected class name is hard-coded instead: HouseAttenuation
class CfgSoundEffects
{
	class AttenuationsEffects
	{
		class HouseAttenuation
		{
			class Equalizer0
			{
				center[] = { 50, 600, 2000, 6000 };  // 20 - 20000Hz
				bandwidth[] = {1, 2, 2, 2 };         // 0.1 and 2.0
				gain[] = { db-3, db-1, db-5, db-8 }; // 0.126 - 7.94; +/- 18dB
			};
			class Equalizer1
			{
				center[] = { 60, 500, 3000, 15000 }; // 20 - 20000Hz
				bandwidth[] = {2, 2, 2, 2 };		 // 0.1 and 2.0
				gain[] = { db0, db0, db0, db0 };	 // 0.126 - 7.94; +/- 18dB
			};
			class Echo
			{
				WetDryMix = 0.1;   // 0 - 1
				Feedback = 0.01;   // 0 - 1
				Delay = 50;        // 1 - 2000
			};
		};
	};
};

Special Filters

Special Filters are used to filter sounds within specific gameplay conditions like underwater or in an unconscious state.

There are three hard-coded classes that are expected by the audio engine (with different, predefined filter chains): UnderWaterEffects, UnconsciousStateEffect, RadioFilterEffects

All of following have to be configured in base class CfgSoundEffects.

Underwater Filters

class CfgSoundEffects
{
	class UnderWaterEffects
	{
		class Mono
		{
			// 0m - unchanged sound
			// 1m - below surface level all sounds are mixed into mono
			distance = 1;
		};
		class Equalizer
		{
			// in range [0 - 3] equalizer pars are linearly interpolated from neutral values to set
			distance = 3;
			// Equalizer
			center[] = { 100, 800, 2000, 10000 };	// frequencies
			bandwidth[] = { 2.0, 2.0, 2.0, 2.0 };	// must be between 0.1 and 2.0
			gain[] = { db3, db0, db-15, db-18 };	// +/- 18dB
		};
	};
};

Unconscious State Effect

class CfgSoundEffects
{
	class UnconsciousStateEffect
	{
		// linear interpolation ... Echo0 * t + (Echo1 - Echo0), t = [0 - 1]
		class Echo0
		{
			WetDryMix = 0.25;   // 0 - 1
			Feedback = 0.15;     // 0 - 1
			Delay = 50;        // 1 - 2000
		};
		class Echo1
		{
			WetDryMix = 0.5;    // 0 - 1
			Feedback = 0.2;     // 0 - 1
			Delay = 100;      // 1 - 2000
		};
		class Equalizer0
		{
			center[] = { 100, 800, 2000, 10000 }; // frequencies
			bandwidth[] = { 1.0, 1.0, 1.0, 1.0 }; // must be between 0.1 and 2.0
			gain[] = { db0, db-5, db-10, db-10 }; // +/- 18dB
		};
		class Equalizer1
		{
			center[] = { 100, 800, 2000, 10000 };	// frequencies
			bandwidth[] = { 2.0, 2.0, 2.0, 2.0 }; // must be between 0.1 and 2.0
			gain[] = { db0, db-10, db-18, db-18 }; // +/- 18dB
		};
	};
};

Radio Protocol Filters

class CfgSoundEffects
{
	class RadioFilterEffects
	{
		class Part0 
		{
			// Equalizer
			center[] = { 370, 900, 6000, 10000 };	// frequencies
			bandwidth[] = { 1, 2, 1, 1.2 };			// must be between 0.1 and 2.0
			gain[] = { db0, db4, db4, db5 };		// +/- 18dB
			// Limiter
			lim_limit = 1;
			lim_attack = 5;
			lim_release = 50;
			enabled[] = { true, false, true };	// equalizer, limiter, convert to 8bit
		};
		class Part1
		{
			// low pass filter
			filter_cut_off = 650;
			/* Filter radian frequency calculated as (2 * sin(pi * (desired filter cutoff frequency) / sampleRate)).
			The frequency must be greater than or equal to 0 and less than or equal to XAUDIO2_MAX_FILTER_FREQUENCY
			frequency == 11025, cuttoff > 1837 = 1 */
			filter_one_over_Q = 0.5;
			/* 0 - 1, Reciprocal of Q factor. Controls how quickly frequencies beyond Frequency are dampened.
			Larger values result in quicker dampening while smaller values cause dampening to occur more gradually */
			filter_enabled = true;
		};
		class Part2
		{			
			// Equalizer
			center[] = { 100, 250, 900, 5000 };		// 20 - 2000Hz
			bandwidth[] = {2, 1.9, 2, 2 };			// 0.1 and 2.0
			gain[] = { db-18, db-18, db4, db-3 };	// 0.126 - 7.94; +/- 18dB
			// Compressor
			comp_threshold = db0;
			comp_ratio = 0.27;	  	// 1:1
			comp_attack = 1;		// milliseconds			 
			comp_relase = 100;		// milliseconds
			// Limiter
			lim_limit = db-18;
			lim_attack = 1;
			lim_release = 500;
			enabled[] = { true, false, false };   // equalizer, compressor, limiter
		};
	};
};