shredd
New Member
Posts: 5
Posts: 5
|
Post by shredd on Sept 14, 2015 13:00:07 GMT
My goal is to setup a system where background music for a level consists of two parts: an intro that plays only once, and a main loop which repeats thereafter. What's the best way to do this? Has anyone tried creating this kind of a system? It's a simple thing, but the obvious solution of putting both files into a single playlist has a little problem (which I discussed with a MasterAudio dev in this thread: darktonic.freeforums.net/thread/300/changing-clips-playlist-causes-skips and was further analyzed code-wise here: forum.unity3d.com/threads/why-is-the-calculation-of-end-time-for-an-audio-clip-always-slightly-different-every-frame.354579/) I'm not a programmer and my understanding of the technicality behind this is limited, but basically the two files do not connect seamlessly, due to calculations being done in a certain way. The main loop file starts up too early or too late, by just a few frames, and it's enough to mess up the beat or cause a silent gap. Crossfading can't be used because it won't fit the music itself in this case. Are there any other ways people have tried to create a music system like this?
|
|
|
Post by DarkTonic Dev on Sept 15, 2015 0:41:33 GMT
In my testing it sounded correct about 2/3 of the time, but yeah it's either late or early the rest of the time. At this time, there's nothing that can be done to fix it. Not sure if others who ran into this ended up using very short crossfading or what...
|
|
editkid
New Member
Posts: 8
Posts: 8
|
Post by editkid on Jan 19, 2016 22:34:26 GMT
I'm trying to solve this exact problem. Going seamlessly from an intro into a looping main body of a song.
Any solutions since the last post?
|
|
|
Post by DarkTonic Dev on Jan 19, 2016 23:00:54 GMT
There's an item on the roadmap to try and address this, but there's a couple other things in front of it.
|
|
editkid
New Member
Posts: 8
Posts: 8
|
Post by editkid on Jan 20, 2016 20:12:50 GMT
Right-o. I will await patiently. Thanks!
|
|
|
Post by DarkTonic Dev on Jan 20, 2016 20:33:32 GMT
Thank you.
|
|
|
Post by boygorge on Mar 2, 2016 10:40:51 GMT
I've successfully used a playlist xfade kludge to smoothly & in-sync switch between intro & loop portions.
Here you lock down the xfade length and then prep the intro portion accordingly. This you do by leaving a tail section from the loop portion, over which the xfade will occur. Mark where the intro ends and from that point trim the tail portion to match exactly the length of your xfade. When Master Audio fires the xfade, a somewhat synced transition between the intro & loop should occur. Put the two in a single playlist, and enable looping for the loop portion.
You might get a bit of phasing depending mostly on the length of xfade, the longer the more apparent. Also higher tempo & more transient content affects to some extent. Best option of course is to compose the intro portion to allow for the desired xfade length, eg. by sustaining a root note past the end of intro over which the loop portion can xfade in.
Where this hasn't worked for me is if you try to loop the same clip a specified amount of times by adding multiple entries of it inside a playlist. That just results in a "Error executing result (An invalid seek position was passed to this function.)" message in console. I'd sure like to see this addressed as it would be super handy to be able to use playlists to build longer songs out of shorter looping segments (eg. <40s).
|
|
|
Post by DarkTonic Dev on Mar 2, 2016 20:31:27 GMT
Please send us a project that reproduces that error boygeorge, and we will look and see if it's possible to fix.
|
|
|
Post by voodoodetective on Jan 8, 2021 9:29:33 GMT
I'm considering buying this Master Audio and this is one of my most important use cases. I was just wondering if there's a facility built in for this, I saw mention of something on the roadmap, or if I'd need to figure this out myself.
|
|
|
Post by DarkTonic Dev on Jan 8, 2021 16:52:37 GMT
We're not going to get to that any time soon. The zero latency feature for Android is far more important and that will take some serious time.
|
|
|
Post by voodoodetective on Jan 8, 2021 20:20:23 GMT
Gotcha, that's very good to know. So in the meantime, I need to be able to: - Crossfade between position in playlist
- Get current position in playlist
I think I can use:
PlaylistController.ActiveAudioSource to get the current track position. But I'm not sure if there's a way to crossfade between positions. Can you point me in the right direction?
|
|
|
Post by DarkTonic Dev on Jan 8, 2021 21:02:42 GMT
I don't understand your question. What is "crossfade between positions"? Yes you can use that property for current position.
|
|
|
Post by voodoodetective on Jan 9, 2021 1:15:48 GMT
I mean I'd like to be able to crossfade between positions in a track. I think it's called "seeking." Something like: SeekWithCrossfade(float trackTime, float crossfadeDuration);
Does that make sense? Maybe it's hard to articulate the idea. It's something winamp did back in the day. I think I can cobble something together if I duplicate playlist songs and then crossfade between them. But maybe there's a better way. Just let me know if I need to explain that better.
|
|
|
Post by DarkTonic Dev on Jan 9, 2021 1:48:44 GMT
There's no support for this. I don't think you'd even be able to add code to do it.
|
|
|
Post by voodoodetective on Jan 9, 2021 5:36:55 GMT
Dang ok, I guess I'd have to use two audio sources to emulate that. Thanks for letting me know!
|
|