Settings
Any sound will accept the following settings.
๐๏ธ Usage
This allows to specify how audio will be handled in memory.
my_custom_audio:
file: ./somewhere/audio.wav
usage: on-demand
Each section already has its own default usage when left unspecified, see Sections.
You can choose between possible values: on-demand
, in-memory
and streaming
.
in-memory
The audio is loaded all-at-once in-memory on game startup and kept around for the whole duration of the game session.
on-demand
The audio is loaded all-at-once each time on-demand, and never kept around.
Short sounds that you don't want to permanently allocate memory for,
or that are not meant to be played frequently.
streaming
The audio is streamed on-demand.
Long-lasting sounds that should not be loaded all-at-once in-memory and only streamed on-demand.
๐ Volume
You can set Volume
factor as follow:
my_custom_audio:
file: ./somewhere/audio.wav
settings:
volume: 2.0 # 2 times louder !
my_other_audio:
file: ./somewhere/else/audio.ogg
settings:
volume: 0.5 # 2 times softer
๐ Start time
This will play your audio with a delay.
my_custom_audio:
file: ./somewhere/audio.wav
settings:
start_time: 10s # 10 seconds delay
๐ Start position
This will play your audio further from start.
my_custom_audio:
file: ./somewhere/audio.wav
settings:
start_position: 1s # start playing directly at 1s
Note that digits with decimal(s) are not supported, so if you would like to start the audio at e.g. 1.2s
, please specify 120ms
instead.
๐ Region
This will only play the specified region of audio.
my_custom_audio:
file: ./somewhere/audio.wav
settings:
region:
starts: 120ms # starts directly from 1.2s
ends: 8s # ends at 8s
You're not required to specify both starts
and ends
.
If left unspecified:
starts
will start at the beginning of the audio.ends
will play until the end of the audio.
Also kindly note that entire piece of audio still need to be loaded, in terms of memory, regardless its region.
๐ Loop
This will loop audio until explicitly stopped.
my_custom_audio:
file: ./somewhere/audio.wav
settings:
loop: true
โฉ Playback rate
This will play your audio faster, or slower.
my_custom_audio:
file: ./somewhere/audio.wav
settings:
playback_rate: x0.5 # plays twice as slow
my_custom_audio:
file: ./somewhere/audio.wav
settings:
playback_rate: x2 # plays twice as fast
You can also specify the value in semitones as follow.
my_custom_audio:
file: ./somewhere/audio.wav
settings:
playback_rate: 2โฏ # adjusts by 2 semitones
โ๏ธ Panning
This adjust from where the audio originates from, from left to right.
my_custom_audio:
file: ./somewhere/audio.wav
settings:
panning: 0.0 # plays fully on left side
my_custom_audio:
file: ./somewhere/audio.wav
settings:
panning: 1.0 # plays fully on right side
โคด๏ธ Fade-in tween
This will play your audio gradually fading-in.
my_custom_audio:
file: ./somewhere/audio.wav
settings:
fade_in_tween:
start_time: 1s # starts playing directly from 1s
duration: 3s # fade-in duration
Linear: # linear fade-in curve (no value needed)
my_custom_audio:
file: ./somewhere/audio.wav
settings:
fade_in_tween:
start_time: 1s # starts playing directly from 1s
duration: 3s # fade-in duration
InPowi: 3 # easing-in with power 3
Possible values for easing
can be found here.
Note that fade-out can be specified as a parameter when calling methods like Stop
, Switch
, etc. see AudioSettingsExt.