VEHICLEENGINE SOUND
Engine sound
What it does
Section titled “What it does”The engine sound plays the engine of a vehicle. It crossfades a set of loops, each recorded at one engine speed, and pitches them to the engine’s speed in the game. Under load the engine is louder than when it coasts. The Crushform Engine Audio component plays the sound. The Vehicle adapter and the Chaos adapter create one for the vehicle, as CF_EngineAudio.
How it works
Section titled “How it works”Loops. A UCFEngineSoundProfile holds the loops, as layers. A layer is one looping sound, the engine speed it was recorded at, and its volume. The component sorts the layers by speed. It fades between the two loops around the engine’s speed, and pitches each loop to the speed in the game. The pitch stays between Min Pitch and Max Pitch. The audio device limits pitch to 0.4 to 2.0 by default, so these two values work inside that range.
Load. With no throttle the engine plays at Coast Volume. With full throttle it plays at full volume. The volume moves between the two as the load changes.
Run state. The component asks the vehicle’s engine host once a frame for its state: off, cranking or running. While the engine cranks, the Starter Sound loops and the engine loops stay silent. When the engine runs, the loops rise over Start Fade Seconds. When it stops, they fade over Stop Fade Seconds, and the Shutdown Sound plays once.
Earshot. The engine plays only while a listener is within the range of the profile’s Attenuation. Out of earshot the sounds stop. When a listener comes back, the engine is heard as it is at that moment, without a rise or a shutdown it missed.
Cabin. A listener inside the cabin hears the engine quieter and duller. The adapter’s SetCabinMuffled muffles the engine too. A component on its own calls SetCabinMuffling.
Presentation only. The engine sound is silent on a dedicated server, because nothing there hears it. Without an Attenuation on the profile, the sound stays off, and the log says so.
Set it up
Section titled “Set it up”This example makes an engine sound for your own vehicle. The plugin ships a default profile, DA_CF_DefaultEngineSound, with its loops and an attenuation, so you can skip the profile and use it.
- In the Content Browser, click Add, choose Miscellaneous, then Data Asset, and pick CFEngine Sound Profile. Name it
MyEngineSoundin your project’s folder. - Open the profile. Under Layers, add one entry for each loop. Set Sound to a looping sound, RPM to the engine speed it was recorded at, and Volume to its gain. Use a different RPM for each layer.
| Engine Sound | ||
|---|---|---|
| Layers | 3 Array elements | |
| Index [ 0 ] | ||
| Sound | SW_CF_Engine_Ranger_0850 | |
| RPM | 850.0 rpm | |
| Volume | 0.7 | |
| Index [ 1 ] | ||
| Index [ 2 ] | ||
| Attenuation | SA_CF_Engine | |
- Set Attenuation to a sound attenuation asset. The plugin’s
SA_CF_Engineis the sample. Without one the engine stays silent. - Optionally set Starter Sound (it must loop, and plays while the engine cranks) and Shutdown Sound (it must not loop, and plays once when the engine stops).
- Open Edit, then Project Settings, then Plugins, then Crushform Engine. Check that Engine Sound is on, and that Default Profile is the profile you want for vehicles that name none.
| Engine Sound | ||
|---|---|---|
| Engine Sound | ||
| Default Profile | DA_CF_DefaultEngineSound | |
- On the vehicle’s adapter, set Engine Sound Profile to
MyEngineSound, or leave it empty for the default. Set Engine Sound Offset to move the sound to the engine’s position. Turn on Engine Sound.
Saving the profile runs its checks. They report a profile with no layer, a layer with no sound or a sound that does not loop, two layers with the same speed, no attenuation, a minimum pitch above the maximum, and a shutdown sound that loops.
Use it
Section titled “Use it”On a Blueprint, the usual task is to muffle the engine when the listener sits in the cabin. The graph gets the engine audio component from the adapter with Get Engine Audio on CF_Adapter, then calls Set Cabin Muffling on it with a volume scale of 0.5 and a low-pass cutoff of 1200 Hz. On a vehicle with the adapter, Set Cabin Muffled on the adapter instead muffles the rolling sound and the engine together, with the settings’ values or, when its override is on, the adapter’s own.
The same call in C++. Find the component on the vehicle, then call its function. The signature is the one in the header. Your module must list the Crushform modules in its Build.cs, as in Installation.
#include "CFEngineAudioComponent.h"
void AMyVehicle::SetListenerInCabin(const bool bInCabin){ if (UCFEngineAudioComponent* Audio = FindComponentByClass<UCFEngineAudioComponent>()) { // The volume scale and the low-pass cutoff in Hz, applied while muffled. Audio->SetCabinMuffling(bInCabin, 0.5f, 1200.f); }}The engine’s host, the object that answers the engine state, is set in C++ with SetCrushformHost before the component begins play. Its explicit host wins over the registry’s host for the owner.
Key settings
Section titled “Key settings”Profile values are on UCFEngineSoundProfile, settings are on UCFEngineSettings, and the adapter’s are on UCFVehicleAdapterComponent. Defaults are the code’s.
| Property | What it does | Default |
|---|---|---|
UCFEngineSoundProfile::Layers | The loops, in any order. A layer with no sound is left out. | empty |
FCFEngineSoundLayer::Sound | A looping sound of the engine at one steady speed. | none |
FCFEngineSoundLayer::RPM | The engine speed the loop was recorded at, in rpm. The loop plays at its own pitch at this speed. | 1000 rpm |
FCFEngineSoundLayer::Volume | The loop’s gain at its full share of the mix. | 1.0 |
UCFEngineSoundProfile::Attenuation | The falloff and spatialisation of every sound. Without it the engine sound stays off. | empty |
UCFEngineSoundProfile::CoastVolume | The share of full volume heard with no load. | 0.6 |
UCFEngineSoundProfile::RPMInterpSpeed | How fast the heard speed follows the engine’s, in 1/s. 0 follows at once. | 8 |
UCFEngineSoundProfile::LoadInterpSpeed | How fast the volume follows the load, in 1/s. 0 follows at once. | 5 |
UCFEngineSoundProfile::MinPitch | The lowest pitch a loop is slowed to. | 0.5 |
UCFEngineSoundProfile::MaxPitch | The highest pitch a loop is sped up to. | 2.0 |
UCFEngineSoundProfile::StartFadeSeconds | How long the loops take to rise from silence once the engine runs. 0 is at once. | 0.4 s |
UCFEngineSoundProfile::StopFadeSeconds | How long the loops take to fade out once the engine stops. 0 is at once. | 1 s |
UCFEngineSoundProfile::StarterSound | Loops while the engine cranks. Empty is a silent start. | empty |
UCFEngineSoundProfile::ShutdownSound | Plays once when a running engine turns off. Empty is none. | empty |
UCFEngineSettings::bEngineSound | Engine Sound: the master switch. Off, no engine plays one. | on |
UCFEngineSettings::DefaultProfile | The profile for an engine that names none. | DA_CF_DefaultEngineSound |
UCFEngineSettings::SoundClass | The sound class of the engine sounds. Empty is Master. | empty |
UCFEngineSettings::Priority | The playback priority of the engine sounds. It is above the rolling sound’s, so a quiet tyre gives way to the engine. | 0.5 |
UCFEngineSettings::CabinVolumeScale | The volume of the engine from inside the cabin. | 0.8 |
UCFEngineSettings::CabinLowPassFrequency | The low-pass cutoff of the engine from inside the cabin, in Hz. | 3000 Hz |
UCFVehicleAdapterComponent::bEngineSound | Engine Sound on the adapter. Needs the master switch in Crushform Engine too. | on |
UCFVehicleAdapterComponent::EngineSoundProfile | The profile of this vehicle. Empty takes UCFEngineSettings::DefaultProfile. | empty |
UCFVehicleAdapterComponent::EngineSoundOffset | Where the engine sound plays, relative to the owner’s root, in centimetres. | zero |
Check that it works
Section titled “Check that it works”- Press Play and rev the vehicle. Then open the console and run
stat CrushformEngine. The Engine Audio Tick time appears while the sound updates. - Drive away from the vehicle. The engine fades as you leave the attenuation’s range, and returns as you come back.
The sound itself does not show in a screenshot. Judge it by ear.
Troubleshooting
Section titled “Troubleshooting”The engine is silent, and the log says the profile has no Attenuation
Section titled “The engine is silent, and the log says the profile has no Attenuation”Cause: The profile’s Attenuation is empty. Without it the engine sound stays off, with a warning.
Fix: Set Attenuation on the profile. The plugin’s SA_CF_Engine is the sample.
There is no engine sound, and no engine audio component on the vehicle
Section titled “There is no engine sound, and no engine audio component on the vehicle”Cause: Either Engine Sound is off in Crushform Engine, or Engine Sound is off on the adapter. In both cases the adapter makes no engine audio component.
Fix: Turn on both switches, then play again.
The engine is heard only close to the vehicle
Section titled “The engine is heard only close to the vehicle”Cause: The engine plays only while a listener is within the range of the profile’s Attenuation: its largest distance.
Fix: Raise the attenuation’s range, or check that the listener is where you expect.
There is no engine sound on the server
Section titled “There is no engine sound on the server”Cause: The engine sound is presentation only. It is silent on a dedicated server, because the server has no listener.
Fix: This is expected. Hear the engine on a client.
Setting the host has no effect
Section titled “Setting the host has no effect”Cause: SetCrushformHost is refused once the component has begun play, and the log says so.
Fix: Call SetCrushformHost before the component begins play.