Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sound looping 'pop' (sugarcube 2.11.0)

Yes, I realised I've asked this before, but it was one part of a double question and never really got discussed much.

I can't be the only one who uses loops on their audio tracks so I'm putting this out to anyone who's discovered a way to mask the little 'pop' noise you hear when the sound clip ends, then starts its next loop.

I use Audacity to create my sound files and did try fading out the clip, but this only accentuates the split.

Any ideas appreciated.

Comments

  • Two possible issues:
    1. Your audio tracks need to be a) gapless and b) be designed to work that way—i.e. the end of the track must seamlessly transition into the beginning of the track.
    2. The HTML5 media elements do not guarantee gapless playback.
  • edited November 2016
    Thank you. I'm referring here to a single continuous sound clip of about 15 seconds, so each of the ones I'm using as loops is definitely gapless.

    I understand issue B, but even if I took the time to do this I don't see how it would eliminate the gap.

    I very much suspect there's nothing can be done, as what I'm hearing is that split-second, unavoidable moment of silence as the track stops then starts up again.
  • Jud_Casper wrote: »
    I understand issue B, but even if I took the time to do this I don't see how it would eliminate the gap.
    If there is a seam, then it will exacerbate any gapping issues and sound poor in general.

    Jud_Casper wrote: »
    I very much suspect there's nothing can be done, as what I'm hearing is that split-second, unavoidable moment of silence as the track stops then starts up again.
    As a self-help project, you may be able to use Howler.js in Web Audio API mode, not HTML5 media element mode, to resolve the issue if it's really important to you—completely untested.

    That would come with its own issues though. Notably, all such audio has to be completely loaded before use and must stay loaded for the lifetime of its use. It's also much more strict about cross-origin resource sharing (CORS) issues.
  • edited November 2016
    Best way is to increase the track length and design it around minimising fades. 15 seconds is way too short for an ambient track.

  • I think I'll swerve the Howler.js - I struggle getting my head around the most basic of scripts.

    Claretta, the only reason I keep tracks short is because I've not yet investigated max file size for games. The last thing I want is to end up with a game that's too big (file size wise) because it's littered with big audio files.

    I only really have two ambient tracks that are designed to play on a loop long term. That is a general 'outside' noise (wind basically) and a rain track for periods I want it to be raining.

    I understand what you're saying - that an ambience which 'pops' at the loop every two minutes is going to be far less noticeable than one that pops every 15 seconds, but can I safely include tracks that long without compromising file size?
  • edited November 2016
    Well you shouldn't be trying to do seamless looping. Ambient noise that is in your face all the time is annoying, so having it fade in and out is a good sound design technique that basically solves the problem. It's what I do in my game.

    But to do it, yes you do need longer tracks (at least a minute). a 1 minute ogg at 0.5 quality is about a megabyte, which should be ok.

    If you don't have heaps of audio, I don't think you should worry so much about file sizes. YouTube videos are waaaaay bigger than a few MB, and people stream those all the time. We don't need to design for dial up.
  • I hope you are also including a way for the reader to mute the ambient noise.
  • edited November 2016
    Well I think we'll have to agree to disagree on one thing, Claretta. Firstly my 'outside' ambience is barely noticeable, but a track where the loop is highlighted by a regular fade out/fade in would be far more annoying to me than a constant one.

    However, my audio file sizes come in at an average of 50-60kb, so good to know I have room for at least a couple of a decent length.

    greyelf, do you mean a way to mute all sounds, or just the ambience? I haven't included such an option and wouldn't know how, so I'll have to look it up.

    Would it be as simple as adding:
    <<link "mute ambience">><<audio "out_side" mute>><</link>>
    
    in the sidebar?


    [EDIT] Yes it would. That was simpler than I feared.

  • You might want to allow that to be toggled. Additionally, if you're going to add the ability to mute some audio, then I'd suggest adding a way to mute the master volume as well.
  • I wasn't sure how to toggle, TME, so I just added another link to unmute.

    I assume muting master is done in the same way, but if you could advise on the toggle method that would be appreciated.
  • Try something like the following:
    <<link "Toggle BGM">>
    	<<if setup.bgmIsMuted>>
    		<<audio "out_side" unmute>>
    		<<set setup.bgmIsMuted to false>>
    	<<else>>
    		<<audio "out_side" mute>>
    		<<set setup.bgmIsMuted to true>>
    	<</if>>
    <</link>>
    <<link "Toggle Audio">>
    	<<if setup.audioIsMuted>>
    		<<masteraudio unmute>>
    		<<set setup.audioIsMuted to false>>
    	<<else>>
    		<<masteraudio mute>>
    		<<set setup.audioIsMuted to true>>
    	<</if>>
    <</link>>
    
    There's no reason for this to persist beyond a restart, so using the setup object to track each of the mute states is ideal.
  • Like a charm! You're a coding marvel. Thank you.
  • edited November 2016
    Jud_Casper wrote: »
    Well I think we'll have to agree to disagree on one thing, Claretta. Firstly my 'outside' ambience is barely noticeable, but a track where the loop is highlighted by a regular fade out/fade in would be far more annoying to me than a constant one.

    Real wind and raid sounds fade in and out. Wind and rain isn't constant. If it's really well done, ambient noise which fades in and out shouldn't be annoying.

    I don't think muting controls are truly necessary in all games, though. It really depends on the game.
  • Yes, real life ambient sounds come and go, but not at regular intervals as they would with a looped track in a game.

    I dunno, you might be right, it's just my hope that my sounds won't even be noticed after a while. They're not loud or intrusive and in any case they now have the option to disable them if they do get annoying.
  • You can make the track much longer, like 5 minutes.
  • edited November 2016
    I've increased the length of the two ambient sounds (outside and rain) to 50 seconds or so. I think this will be long enough for the 'pop' of silence when the track loops to be not so annoying.

    I agree that if the track was as long as 5 minutes, a fade out / fade in would probably be the best option.
Sign In or Register to comment.