Loop to certain point in a music track

Discussion and feedback on Construct 2

Post » Wed Dec 11, 2013 4:41 am

A while back I made a thread about looping music tracks with intros that should only play once. The consensus was to use 2 different tracks and one of many ways to decide when one has finished and the other should start (taking the tag which I need to use elsewhere..) I'm pretty sure I tried them all and ended up with a slight pause or gap in-between the two every time.

That said, is it possible to add an extra parameter to the "play audio" dialog that tells the music track what time to loop back to? Even if it can be done with 2 tracks, this would be much easier.

While we're on the subject, is it possible to allow additional tags like the function parameters?MadFactory2013-12-11 05:28:02
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Wed Dec 11, 2013 4:50 am

+1, this would be really awesome to have. Even back in the Megaman days on NES, they had short little unique intros before the whole track played and would just continue to loop from there. It was subtle, sure, but it made a hell of a difference and set MM's BGM apart from the rest.Infinitys End2013-12-11 04:50:24
B
13
S
1
G
1
Posts: 16
Reputation: 1,566

Post » Wed Dec 11, 2013 4:59 am

Yes. There is an Audio property for playback time. You can reference it with Audio.PlaybackTime("Whatever") and then you can alter it with Audio > Seek To.

It's a little tough to make it perfect, though. There are a few ways I've gotten around it, though.

Firstly, you'll need to say if Audio.PlaybackTime("Whatever") is > or = to ~~~, Seek To ---. This is the quick and dirty and accounts for if it happens to be off by a millisecond or several when the processing tick goes by. You can also reference on track ended, but this is unreliable in my experience (it works, just introduces gaps).

You can also play the same track over itself once it ends by alternating tags. Ie if Audio.Audio.PlaybackTime("Whatever1") >= to ~~~, play with tag "Whatever2". And then alternate events. This way, you can retain the audio spill-over at the end of the measure without wrapping it to the start of the track (or the mid-point wherever you are going with it). It isn't an ideal solution, but it works.

Or you could do the whole things split up by measures on a timer and make it fully interactive...
B
103
S
38
G
19
Posts: 962
Reputation: 17,996


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 14 guests