-
-
Notifications
You must be signed in to change notification settings - Fork 23
AudioCue
Inherits Resource.
Audio clips (music or sounds) that can be played, faded, or stopped. Defines the properties to use when the AudioManager wants to play the AudioStream linked to this object.
-
attenuation float. Default
1.0
. Defines the attenuation to apply to the audio stream player to use when playing this cue.⚠️ Not used in any script yet. - audio AudioStream. The resource of the audio file to play.
-
bus String. Default
'Master'
. The bus where the audio will be played. -
is_2d bool. Default
false
. Whether the audio will be played as an AudioStreamPlayer or an AudioStreamPlayer2D. -
loop bool. Default
false
. Whether the cue will loop when played. -
max_distance float. Default
2000.0
. Defines the value to assign to the max_distance property in the AudioStreamPlayer2D when the cue is 2D (is_2d == true
). -
pitch float. Default
0.0
. The pitch (in semitones) to apply to thepitch_scale
property of the audio stream that will play this audio cue. -
rnd_pitch Vector2. Default
Vector2.ZERO
. The lower (Vector2.x
) and highest (Vector2.y
) values to use when randomly altering the pitch of the audio to play. -
rnd_volume Vector2. Default
Vector2.ZERO
. The lower (Vector2.x
) and highest (Vector2.y
) values to use when randomly altering the volume of the audio to play. -
volume float. Default
1.0
. The volume for the audio to play.
-
change_stream_pitch( float
pitch = 0.0
) voidChanges to
pitch
the pitch_scale in the audio stream that is playing the audio file of this AudioCue. -
change_stream_volume( float
volume = 0.0
) voidChanges to
volume
the volume_db in the audio stream that is playing the audio file of this AudioCue. -
fade( float
duration = 1.0
, boolwait_to_end = false
, floatfrom = -80.0
, floatto = INF
, Vector2position_2d = Vector2.ZERO
) AudioStreamPlayer / AudioStreamPlayer2D🍑 Use this to play an AudioCue inside an E.run() (a.k.a. queue of instructions) 🍑.
Plays this audie cue with a fade that will last
duration
seconds. You can specify the starting volume withfrom
and the target volume withto
. Can be yield.# Plays sfx_turn_on_pc with a fade of 2 seconds. # Won't pause the queue of instructions waiting for the clip to end. yield(E.run([ C.walk_to_clicked(), A.sfx_turn_on_pc.fade(2.0), 'Player: I should not being doing this.' ]), 'completed')
-
fade_now( float
duration = 1.0
, boolwait_to_end = false
, floatfrom = -80.0
, floatto = INF
, Vector2position_2d = Vector2.ZERO
) AudioStreamPlayer / AudioStreamPlayer2DPlays immediately this audio cue with a fade that will last
duration
seconds. You can specify the starting volume withfrom
and the target volume withto
. Can be yield ifwain_to_end
istrue
.# Plays sfx_turn_on_pc with a fade of 2 seconds. # Will wait for the fade to end. yield(A.sfx_turn_on_pc.fade_now(2.0, true), 'completed') # Once the sound effect stops playing, characters will say something E.run([ "Player: I'm ready to use this computer now", "Popsy: Let's check the email" ])
-
get_pitch() float
Returns the
pitch_scale
to apply to the audio stream player that will play the audio of this audio cue. Ifrnd_pitch
is different toVector2.ZERO
, a random pitch value (in semitones) will be generated and returned transformed to a valid pitch value. Ifrnd_pitch
is equals toVector2.ZERO
, then the value returned will bepitch
transformed from semitones to a valid pitch value. -
stop( float
fade_duration = 0.0
) void🍑 Use this to stop the audio cue inside an E.run() (a.k.a. queue of instructions) 🍑
Stops the audio cue. Can use a fade that will last
fade_duration
seconds. Can be yield.func on_interact() -> void: E.run([ "Player: I'm tired of this shit!!!", A.mx_classic.stop(), A.sfx_radio_noise.stop(), '....', "Player: That's better" ])
-
stop_now( float
fade_duration = 0.0
) voidStops the audio cue. Can use a fade that will last
fade_duration
seconds. Can be yield.func on_room_exited() -> void: A.mx_bar.stop_now(2.0) A.sfx_bar_ambience.stop_now(2.0)
-
set_values( Dictionary
values
) voidMaps the values in
values
to the properties of this audio cue.Used by TabAudio.gd when changing the script of the audio cue to one of the types: AudioCueSound or AudioCueMusic.
-
get_values() Dictionary
Returns the properties of this audio cue as a Dictionary.
Used by TabAudio.gd when changing the script of the audio cue to one of the types: AudioCueSound or AudioCueMusic.
-
_get_rnd_pitch() float
Returns a random float between
rnd_pitch.x
andrnd_pitch.y
. -
_get_rnd_volume() float
Returns
volume
adding to it a random float betweenrnd_volume.x
andrnd_volume.y
. -
_set_loop( bool
value
) voidSets
value
toloop
, and depending on the type of the audio file (AudioStreamOGGVorbis, AudioStreamMP3, or AudioStreamSample (for WAV files)), changes the corresponding property in the AudioStream.