"Soundscript" container

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(Example Config.txt)
(distance)
 
Line 35: Line 35:
 
:Default: 50,150
 
:Default: 50,150
 
:Compulsory: No
 
:Compulsory: No
:Desc: Distance range from the source, in meters, where the sound is audible. The minimum distance defines the radius within which the sound remains at 100% volume. Beyond that distance, the sound volume will begin to decay naturally. The maximum distance defines a radius beyond which the game will no longer play the sound. This does not mean that the sound will fade to zero by the maximum distance, but rather that the sound will cut off abruptly at that point. It is up to the content creator to choose an appropriate distance - smaller is better for performance.
+
:Desc: The minimum distance (first value, in meters) defines the radius within which the sound remains at 100% volume. Beyond that distance, the sound volume will begin to decay naturally. The maximum distance (second value, in meters) defines a radius beyond which the game need no longer play the sound. This does not mean that the sound will fade to zero by the maximum distance, but rather that the sound may cut off abruptly beyond that point. It is up to the content creator to choose an appropriate maximum distance - smaller is better for performance, but overly small values may result in the sound audibly cutting off. Many Trainz editions ignore the configured maximum distance value and instead perform their own optimized calculation of the appropriate value.
  
 
====nostartdelay====
 
====nostartdelay====

Latest revision as of 11:50, 12 June 2019

A container type tag for defining asset sounds.

Contents

[edit] Supported Tags

Each soundscript subcontainer supports the following tags. Each tag is shown here with its default value.

 repeat-delay  0,0
 distance      50,150
 ambient       0
 attachment    ""
 nostartdelay  0
 priority      1
 trigger       ""
 volume        1
 value-range   0,0
 sound-asset
 sound
 {
 }

[edit] ambient

Type: Boolean
Default: 0
Compulsory: No
Desc: If true this is an 'ambient' sound, ambient sounds are played in 2D and do not make use of 3D positioning in the world other than to affect volume. Unlike positional sounds, ambient sounds may be stereo.

[edit] attachment

Type: Attachment point
Default: ""
Compulsory: No
Desc: Point to attach the sound source to. Attachment points are specified in the mesh file during creation.

[edit] distance

Type: Decimal Pair
Default: 50,150
Compulsory: No
Desc: The minimum distance (first value, in meters) defines the radius within which the sound remains at 100% volume. Beyond that distance, the sound volume will begin to decay naturally. The maximum distance (second value, in meters) defines a radius beyond which the game need no longer play the sound. This does not mean that the sound will fade to zero by the maximum distance, but rather that the sound may cut off abruptly beyond that point. It is up to the content creator to choose an appropriate maximum distance - smaller is better for performance, but overly small values may result in the sound audibly cutting off. Many Trainz editions ignore the configured maximum distance value and instead perform their own optimized calculation of the appropriate value.

[edit] nostartdelay

Type: Boolean
Default: 0
Compulsory: No
Desc: If added and true this tag specifies that the sound will play immediately once triggered. By default sounds have a random start delay between 0 & 4 seconds. Start delay should be left active in most cases, as turning it off may cause significant audio artifacts when several identical sounds are in proximity.

[edit] priority

Type: Integer
Default: 1
Compulsory: No
Desc: Sets the priority of the sound, if their are not enough sound channels available higher priority sounds will be played first. Defaults to 1, can be negative.

[edit] repeat-delay

Type: Decimal Pair
Default: 0,0
Compulsory: No
Desc: Time range (in seconds) to delay, after the sound finishes playing, before playing the sound again. To set a constant delay either set both these values the same or only provide one of them, otherwise a random value between them will be chosen. When used with a trigger event (see the 'trigger' tag), a positive value indicates that the sound should not repeat, but should wait until triggered again.

[edit] sound

Type: Container
Default: {}
Compulsory: Yes
Desc: Contains list of the sound files to play. If the list has more than one entry then one file will be picked at random from the list. The value of each tag in this container is the filename of a WAV sound file. Filenames are relative to the base directory of the asset, i.e. relative to the location of the config file.
Valid WAV files are:
  • Uncompressed.
  • 8 or 16 bit
  • Mono, Stereo or Surround
Sampling rate can be 22kHz (22,050Hz) or 44kHz (44,100Hz). The higher sampling rate doubles the size of the file for no significant improvement in quality, and is not recommended. For some purposes there are additional requirements - for instance directional sounds must be mono.

[edit] sound-asset

Type: KUID
Compulsory: No
Desc: The asset to source the sound files from. Allows the creation of "sound library" assets, so that sound files can be shared between multiple other assets. Defaults to the current asset.

[edit] trigger

Type: String
Default: ""
Compulsory: No
Desc: The 'trigger' tag gives your sound a name that can allow it to be played from TrainzScript (see: Class MapObject), animations and certain predefined events. (At least one of these "predefined events" is to use the word "toggle" when including a soundscript container in the config.txt of a "MOjunction". This will make the sound fire each time the turnout is switched)

[edit] value-range

Type: Float pair
Default: 0,0 (off)
Compulsory: No
Desc: 2 numbers, where the numbers are not the same, which set the start and end times for the sound to play. Midnight is 0.5, midday = 0.0 or 1.0. (TBD. This is a bit vague.)

[edit] volume

Type: Decimal
Default: 1
Compulsory: No
Desc: Specifies the volume gain of the sound. Defaults to 1 (100%).


[edit] Example Config.txt

Sample config.txt file for a map asset that has a different day and night background sounds:

 kind map
 kuid <KUID:0:0>
 soundscript
 {
   morning
   {
     ambient 1
     value-range 1, 0.1
     volume 0.3
     sound
     {
       0 "ctry_day_1.wav"
       1 "ctry_day_2.wav"
     }
   }
   night
   {
     ambient 1
     value-range 0, 0.9
     volume 0.3
     sound
     {
       0 "night_loop.wav"
     }
   }
 }

[edit] Categories

Personal tools