Sound keeps looping

CaribaLedonCaribaLedon Posts: 5Member

Hi there!
I want to play a sound effect ONCE. To do so, I imported a .wav file into Godot. In the import panel, 'Loop' is NOT checked.
Then I assigned the wav to an AudioStreamPlayer3D.

When I call $MySound.play() once in a script, the sound keeps on repeating endlessly.

How can I make sure the sound is only played once?
Thanks! :)

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 4,292Admin

    This discussion was caught in the moderation queue since you have not confirmed your account yet.

    Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

    (Note: You do not need to repost, the discussion has been moved out and is visible now)

    If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

  • DaveTheCoderDaveTheCoder Posts: 237Member
    edited February 15

    I saw a tip that might help:

    Select the sound file in the File System dock, verify that Loop is unchecked in the Import panel and click Reimport.

  • ZeltaZelta Posts: 122Member

    @DaveTheCoder said:
    I saw a tip that might help:

    Select the sound file in the File System dock, verify that Loop is unchecked in the Import panel and click Reimport.

    yeah, .ogg files are imported with loop by default, I went crazy a day for this

  • CaribaLedonCaribaLedon Posts: 5Member

    @DaveTheCoder said:
    I saw a tip that might help:

    Select the sound file in the File System dock, verify that Loop is unchecked in the Import panel and click Reimport.

    Yeah, Loop is unchecked. I also hit the Reimport button more than once ;-)
    Sadly this does not change a thing. The sound is still looping...

  • MegalomaniakMegalomaniak Posts: 3,567Admin

    Your code might just be the one on loop/reevaluated such that it effectively loops.

  • CaribaLedonCaribaLedon Posts: 5Member

    I have created a minimal example project that shows the issue. It is just a single camera + audio player. When the scene starts, play() is called once. Still the sound keeps on looping forever.

    You can download the scene here:
    https://drive.google.com/file/d/1GPMw0UH9tTqye9F_Ud0OReMM2aCuemKM/view?usp=sharing

    Am I missing something very simple here? Or is this a bug in Godot?

  • MegalomaniakMegalomaniak Posts: 3,567Admin
    edited February 18

    Interesting, I set stream paused to true and then false again and it's not playing anymore. But even with the line commented out it previously played without stream paused set to true.

    edit: So the actual resource seems to still have Looping set to Forward:

    However even with it set to disabled via inspector, during runtime it is still somehow set back to "Forward" state according to remote inspection. I think it's a bug.

  • sairam134sairam134 Posts: 2Member

    I am having the same issue now, have any fixes been found?

  • mralienboimralienboi Posts: 1Member

    I've been having the same issue. I tried using ogg, mp3 nothing. Looping is off. Im beginning to think that this is an actual bug.

  • cyberealitycybereality Posts: 1,456Moderator

    I encountered this recently with an AudioStream but my confusion was that Wav files are not looped by default by MP3s are (strange decision). I just click the import tab and deselected loop and reimported.

    @mralienboi Can you upload a minimal example of the problem? I can take a look, it is possible there is a bug but maybe it is something wrong in your setup.

  • CalinouCalinou Posts: 615Admin Godot Developer
    edited May 2

    I encountered this recently with an AudioStream but my confusion was that Wav files are not looped by default by MP3s are (strange decision). I just click the import tab and deselected loop and reimported.

    Sound formats designed to be used for background music and ambient sounds (Ogg Vorbis and MP3) are looped by default, but formats designed for sound effects (WAV) aren't.

    This behavior could be changed by default for 4.0, but it will likely break user expectations for anyone realizing that their music won't loop anymore…

  • cyberealitycybereality Posts: 1,456Moderator

    Okay. That makes sense. I did look at any docs or anything, I just pasted audio into the project and it tripped me up for a few minutes (I looked online and realized shortly after). It's not a huge deal, since now I know how it works.

Leave a Comment

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