Table of Contents

Sound Sets

Sound sets are configuration files that group several sounds together to get an appropriate sound background. This is used e.g. for vehicles. The sound set .lua files are located in the res/config/sound_set/ folder. They need to have a data() function that returns a data struct like below:

function data()
  return {
    tracks = { ... },
    events = { ... },
    updateFn = function (input)
      ...
    end,
  }
end

The sound set data struct has three properties:

Tracks usually are looped sounds, whereas events are only played once per trigger.

Soundset Util

To facilitate the creation of these functions, there is a sound setutil that is used in most sound sets. Therefore the effective structure of the sound set files is mostly like this:

local soundsetutil = require "soundsetutil"
 
function data()
  local data = soundsetutil.makeSoundSet()
 
  soundsetutil.addTrackParam01(
    data, "vehicle/tram_old/drive.wav", 18.0,                 
    { { .0, .0 }, { .1, .32 }, ... }, { { .0, 1.0 } }, "speed01" 
  )	
  ...
 
  soundsetutil.addEvent( data, "openDoors", { "vehicle/tram_old/bell.wav" }, 5.0 )
  ...
 
return data
end

The soundsetutil.lua provides a couple of functions that can be used:

makeSoundSet

The soundsetutil.makeSoundSet() function is the basic function that sets up the internal structure of the soundset for the use of other util functions. It is required to be used before the other functions.

addTrack

The soundsetutil.addTrack(data, name, refDist, updateFn) function is used to add a track to the sound set. The parameters are:

This function is very generic. More specific functions can be found below.

addEvent

The soundsetutil.addEvent(data, key, names, refDist, updateFn) function is used to add an event to the sound set. The parameters are:

If there is more than one sound file referenced, one is chosen randomly.

addTrackParam01

The soundsetutil.addTrackParam01(data, name, refDist, gainCurve, pitchCurve, param01) function is used to add a track to the sound set in dependance of an input parameter of the updateFn. The parameters are:

addSimpleTrackParam01

The soundsetutil.addSimpleTrackParam01(data, name, refDist, param01) function is a simplified version of the function above. Pitch is constant at level 1, while gain is equal to the input value. The parameters are:

addEventParam01

The soundsetutil.addEventParam01(data, key, names, refDist, gainCurve, pitchCurve, param01) function is used to add an event to the sound set in dependance of an input parameter of the updateFn. The parameters are:

addTrackSqueal

The soundsetutil.addTrackSqueal(data, name, refDist) function is a specialised function to add a track in dependance of the speed and side force. It usually can be heared when a train drives over switches. The parameters are:

addTrackBrake

The soundsetutil.addTrackBrake(data, name, refDist, maxGain) function is a specialised function to add a track in dependance of the speed and brake intensity. It usually can be heared when a vehicle decelerates. The parameters are:

addEventClacks

The soundsetutil.addEventClacks(data, names, refDist, axleRefWeight) function is a specialised function to add an event in dependance of the speed, weight and number of axles. It usually can be heared as small clack sounds when a train runs along tracks and the wheels run over imperfect welding seams or screwed track ends. The more weight lasts on an axle, the louder the sounds can be heared. The parameters are:

makeRoadVehicle2

The soundsetutil.makeRoadVehicle2(data, speeds, idle, idleSpeed, idleGain0, drive, driveSpeed, refDist, param01) function is a specialised function to add sounds for a road vehicle. The parameters are:

makeSteamTrain

The soundsetutil.makeSteamTrain(data, idle, fast, tracksRefDist, chuffNames, chuffsRefDist, chuffsFastFreq, refWeight) function is a specialised function to add sounds for a steam engine. The parameters are:

UpdateFn Input Parameters

Depending on the type of object, there are different parameters available for the updateFn function.

Town Buildings

Town Buildings only have the underConstruction parameter that is used to determine if the building currently is under construction. It returns 0 if not under construction, otherwise some values between 0 and 1 depending on the progress.

Stations

Stations have some parameters in relation to their size and the waiting cargo items and passengers:

Industries

Industries have two parameters that can be used for the sound configuration:

Road Vehicles

Road vehicles have different speed related parameters that can be used for the configuration:

Rail Vehicles

Rail vehicles have a lot of parameters that can be used for more complicated configurations:

Water Vehicles

Ships have some power and speed related parameters that can be used for the configuration of sounds:

Air Vehicles

Planes have some power and speed related parameters that can be used for the configuration of sounds:

Event Keys

Depending on the type of object, there are several keys available for the sound events defined in sound sets:

Event Key Town Buildings Stations Industries Road Vehicles Rail Vehicles Water Vehicles Air Vehicles Description
“random<n>” occurs approx. every n seconds (n is one of 1, 2, 4, 8, 16, 32, 64)
“openDoors” occurs after arrival at a station
“closeDoors” occurs before departure from a station
“horn” occurs at station departure
“clacks” occurs regularily while moving (for axle clacks)
“chuffs” occurs regularily while moving (for steam chuffs)
“sonicBoom” occurs when speed gets larger than the speed of sound
“land” occurs when the weels touch the ground