This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Can't loop sound

2dvoxel2dvoxel Posts: 7Member

I imported a .wav file to use it as sfx in a scene, my issue is that that sounds just plays once instead of being looped until a timer runs out.
Basically it's the sound of a fuse for a bomb, until the timer sends the signal the sound should stop playing and play the explosion sound.


Attached the images, on how i imported the file, both in the import tab and the inspector tab have the loop option active, i don't know what else i need to make the sound loop.

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 2,561Admin

    You can probably make the sound loop through GScript and the finished signal. Something like this:

    extends AudioStreamPlayer
    export (bool) var loop_sound = true
    func _ready():
        connect("finished", this, "_on_finished")
    func _on_finished():
        if loop_sound == true:
            play();
    

    Then you can trigger it to start playing like a normal AudioStreamPlayer. Though, having the loop option selected should make the audio loop. Maybe its a bug? If there is not one already open on this issue, it might not be a bad idea to open a bug report on the Godot GitHub (I didn't see any issues on the topic, but I only took a brief look). If you can, a minimum replication project that shows the bug would also be so developers can see if the bug is fixed, but is not required.

  • bitshift-rbitshift-r Posts: 54Member

    Did you re-import after activating the loop option?

  • 2dvoxel2dvoxel Posts: 7Member

    @bitshift-r said:
    Did you re-import after activating the loop option?

    yes, didn't work

    @TwistedTwigleg said:
    You can probably make the sound loop through GScript and the finished signal. Something like this:

    extends AudioStreamPlayer
    export (bool) var loop_sound = true
    func _ready():
    connect("finished", this, "_on_finished")
    func _on_finished():
    if loop_sound == true:
    play();

    Then you can trigger it to start playing like a normal AudioStreamPlayer. Though, having the loop option selected should make the audio loop. Maybe its a bug? If there is not one already open on this issue, it might not be a bad idea to open a bug report on the Godot GitHub (I didn't see any issues on the topic, but I only took a brief look). If you can, a minimum replication project that shows the bug would also be so developers can see if the bug is fixed, but is not required.

    seems like a workaround but okay, will try later that

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    Could it be that 100000 for the loop end is too large a number and it is looping but just taking a long time before it replays?

  • 2dvoxel2dvoxel Posts: 7Member

    @Megalomaniak said:
    Could it be that 100000 for the loop end is too large a number and it is looping but just taking a long time before it replays?

    Yeah you are right, well more or less, the sound kinda extends a bit and then dies, but no what i had in mind, still, im gonna try a few more times.

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    Also as a sanity check try using an audio file in another format, ogg perhaps?

  • 2dvoxel2dvoxel Posts: 7Member

    yes, the file .wav

  • SIsilicon28SIsilicon28 Posts: 693Moderator

    Was the loop end set manually?

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    @2dvoxel said:
    yes, the file .wav

    Thing about it is that there are multiple formats to wav Microsofts is just one, but your file might be in the apple format or any other. They aren't the same.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.