How do you add audio in the new audio sampler in godot 3.0?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By stubbsy345
:warning: Old Version Published before Godot 3 was released.

I’m sure i’m missing something very obvious but I can’t see how to add my audio samples into the sample player?

:bust_in_silhouette: Reply From: Chip Collier

Howdy!

I bumped against this as well. But from what I found there isn’t currently an audio sample library or sample player in Godot 3.0.

What I did instead, and perhaps will work for you, was to create an AudioStreamPlayer node for each sound effect and loaded my wav file via the “Stream” property . For my case in the scene representing the player I only had one or two sounds I wanted to emit.

In the script for the player I got a reference to these nodes and used the play method to trigger the audio:


    var jump_sound
    
    func _ready():
        jump_sound = get_node("Jump")
        set_process_input(true)
    
    fun _input(event):
        if event.is_action_pressed("player_jump"):
            jump_sound.play()

I used this pattern in several places and am happy enough with it. I imagine it could become a chore with larger setups, and I don’t know about mixing or anything yet.

Hope that helps!

I have hundreds of sound effects in my project. I am not sure this is a good solution for me.

Diet Estus | 2018-03-14 01:03

I have several audio too in my project so…I think is not for either…

ferhand | 2018-09-18 22:34