Layered Interactive Music (demo)

Show us your completed creations made in Construct 2

Post » Mon Oct 07, 2013 5:20 am

Try it!

Layered Interactive Music (demo)

No plugins, uses Web Audio API for looping.


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.

C-72013-10-07 06:32:01
B
103
S
38
G
19
Posts: 962
Reputation: 17,986

Post » Mon Oct 07, 2013 6:11 am

Error 404 - File or directory not found.

Could you please upload the .capx again.
B
14
S
5
G
4
Posts: 107
Reputation: 4,788

Post » Mon Oct 07, 2013 6:32 am

@trollface

It works now. I forgot to include http://C-72013-10-07 06:32:50
B
103
S
38
G
19
Posts: 962
Reputation: 17,986

Post » Wed Oct 09, 2013 5:35 am

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.

B
103
S
38
G
19
Posts: 962
Reputation: 17,986

Post » Wed Mar 12, 2014 3:45 am

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
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Wed Mar 12, 2014 6:41 am

jobel wrote: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.
B
103
S
38
G
19
Posts: 962
Reputation: 17,986

Post » Wed Mar 12, 2014 4:03 pm

C-7 wrote: 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
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Thu Mar 13, 2014 12:42 am

@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.
B
103
S
38
G
19
Posts: 962
Reputation: 17,986

Post » Thu Mar 13, 2014 3:40 am

@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!
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Wed Nov 26, 2014 6:52 pm

C-7 wrote: 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.
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Next

Return to Completed Creations

Who is online

Users browsing this forum: No registered users and 2 guests