Can Godot play sound samples with no noticeable delay?

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

I made a very simple project with a base node and child SamplePlayer node. I added a sample to the sample library and wrote the code below:

extends Node2D

func _ready():
    set_process_input(true)

func _input(event):
    if event.type == InputEvent.MOUSE_BUTTON \
    and event.button_index == BUTTON_LEFT \
    and event.pressed:
        get_node("SamplePlayer").play("sample")

My hope was that there would be no delay between clicking the mouse and hearing the sample. However, there is about 0.1 seconds of delay between the mouse click and the sample being heard. Is there a way to eliminate this delay, or reduce it so it is not noticeable?

I’m VERY new to all of this but I’ve seen mention of pre loading scenes and resources in other threads. Is there some way you can perhaps pre load the sample which may speed up the reaction time?

Robster | 2016-09-21 00:15

AFAIK the audio engine will be rewritten in 3.0

timoschwarzer | 2016-09-29 17:09

:bust_in_silhouette: Reply From: Freeman

There is a way. SamplePlayer is probably your best choice for playing sounds in the shooting game that does not require a time critical audio reactions.
However if you need a relatively low audio latency experience you should use AudioServer, that provides low level audio access.
For me it works well in music related games/apps, giving less latency, quite good performance and better audio playback control.