Get sample position in bytes and proper looping.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 9BitStrider

I’m having trouble getting my sample to loop the way I want it to. I have a WAV file that plays a charge up sound effect. Thing is, I want the sample to loop back to a certain point once it crosses a certain position in the sample. Clicking ‘Loop’ in the import window makes it loop from beginning to end. And editing the Loop Begin/End values does nothing.

EDIT: Correction. The looping works perfectly in the inspector window when I hit play at the bottom. But in game? Nothing.

Godot 3.1.2

I think you found a bug, but it seems to work when setting the loop start or end via script.
For example:

func _ready():
    $ = 10000

Adam_S | 2020-01-10 02:02

:bust_in_silhouette: Reply From: LucasTheDrgn

I was having this same issue and did some debugging and digging around: It would appear Godot always uses the loop data written into the wave file, even when specified otherwise in the editor, even when no loop data is present. They suggest Sound Forge or Audition to add these loop points (which are both very not free software), I found luck with Wavosaur. Opened up the file, selected Tools > Loop > Create loop points, then Tools > Loop > Properties and pasted the sample numbers I was attempting to put into Godot’s editor. After saving and allowing Godot to reimport the audio, my test calls to get_loop_begin and get_loop_end both returned the desired values (even though I had reset them in the editor, as an extra verification that it completely ignores these values).