+4 votes

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

in Engine by (290 points)

1 Answer

+3 votes
Best answer

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!

by (50 points)
selected by

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

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.