Skip to content

AudioCue

Carenalga edited this page Feb 11, 2023 · 6 revisions

Description

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.

Properties

Export

  • 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 the pitch_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.

Methods

Public

  • change_stream_pitch( float pitch = 0.0 ) void

    Changes 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 ) void

    Changes to volume the volume_db in the audio stream that is playing the audio file of this AudioCue.

  • fade( float duration = 1.0, bool wait_to_end = false, float from = -80.0, float to = INF, Vector2 position_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 with from and the target volume with to. 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, bool wait_to_end = false, float from = -80.0, float to = INF, Vector2 position_2d = Vector2.ZERO ) AudioStreamPlayer / AudioStreamPlayer2D

    Plays immediately this audio cue with a fade that will last duration seconds. You can specify the starting volume with from and the target volume with to. Can be yield if wain_to_end is true.

    # 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. If rnd_pitch is different to Vector2.ZERO, a random pitch value (in semitones) will be generated and returned transformed to a valid pitch value. If rnd_pitch is equals to Vector2.ZERO, then the value returned will be pitch 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 ) void

    Stops 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 and get

  • set_values( Dictionary values ) void

    Maps 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.

Private

Clone this wiki locally