Seamless Transition Between Audio Files

0 favourites
From the Asset Store
Excel2JSON
$1.20 USD
60% off
Convert multiple Excel files into JSON files and import them into construct3.
  • Hey all! So I've created a small "music maker" that lets you combine loops to create a song, but the transition isn't fluid. Sometimes it goes to the next file too fast, other times there's a small break between loops.

    Here's the program/game: http://www.newgrounds.com/portal/view/670185

    This is what I used for making the song move forward. I had a blank audio file that's the same size as the other audio files to gauge when to move forward:

    Any help is appreciated. Thanks!

  • Lost cause, eh? Darn.

  • There might be a solution where I play all of the audio files looping and muted, but I unmute the tracks that are meant to actually be playing. This would take up a lot of events, so I'm wondering if there's an easier way?

  • Bump. Guyyyys, I'm really at a loss here.

  • Bump. Pls ;-;

  • I have no experience with timing of sounds so this is all a complete guesswork, but did you do the timing with the overlapping the pattern with your seekbar? I wouldn't do something what needs a exact timing with a collision or overlapping event.

    I would put the pattern in an array and use the array to play the sounds in the correct order.

  • I have no experience with timing of sounds so this is all a complete guesswork, but did you do the timing with the overlapping the pattern with your seekbar? I wouldn't do something what needs a exact timing with a collision or overlapping event.

    I would put the pattern in an array and use the array to play the sounds in the correct order.

    Sorry for the late reply; this week's been nuts. I'll definitely try that! I'm not a big fan of arrays, but today's a good day to learn

  • I have no experience with timing of sounds so this is all a complete guesswork, but did you do the timing with the overlapping the pattern with your seekbar? I wouldn't do something what needs a exact timing with a collision or overlapping event.

    I would put the pattern in an array and use the array to play the sounds in the correct order.

    Okay, so the overlapping isn't the problem. I tried using a function that loops itself every 6.621 seconds (the EXACT timing of all of the loops), but there's still a timing issue. This is what the function looked like

    And since I'm getting desperate, here's the capx: https://www.mediafire.com/?nrdsqhvdd45b0mg Please don't use it for anything more than helping me :X

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay, I do this type of transition work in my game currently and it works great. Admittedly, I saw this post really late at night and I really need to go to sleep. Tomorrow I'll screenshot some of my events and show you a little of how it's done, but a few hints until then:

    Do not use Wait or any other system thing for timing. This will more times than not be at least a tiny bit off from the actual audio files in use and, as I'm sure you've noticed, tiny differences make for a big problem with audio. Instead, you should use Audio.PlaybackTime(Tag) for everything. Then, you can use Audio>Seek to for lining up your tracks. Remember, though, if you're looping a track, the PlaybackTime will keep going past the looppoint (ie, it'll count past the end of the audio file) so you'll also need to seek your guide track back to 0. Lastly, you need to recognize that the events aren't going to be absolutely accurate, but you should use correct values. So if your loops is 6.345 seconds, you should run your events when PlaybackTime is > or = to 6.345.

    And, lastly, if someone sees this and is curious about how to find the most accurate timing for stuff, here's a good formula for it. If your measures are at a strict tempo, it's BeatsPerMinute/60*BeatsPerMeasure. So 144/60*4 would be 144 bpm in 4/4 time. Then, you can multiply that number by however many measures are in your track to get the loop length.

    So when I get a chance tomorrow, I'll walk you through a bit more of this in greater detail with screenshots (and probably an example).

  • Instead, you should use Audio.PlaybackTime(Tag) for everything.

    Oh man, how did I never think of that?

    Fixed my capx to include that, but something's not registering with the event. If I do if Audio.PlaybackTime("blank") >= 6.62 (in debug, the time is rounded to 6.62), it'll stop on the first bar and not play any of the other ones.

    I set it to 6.6, which almost does the trick, but it's still iffy. Also, sometimes in the debug I'll pause it and the times for a few of the tracks aren't the same as the rest (off by like 0.01 or 0.02, but noticeable).

    Updated capx: https://www.mediafire.com/?qy02hu2y52x2b3n

  • For me, I typically just have each of my tracks "complete" instead of piecing layers together--so I switch between fully mixed versions. The only difference is at times adding maybe one element like a melody over top. A couple of those earlier events refer to the adaptive music parts that I use, so ignore those, but that's the gist of how I do it all. The business with arrays is all for my own convenience and re-use of events, so you don't have to worry about that.

    Despite the tracks being set to loop, I still re-seek them to the beginning to reset the playback time (otherwise it keeps going up). And, with how I have it set up, I just call a simple function in-game and this code will take care of it all. The adaptive stuff is much more complex, but I can still control it all with one simple function call. So once the initial setup is done, be sure to make it easy for yourself to control it all!

  • It looks like the new update makes this all even better!

    yeah but Chrome and Firefox still won't sync tracks without manually aligning them... and when you manually align them after each loop it creates artifacts.. so still no seamless transitions with multitracks...

    like in my example from 2 years ago... (you have to let it loop 5-6 times then you hear it go way out)

  • > It looks like the new update makes this all even better!

    >

    yeah but Chrome and Firefox still won't sync tracks without manually aligning them... and when you manually align them after each loop it creates artifacts.. so still no seamless transitions with multitracks...

    like in my example from 2 years ago... (you have to let it loop 5-6 times then you hear it go way out)

    That was a quick and dirty example, but the trick would be to align the track while it's silent just before you fade it in. If you're only trying to have one or two tracks actually fully audible at a time, this should be no problem. The problem would come from trying to continuously line up a whole bunch of tracks simultaneously while they're playing. I didn't put in the check in the screenshot I posted above, but right before you fade a track in, sync it to what is currently playing. Then it will fade in correctly and you have no reason that de-syncing would even be audible.

    Your idea of a silent 'guide' track is actually a really good idea and a great way to make this all work perfectly.

  • but right before you fade a track in, sync it to what is currently playing. Then it will fade in correctly and you have no reason that de-syncing would even be audible.

    this gets tricky if you use "stems" though.. I think you mentioned you were using full mixes. I'm talking about making 1 piece of music 2 minutes long and I break it out into 4 tracks that need to be played simultaneously. So "virtual remixing" basically.. Once you have more than 1 track playing you can't re-seek those without causing audio junk that you will hear.

    I just assumed this was beyond the scope of what C2 can handle. It would be tricky enough to code it without these sync issues.. with sync issues it's not really worth the effort unless your game is dependent on the music.

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