Music Looping Problem

0 favourites
  • 8 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • My friend and I are making a game, and a really important part of the game is music. We've written a great deal of the songs for the game already, and all of them are written to loop flawlessly.

    However, there is reverb in most of the songs, so when a song is mixed down to an .ogg, there is a couple of seconds of lingering sound at the end that plays out before the song is really "over". So the traditional 'loop song at end' isn't an option, else there would be a stupid 3 or so second delay between loops.

    So I programmed a song to play on the 'start of layout' that doesn't loop, then I made another event that plays the song every 78000 ms, which is the exact duration of the song from the very beginning to the end of the last note (this doesn't include the reverb at the end).

    So I expect the song to start playing instantly when the layout starts, and for the song to continue looping seamlessly afterwards.

    The first loop doesn't work very well. The song starts a second time just a second or two before the first play-through of the song is finished, and it sounds really weird. Afterwards, however, the looping is just fine. Once the song is looping on the event: "autoplay every 78000 ms", the loop sounds exactly how I expected it to. So it's just the first loop that's messed up, apparently.

    Note: I'm using the xAudio2 object for sound

    Does the clock that counts the milliseconds not necessarily begin exactly when the "start of layout" event is run?

    If anybody could tell me anything about this, or suggest a better alternative to my looping songs problem, I would be EXTREMELY grateful. Thanks in advance! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Forget about c2 clock for precision counting. What you could do is either use delta time, or move the final reverb tail to the beginning of the track and then fade in on start of layout instead of starting straight away.

  • megatronx Those are some good suggestions. I've actually considered the second before. Can you suggest a way of using the delta time function? I've not ever used, or even heard of it. How would you go about looping the music with it? Also, thanks for the help!

  • You could try the Timer behaviour. It should be simpler that tracking delta-time. Also make sure the music is preloaded so you know there is no initial delay.

  • I would think trying to time when a point in a song will happen is a bit much to ask of a browser. Even setting it to loop doesn't work everywhere.

    It may work soon, it's amazing how far sound has come in the past year. But currently you may be trying to make a silk purse out of a sows ear.

    Delta time compensates for slowness due to slow processors and internet lag so that timed events can skip ahead when it needs to stay lined up. But if the sound doesn't start when the timer thinks it does, you have to hope the exact same lag affects the 2nd piece too.

  • blackhornet I don't think I have access to the 'timer'. I will confess. I'm currently using Construct Classic... <img src="smileys/smiley13.gif" border="0" align="middle" />

    Paradox I was thinking this game would be more of an application that you download and play offline afterwards. Do people still do that?

  • Oh Classic. That is completely different animal, I don't know enough about that to offer a suggestion.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • megatronx How do you fade music? I'd like to fade it in and out between layouts (and preferably fade the layouts too).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)