This is an old revision of the document!
A sound set specifies a set of audio files and how their gain/pitch should be modified when played, depending on some input values. They are stored in .lua
files in the folder res\config\sound_set\
.
The file has the following format:
function data() return { -- specify resources tracks = { { name = "vehicle/ship/engines.wav", refDist = 25.0 }, }, events = { horn = { names = { "vehicle/ship/horn.wav" }, refDist = 50.0 }, }, -- update function: here you can modify gain/pitch, depending on input updateFn = function (input) return { tracks = { { gain = soundeffectsutil.sampleCurve({ { 0.0, 0.8 }, { 1.0, 1.0 } }, input.power01), pitch = soundeffectsutil.sampleCurve({ { 0.05, 0.8 }, { 1.0, 1.1 } }, input.power01) }, }, events = { horn = { gain = 1.0, pitch = 1.0 }, } } end } end
A track consists of a file name and following attributes:
gain
: ground level, will be multiplied with gain resulting in updateFn
refDist
: reference distancerolloffFact
: roll off factorhasVelocity
: indicates whether source is moving{ name = "vehicle/ship/engines.wav", gain = 0.9, refDist = 25.0, rolloffFact = 1.0, hasVelocity = true },
An event is defined by its key word (see below for a reference). You can specify a list of audio files and the same attributes as for tracks. Every time the event is triggered, an audio file is randomly picked from the list.
clacks = { names = { "vehicle/clack/modern/part_1.wav", "vehicle/clack/modern/part_2.wav", -- as many as you want... }, refDist = 15.0, -- other attributes },
In this function you can modify the gain/pitch of the audio sources, depending on input
. In the above example a ships engine sound is implemented by altering the gain/pitch of an engine sound source depending on its power output.
Note: the number of entries in the table tracks
on top of the file has to match the number of entries in the table tracks
in updateFN
. The same holds for events
.
In the following you can find for each model type, that can emit audio, a complete list of available input parameters and event keys.
Parameters with Appendix 01
are normalized to be between 0 and 1.
Input parameters
speed
topSpeed
speed01
powerOutput
power
powerIdle
power01
Events
land
sonicBoom
Input parameters
speed
topSpeed
speed01
weight
brakeDecel
powerOutput
power
power01
chuffStep
curveRadius
curveSpeedLimit
sideForce
maxSideForce
numAxles
axleRefWeight
gameSpeedUp
Events
chuffs
clacks
horn
openDoors/closeDoors
Input parameters
speed
topSpeed
speed01
Events
openDoors/closeDoors
Input parameters
speed
topSpeed
speed01
powerOutput
power
power01
Events
horn
Input parameters
Industry: production01
, level
.
Stations: crowd01
, crowd
, cargo01
, cargo
, terminals
.
Town buildings: underConstruction
.
Events
Constructions trigger random events at different frequencies, which can be used to play arbitrary sound sources regularly. They are named randomX
, where X is a number between 1 and 64. For example random16
is an event, triggered randomly at an average frequency of 16 seconds.