Can't loop sound

2dvoxel2dvoxel Posts: 13Member

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: 3,076Admin

    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: 67Member

    Did you re-import after activating the loop option?

  • 2dvoxel2dvoxel Posts: 13Member

    @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,884Admin

    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: 13Member

    @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,884Admin

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

  • 2dvoxel2dvoxel Posts: 13Member

    yes, the file .wav

  • SIsilicon28SIsilicon28 Posts: 757Moderator

    Was the loop end set manually?

  • MegalomaniakMegalomaniak Posts: 2,884Admin

    @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.

  • 2dvoxel2dvoxel Posts: 13Member

    @SIsilicon28 said:
    Was the loop end set manually?

    yes

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file