C3 doesn't allow 2 of the same music track to be played simultaneously, preventing proper looping.

0 favourites
  • 8 posts
From the Asset Store
6 looping tracks to use in your games and projects. These tracks are in the style of the 1960s detective movie genre.
  • Most if not all music tracks will have a "tail" or "remainder" at the end consisting of reverb, delay effects, decay of an instrument, etc. or maybe the composer simply wants some sustain at the end of the track that overlaps the following loop a bit.

    As such, the loop needs to start playing at a specified point shortly before its previous one has ended, resulting in a bit of an overlap. This can't be done with the Audio object's built-in looping.

    However, this can be done with audio scheduling. Problem solved!

    Or so I thought... It appears that Construct doesn't allow you to stack playback of identical music tracks, so when I go to play a new loop just before the end of the previous one (as to not cut off the remainder) it instead replaces the previous loop and...yep, cuts off the remainder.

    This isn't a problem when using 2 different tracks (e.g. having a one-off intro track overlap the beginning of a different, looping track) so I don't understand why we can't also do that with multiple of the same track, unless it's some sort of safety measure to prevent people from doing this on accident (in which case there should just be a parameter to define how many "stacks" or "layers" of the same track can be played simultaneously - this would actually be very useful for sounds!)

    Anyway, hopefully I've explained this well enough. Ashley would it be possible to allow this or add an option to do so? I can file a suggestion if needed. The only workarounds are to have a duplicate of the same music track with a different name and then alternate between the two, or play the music tracks from the sound folder...but obviously neither of those are a good idea lol.

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why not just mix the tail in to the start of the track? That's what you'd normally do to make a looping audio track.

  • Having done this many times for tracks in different platforms in my opinion it is always better to bake in the song tail to the start of the looped track as Ashley says.

    If the tail is quite distinct (e.g. a delay) you can use two tracks, the initial clean track, followed by the looped track with the baked in tail at the start.

  • Ashley I've done this before with mixed results and would ultimately consider it a workaround/hack. Having the tail mixed into the start is really obvious in some cases. Also, what of tracks with a one-off intro? If the tail of the looped section is baked into the beginning then you get the tails of both the intro & the loop stacked on top of each other. Alternatively, if the entire track is 1 file with a "loop back point" to skip the intro on successive plays, then that similarly cuts the tail of the looped section. All in all it's a hassle and the results are not perfect nor flexible.

    My composer and I were both excited to utilize audio scheduling and not have to bother with all of that, and everything is already coded with track tags, files, segments, durations, etc. in a JSON file so we can basically structure and loop music tracks however we want, flawlessly and without "tricks". This even allows us to change up song structure on the fly e.g. dynamic boss music based on its remaining health! All we need is the limitation of two identical tracks playing simultaneously to be lifted, and we're golden! I implore you to give it some consideration.

  • So can't you do it by splitting it up in to 3 tracks: intro (clean), intro (with tail), and the rest of the main track? I don't think that's a hack, that seems a pretty reasonable way to do it.

    I'm not sure if you realise, but scheduled audio does not actually usually work with audio categorised as music. These tracks are normally backed by <audio> elements, which don't support sample-accurate playback - only Web Audio buffers do, which is how audio categorised as sound is played.

    On some platforms for various reasons like compatibility we actually ignore the audio categorisation and play everything as sound anyway (i.e. via Web Audio buffers). I've never seen or heard of any particular negative consequence of doing that, so I think it's fine to do that in your case too if you need sample-accurate playback of music tracks, and audio categorised as sound can be played with unlimited overlap.

  • Sounds like you could just make another copy of your loop and rename it then import into construct as a new file, so it will not look like an identical track ( It is, but construct doesn't know that if you rename it, does it? ).

    I just noticed you mention that at the end of your post. Anyway, doesn't seem like a big deal really unless files are huge and file size is of concern.

  • I'm not sure if you realise, but scheduled audio does not actually usually work with audio categorised as music. These tracks are normally backed by <audio> elements, which don't support sample-accurate playback - only Web Audio buffers do, which is how audio categorised as sound is played.

    On some platforms for various reasons like compatibility we actually ignore the audio categorisation and play everything as sound anyway (i.e. via Web Audio buffers). I've never seen or heard of any particular negative consequence of doing that, so I think it's fine to do that in your case too if you need sample-accurate playback of music tracks, and audio categorised as sound can be played with unlimited overlap.

    No I was not aware of this, and am now doubly confused. I thought the whole point of audio scheduling was to eliminate the potential 16ms+ "seam" between audio loops (which the built-in loop option is NOT immune to) as well as consistently repeating sounds like in the audio scheduling demo found in the start page. So then, how on earth are you supposed to seamlessly loop music outside of the method I've proposed above?

    As for workarounds, considering this particular game is strictly for desktop PC & consoles (chowdren) would it be okay to put my music tracks in the sound folder and play them as such? I considered this earlier but I thought it would instantly load every music track into memory instead of "streaming" on the fly, but perhaps that's some old web-based C2 logic I'm wrongly applying here?

  • It's still possible to get seamlessly looping music by mixing the tail in to the start, which is what I assumed most people were doing. Sample-accurate playback works well for things like fast regular sounds, like in the built-in example for audio scheduling, which is what I had in mind when designing it.

    As I said it should be fine to put music tracks in the sounds folder. They are only loaded on startup if you enable "Preload sounds", so you can just turn that off, and use the other memory management features of the Audio plugin to control what's loaded and when.

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