Skip to content

SoundSource ​

Inherits: Resource

Where a sound comes from: one track with its own options, an album, or a Dynamic Music. The world, a zone, a weather and an encounter each hold some (music, ambience, combat music); an event sets one. An empty source says nothing, and the place below it in the order (encounter > event > shelter > weather > zone > world) decides. Ambience uses a track only; music and combat music can use an album or a Dynamic Music. See docs: Audio > Music Albums, Audio > Dynamic Music.

Properties ​

KindkindKind.NONE
Stringtrack_path""
intalbum_id0
intdynamic_id0
Stringstart_state""
boollooptrue
floatdelay_min0.0
floatdelay_max0.0
floatvolume_db0.0
floatfade_seconds-1.0
SoundSourcenight_sourcenull

Methods ​

SoundSourceof_track( path: String, p_loop: bool = true, p_volume_db: float = 0.0 ) static
SoundSourceof_album( p_album_id: int ) static
SoundSourceof_dynamic( p_dynamic_id: int, p_start_state: String = "" ) static
SoundSourcefor_time( night: bool )
boolhas_content()
boolis_set()
SoundAlbumget_album()
DynamicMusicget_dynamic()
floatroll_delay( rng: RandomNumberGenerator )
PackedStringArrayget_track_paths()
Stringdescribe()
PackedStringArrayvalidate()
SoundSourcewith_volume_offset( offset_db: float )
boolsame_as( other: SoundSource )

Enumerations ​

enum Kind ​

What the source is

  • NONE = 0
  • TRACK = 1
  • ALBUM = 2
  • DYNAMIC = 3

Property descriptions ​

Kind kind = Kind.NONE ​

None = this source says nothing; Track = one track with the options below; Album = a collection of tracks (Audio > Music Albums); Dynamic = music that changes with the game (Audio > Dynamic Music)

String track_path = "" ​

The track (a file of the audio library) when the source is a Track

int album_id = 0 ​

The id of the album when the source is an Album (a Music Album for music, a Combat Music Album for combat music)

int dynamic_id = 0 ​

The id of the Dynamic Music when the source is Dynamic

String start_state = "" ​

Dynamic: the state the music starts in (empty = the start state of the music)

bool loop = true ​

A track plays again when it ends (on) or once (off). An album has its own loop setting

float delay_min = 0.0 ​

The silence before a looping track plays again, in seconds (a random time between the two; 0 = it loops with no break)

float delay_max = 0.0 ​

No description yet.

float volume_db = 0.0 ​

How loud it is (dB)

float fade_seconds = -1.0 ​

The seconds the sound takes to come in when this source starts (-1 = the project's default)

SoundSource night_source = null ​

What plays at night instead of this (the day) source: a source of its own (a track, an album or a Dynamic Music with its options). Null = the same all day and all night. The sun decides when it is night (TimeOfDay: between the sunset and the sunrise of the Sun config), and the sound changes over the fade of the source that starts

Method descriptions ​

SoundSource of_track( path: String, p_loop: bool = true, p_volume_db: float = 0.0 ) ​

A source that is a track

SoundSource of_album( p_album_id: int ) ​

A source that is an album

SoundSource of_dynamic( p_dynamic_id: int, p_start_state: String = "" ) ​

A source that is a Dynamic Music, starting in a state (empty = its start state)

SoundSource for_time( night: bool ) ​

The source that plays at this time: the night source at night when it says something, else this one

bool has_content() ​

Does this source, or its night source, say anything? (a layer keeps a source that only has a night version)

bool is_set() ​

Does this source say anything? A track needs a path, an album or a Dynamic Music an id

SoundAlbum get_album() ​

The album of an Album source (null when it is not one, or the album is gone)

DynamicMusic get_dynamic() ​

The Dynamic Music of a Dynamic source (null when it is not one, or the music is gone)

float roll_delay( rng: RandomNumberGenerator ) ​

The silence before the next play, picked now (seconds)

PackedStringArray get_track_paths() ​

Every file this source can play (the track, or the tracks of the album): what the world preloads

String describe() ​

A name for the editor and the logs

PackedStringArray validate() ​

The warnings of this source

SoundSource with_volume_offset( offset_db: float ) ​

A copy with a louder or quieter volume (the weather makes its ambience quieter in a light weather)

bool same_as( other: SoundSource ) ​

Two sources that play the same thing the same way (the player does not start the same source again)