Skip to main content

Vehicle sound in Far Cry 3

Verified via reverse engineering

Traced in retail Far Cry 3's FC3.dll (Ghidra program /FarCry3-Retail), which has no symbols; the function names below are ours. Retail values come from worlds\fc3_main\generated\entitylibrary_full.fcb, unpacked and converted with FCBConverter. Nothing here was heard or measured in game.

In Far Cry 3 the engine sound follows the car's physics. Far Cry 2 makes its RPM up from road speed over three pretend gears. Far Cry 3 takes it from the physics, whose gearbox has real gears, shift points and clutch time. The sound smooths that RPM once more and gets two extra signals about gear changes: one when a gear engages, one while a change is under way.

The physics RPM​

Cars are still the Havok vehicle kit, as in Far Cry 2. Far Cry 3 replaces the transmission and the engine with its own subclasses, and builds both from the archetype's WheeledParams instead of constants in code.

Every step​

VehicleTransmission_CalcTransmission (0x11384CE8) works out the RPM in VehicleTransmission_CalcDampedRPM (0x11384B84):

wheel = Havok calcRPM // driven wheels' spin in rpm × current gear ratio, never below 0
if the clutch is out (a gear change is running):
rpm = rpm − RpmDownDamping × dt
else:
low = minRPM − RpmDownDamping × dt
high = min(max(rpm, low) + RpmUpDamping × dt, maxRPM)
rpm = clamp(wheel, low, high)
rpm = max(rpm, 0)

What follows from it:

  • Revs climb no faster than RpmUpDamping per second, so a gear that lets the wheels jump does not make the engine jump.
  • Revs fall to the wheels at once while a gear is engaged. RpmDownDamping only limits the fall while the clutch is out.
  • The floor is the engine's fEngineMinRPM. There is no clutch slip in this RPM: standing still on the throttle, it stays at idle unless the driven wheels spin. Havok's own clutch-slip rule still runs in the engine, but only for torque.
  • In the air or in wheelspin the revs rise, because they follow the driven wheels, not the road.

The transmission stores the result at +0x3C. The engine's calcEngineInfo (VehicleEngine_CalcEngineInfo, 0x113848D7) copies it to its own +0x3C, and that copy is what the vehicle's GetRPM returns to the sound.

Gear changes​

VehicleTransmission_UpdateCurrentGear (0x11384DBC) runs after the RPM. Once a gear change's clutch time runs out, the clutch engages again. When the car is going forward with the clutch in:

  • A gear holds inside its speed window. Each GearsConfig entry has MinSpeed and MaxSpeed in km/h. While the speed is inside the current gear's window, no shift is considered. A window with MaxSpeed 0 never holds.
  • Down: below fDownshiftRPM, one gear down, with the clutch out for fClutchDownDelayTime. A further condition applies from second to first; it was not traced.
  • Up: above fUpshiftRPM, moving, not in the top gear and past a check on the driven wheels that was not traced, one gear up with the clutch out for fClutchDelayTime. With bUseTransmissionPrediction set, the shift first predicts the RPM the new gear will have after the clutch time, from the speed the car is expected to lose meanwhile, scaled by fTransmissionPredictionSensibility. If that RPM is at or below fDownshiftRPM, the shift is cancelled. Without prediction the clutch engages again on the next step: the up-shift clutch time is only used together with prediction. Every retail car has prediction on.

Retail tuning makes the RPM fall during an up-shift to where the next gear picks up. The 4x4 shifts up at 5,000. The clutch is out for 0.5 s at 3,500 rpm/s, so the revs fall to about 3,250, and second gear starts at 5,000 × 1.48 ÷ 2.32 ≈ 3,190.

From the archetype​

PhysWheeledVehicle_SetupEngine (0x11373DE9) and PhysWheeledVehicle_SetupTransmission (0x113757BE) copy WheeledParams into the components:

FieldBecomes
fEngineMinRPM, fEngineOptimalRPM, fEngineMaxRPMthe engine's min, optimal and max RPM
fEnginePowerthe engine's maximum torque
fEngineCutOffSpeed, fEngineReverseCutOffSpeedno torque above these speeds
GearsConfig (GearRatio, MinSpeed, MaxSpeed)the gear ratios and their speed windows
fReverseGearRatiothe reverse ratio
fUpshiftRPM, fDownshiftRPMshift points
fClutchDelayTime, fClutchDownDelayTimeclutch time for up and down shifts
RpmUpDamping, RpmDownDampingthe rate limits above; 3,000 and 2,000 rpm/s by default
fEngineBrakeRatioscales the engine's braking torque
fGearBoxTopSpeed, fTopSpeedRPMthe primary ratio: fTopSpeedRPM at fGearBoxTopSpeed in the top gear, on a driven wheel's real radius

The sound​

WheeledVehicleSound_Update (0x10717105) runs every frame on a wheeled vehicle's sound component. It calls WheeledVehicleSound_UpdateSoundState (0x10715CBB), which starts and stops events and computes the parameters, and WheeledVehicleSound_UpdateLastGearEmulation (0x10712EF5).

What plays when​

MomentEvents
A driver gets insndEngineIgnition
The engine startssndPlayEngineIdleLoop, sndEngineLoop and sndExtraTorqueEngineLoop, until it stops
The engine stopsthe loops fade out over 0.2 s; sndTurnOffEngine and sndStopEngineIdleLoop play
Throttle at or above fThrustPedalStopThresholdsndThrustPedal, stopped with a fThrustPedalStopFadeOut fade below it
Pedal below −0.5sndBrake
The clutch goes out for a gear changesndGearShift_New, _MinorDamage or _MajorDamage, by damage state

This is Far Cry 2's set. What changed is the gear change: it comes from the physics gearbox, and retail Far Cry 3 fills sndGearShift_*.

The RPM the sound hears​

The sound does not use the physics RPM directly. VehicleSound_FadeToward (0x1062F30D) moves its own copy toward it by at most RpmFadeUpFactor per second going up and RpmFadeDownFactor per second going down, never past it, and keeps it between the engine's min and max RPM. The field descriptions say rpm/s², but the code uses both as rpm/s.

The parameters it answers​

WheeledVehicleSoundCB_GetMultiLayer (0x10712926) answers the bank's multilayers; what it does not know goes to the shared VehicleSoundCB_GetMultiLayer (0x1062EDCA). The ids are the retail 4x4's.

FieldIdValue
sndmlSpeedSoundMultilayer0x00440255the vehicle's speed
sndmlRPMSoundMultilayer0x00440256the faded RPM above
sndmlThrustPedalSoundMultilayer0x0044F4D0the throttle, 0 to 1 (FC2 sends 0 to 100), faded in over fPedalFadeInTime and out over fPedalFadeOutTime; braking reads 0
sndmlExtraTorqueSoundMultilayer0x0044025Bthe physics extra-torque factor × 100, faded by ExtraTorqueFadeUpFactor and ExtraTorqueFadeDownFactor
sndmlDamageSoundMultilayer0x00450C23a value at the vehicle's +0xF4 × 100
sndmlStartGearSoundMultilayer0x00074C81new: 1.0 when a gear engages after the clutch, then falls by StartGearFadeDownFactor per second
sndmlGearShiftMultilayer0x00177AE2new: seconds since the current gear change began, 0 when none is running
sndmlWheelSlipSoundMultilayer0x00440257the largest slip of any wheel on the ground
sndmlWheelForwardSlipSoundMultilayer0x00177ACFthe largest forward slip
sndmlChassisRumbleMultilayer0x0017312Afrom the chassis's pitch and roll (not traced further), 0 to 1, faded by fChassisRumbleFade

The speed, RPM, throttle, extra-torque, damage and wheel-slip ids are Far Cry 2's own.

Last-gear emulation, unused​

The LastGearEmulation block can fake gear changes in the top gear, where the real gearbox has nothing left to shift. It is used only with bEmulateLastGear set, in the top gear and outside a real gear change. The emulated RPM then climbs at fRPMAccel toward the max RPM. If the physics RPM drops by more than fRPMDecelThreshold of the max RPM, it falls at fRPMDecel instead. At fRPMMax it plays the gear-shift event and falls for fRPMShiftDelay, then restarts at fRPMStart. It does this up to MaxGear times. bEmulateLastGear is off on all 55 retail wheeled archetypes.

Retail tuning​

ArchetypeMin / max RPMUp / down shiftClutch up / downRpmUp / RpmDownDampingRpmFadeUp / DownFactorGears (km/h window)
4x41,000 / 6,0005,000 / 3,6000.5 / 0.1 s5,000 / 3,5002,500 / 5,0002.32 (0–39), 1.48 (27–59), 1.0 (47–75)
Technical1,000 / 5,7004,800 / 3,2000.5 / 0.1 s5,000 / 3,5005,000 / 3,5002.32 (0–35), 1.48 (27–50), 1.0 (47–75)
GermanHatch1,000 / 6,5005,000 / 3,6000.55 / 0.15 s6,000 / 3,5006,000 / 3,5002.27 (0–39), 1.48 (27–59), 1.0 (47–65)
JapSedan1,000 / 6,5005,000 / 3,6000.55 / 0.1 s6,000 / 3,5006,000 / 3,5002.27 (0–39), 1.48 (27–59), 1.0 (47–65)
Buggy1,000 / 7,2005,999 / 3,8000.26 / 0.1 s6,000 / 3,5006,000 / 3,5001.92 (0–25), 1.32 (25–40), 1.0 (40–65)
Quad_Bike1,200 / 6,5005,000 / 3,6000.35 / 0.15 s7,000 / 5007,000 / 8,0002.01 (0–30), 1.39 (30–45), 1.0 (45–65)
CargoTruck900 / 5,0004,300 / 2,4000.6 / 0.1 s2,500 / 2,5002,500 / 2,5003.22 (0–15), 2.29 (15–25), 1.84 (25–40), 1.2 (40–65)
MissionSpc_APC900 / 5,0003,250 / 1,8001.0 / 0.1 s8,000 / 2,5002,000 / 4,5002.74 (0–35), 1.92 (31–47), 1.27 (41–60), 1.0 (57–65)

Across the cars that have sound:

  • StartGearFadeDownFactor is 0.65, so the start-gear signal takes about 1.5 s to fade.
  • fPedalFadeInTime and fPedalFadeOutTime are 0.05 s on all but one.
  • sndThrustPedal and sndExtraTorqueEngineLoop are empty everywhere.
  • bUseTransmissionPrediction is on everywhere; fTransmissionPredictionSensibility is 0.1–1.4.

The converted data lists one more Gear after the last on every car, all zero. The transmission divides by the last gear's ratio, so the game cannot be using that entry as a gear. It was not looked into further.

What is not known yet​

How Far Cry 3 layers its engine recordings: which loops play, and on which of the parameters above they crossfade and pitch. The engine events point into soundbinary\<id>.spk banks in fc3_main.dat (the 4x4's sndEngineLoop is 0x00052524, which refers on to 0x00052523). These banks start with 04 4B 50 53, a newer .spk version than the one JackAll reads.

Boats have their own fSoundRpmFadeUpFactor and fSoundRpmFadeDownFactor; their RPM was not traced.