The DtEngineAudioUpdater plays audio sounds for the engaged entity based on the value of a floating point state attribute (typically RPM or speed). The state attribute value modulates the pitch and gain of the sound to create realistic engine effects.
Features:
- Uses state attributes (RPM or speed) to control sound pitch and volume
- Applies smoothing to prevent jitter in pitch changes
- Controls multiple engine sounds with different characteristics
- Positions sounds at the entity's location for 3D audio effects
- Supports engine on/off state via a boolean attribute
Entities need to have a boolean state attribute to represent the engine being on/off. The default attribute name is "engine-on" but can be changed in the configuration. If this attribute is false, engine audio sounds will not play.
- Example Configuration:
["engineAudio"] = {
componentType = "DtEngineAudioUpdater";
priority = 10;
audioPath = "$(DATA_DIR)\\audio\\sounds\\";
engineOnAttribute = "engine-on"; -- can also use "engineOnName" for compatibility
sources = {
{
audioFile = "tankEngine.wav", -- can also use "audio" for compatibility
rpmAttribute = "rpm", -- can also use "stateAttribute" for compatibility
rpmMax = 3100, -- can also use "maxValue" for compatibility
rpmSmoothing = 0.999, -- can also use "lowpassAlpha" (1.0 - smoothing) for compatibility
minPitch = 0.1, --
minimum pitch scaling (
default: 0.1)
maxPitch = 1.0, --
maximum pitch scaling (
default: 1.0)
gain = 0.75, -- volume multiplier (default: 1.0)
decibels = 70.0 -- sound level in decibels (default: 80.0)
},
{
audioFile = "tank.wav",
rpmAttribute = "speed",
rpmMax = 45,
rpmSmoothing = 0.925,
decibels = 80.0
-- gain defaults to 1.0
}
};
};
T maximum(T x, T y)
Returns what ever is greater, x or y of type T.
Definition fsUtil.h:130
T minimum(T x, T y)
Returns the which ever is lesser, x or y of type T.
Definition fsUtil.h:137