Layered Interactive Music (demo)

  • <font face="Arial, Helvetica, sans-serif"><center><font size="5">Try it!

    Layered Interactive Music (demo)</font>

    No plugins, uses Web Audio API for looping.</center>

    This brief demo demonstrates interactive music through layering/versioning, and the changes are made through in-game triggers. It can be applied in nearly any setting, though it does have best results when using a browser that supports the Web Audio API (for seamless looping). This demo incorporates five different version of a track, syncs them, and dynamically brings different tracks to the forefront. It is triggered by simple zones which the player may walk through. There is also a DANGER button in the corner that triggers a darker, more intense audio track. It is all done with no third-party plugins in Scirra Construct 2 and can be controlled via Touch, Mouse, WASD, or Arrow Keys.

    I've uploaded a commented CAPX with the audio files included so you can see how I have it all set up. It is a very easy-to-implement system and can really make a big difference to a lot of games.

    </font>

  • Error 404 - File or directory not found.

    Could you please upload the .capx again.

  • trollface

    It works now. I forgot to include http://

  • I did a minor update to both the demo and the capx to reflect smoother transitions. The increase in audio uses lerp now instead of just standard gain to even out the sound levels between the new and old tracks.

  • hi, I tried something similar and my audio files eventually went out of sync. I tried your capx, but couldn't really tell if you are having that problem. It seems like a limitation in the audio library or a bug, I'm not sure which.

    http://www.scirra.com/forum/audio-syncing-a-limitation-or-bug_t98383

  • hi, I tried something similar and my audio files eventually went out of sync. I tried your capx, but couldn't really tell if you are having that problem. It seems like a limitation in the audio library or a bug, I'm not sure which.

    http://www.scirra.com/forum/audio-syncing-a-limitation-or-bug_t98383

    I think I did it in this demo, but I do it in my later stuff for sure. Whenever a transition starts, I manually re-sync the audio just in case. Most audio engines would have a similar problem, so I just accounted for it from the start. So just occasionally set the playback position of the other tracks to whichever one you consider to be the 'master' version.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So just occasionally set the playback position of the other tracks to whichever one you consider to be the 'master' version.

    oh should I be using more than 1 audio object? I don't think C2 will let me do that..

    how do you set: Seek "tag" to Mastertrack's position? As far as I can tell I can't reference another tracks position. Unless I keep track of it manually, but I wouldn't trust the preciseness of that.

    just to be clear, my music always loops and is always playing, even if muted -- in order for them to stay sync'd. But somehow in the loop they lose sync. If I were to adjust the times of the other 3 tracks while they are playing, it would have to be done in the right place (and within 10-20ms) otherwise you'd hear it.

    Not to compare C2 with Unity, but I tried this same thing in Unity and it doesn't have this problem. So I know it's not my audio files.

    https://dl.dropboxusercontent.com/u/362 ... uilds.html

  • jobel Yes, you can reference the playback position. I really like to re-sync tracks when they've got silent/quiet to ensure no one hears a blip and then I just re-sync by a comparison (if one track is greater than 5ms in either way away from the master track, seek to it). You can reference it with Audio.PlaybackTime(Tag)

    So Seek to Audio.PlaybackTime("main")

    PlaybackTime is the current playback time in seconds of a sound with a tag. This starts at 0 and counts up to the duration, except for looping sounds which keep counting up past the duration.

  • C-7 I did some testing and it turns out the browsers are to blame for this..

    IE11 keeps the audio completely in sync. I let my 4 track, 30 second song loop for 30 minutes and it was perfectly in sync. The downside is that IE11 doesn't do a great job with loops and you can hear a small "pop" at the loop points.. it's not horrible, but it's definitely not seamless to my ears.

    Chrome33 (which is what I normally use) loops great but somehow allows the tracks to become out of sync.

    Firefox27 has both terrible looping and at the same time allows the tracks to go out of sync.

    So, pick your poison I guess!! I put a ticket into Google about this, so maybe a future Chrome release will fix it. But in the mean time I will look into your work around. Thanks!

  • I really like to re-sync tracks when they've got silent/quiet to ensure no one hears a blip and then I just re-sync by a comparison (if one track is greater than 5ms in either way away from the master track, seek to it).

    Have you done this with tracks that were playing? I'd imagine the player would hear something so it's better to do while they are silent.

    perhaps you can always resync without any checks? since it takes Chrome about 3 loop iterations to go out of sync, you could just always resync after the loop? the problem would be if you heard it.

  • Beautiful. Nice graphics too.

  • Thanks!

    @jobel ideally you would only sync silent tracks (in my own game, I do it immediately prior to a track fading in), but if the tracks get to far out of sync when audible, the player would hear something anyways.

    The best way I've found around this is to do a bunch if small clips (usually measures or passages) cued with a timer. I do this method most often now, but the fading once is so both viable and interesting.

  • The best way I've found around this is to do a bunch if small clips (usually measures or passages) cued with a timer.

    that's interesting, and do you cue these passages or measures together in a playlist so they play after one another? I'm actually experimenting with this for another reason entirely.

  • > The best way I've found around this is to do a bunch if small clips (usually measures or passages) cued with a timer.

    >

    that's interesting, and do you cue these passages or measures together in a playlist so they play after one another? I'm actually experimenting with this for another reason entirely.

    More or less, yeah. Don't worry about trying to play them at the end of the last audio clip--that would never work and would sound bad. Instead, export each measure or whatever you're using individually but don't cut off the decay at the end of the audio. In other words, let the last note or whatever you have ring out. Then start each new clip accurately time-wise while the other one's decay continues through like it would in real life and you have seamless, cued music. You can interject at any point and change which measure comes next. At the very least, I randomize the order of segments so that the music isn't as repetitive. But you can also have the music move to different sections at those break points to fit the mood or location of the player while preserving the flow of the music (ie, don't cut off crap or start things in nonsensical places). I like using transitional measures for this or simultaneously playing something like a suspended cymbal roll placed at a division of the measure to sell the transition even further.

  • Don't worry about trying to play them at the end of the last audio clip--that would never work and would sound bad. Instead, export each measure or whatever you're using individually but don't cut off the decay at the end of the audio.

    ahh yes, like in RMX or REX beat slices and let them overlap. Very cool idea.. so you just have to do the math to figure out the timing of when to trigger them... (song_bpm / 60) * 4 (beats per measure). And if you are syncing them with a "master track" like you mentioned previously you'd figure out multiples of Audio.PlaybackTime("master").

    if you cut up music into small enough sections (not too small) then you'd probably never have to re-sync right? Since the timer would keep everything together and the music wouldn't be technically "looping" because you'd be doing that manually...

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