Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Does Unity support synchronised tracks and looping to a point other than the start of a track?

Discussion in 'Audio & Video' started by TofaPT, Mar 5, 2015.

  1. TofaPT

    TofaPT

    Joined:
    Mar 5, 2015
    Posts:
    7
    Just been starting to look at Unity Audio and am after some advice (I did scan the manual first, but may have missed this...). I'm thinking about two audio features, but am not clear if Unity 5 supports these as-is or whether it would require some asset store extension (e.g. Master Audio I hear is good?).

    Features are:
    1. Playing several audio tracks at the same time synchronously (e.g. each track would be a different set of instruments, and you would fade between them at certain points in the game)
    2. Having the audio tracks from #1 above loop - but with an initial intro. (e.g. rather than looping back to the start, it would loop to a point a short distance into the track)
    Can anyone advise as to:
    A) Are these features supported in Unity 5?
    B) If not, are there any asset store extensions that would be recommended to handle these?
     
  2. InsomniaLab

    InsomniaLab

    Joined:
    May 14, 2014
    Posts:
    3
    Don't know about Unity 5, but you can do both in Unity 4.

    #1 is pretty easy and works pretty much as is.

    #2 required lots of custom coding. It's moderately easy to do for PC releases, but to get this to work gaplessly on mobile required a hell of a lot of work due to the forced use of mp3 compression.

    I've avoided switching to Unity 5 so far since it introduced some nasty audio artifacts on all of my audio, with no apparent workaround. A lot of Unity 5's new audio handling seems undocumented at this point, which is a huge drag.
     
  3. Nifflas

    Nifflas

    Joined:
    Jun 13, 2013
    Posts:
    119
    #1 Can be accomplished through PlayScheduled or just making sure Play is triggered the same frame for each AudioSource (I can not verify this since I haven't tried it myself, but I've been told Play has been updated to sync perfectly with all other Plays during the same frame. If this turns out to be wrong, use PlayScheduled). As for #2, If you're willing to break the intro and looped parts into separate AudioClips, what you want can be accomplished with sample accuracy using PlayScheduled. Just schedule the intro on a given DSP time, then schedule the loopable part at that DSP time plus the length of the intro.

    Note that I don't develop for mobile and have no insight there. Also, G-Audio is worth looking into if you want to do more advanced audio in Unity, but it requires at least intermediate programming skills.
     
    Last edited: Mar 6, 2015
  4. TofaPT

    TofaPT

    Joined:
    Mar 5, 2015
    Posts:
    7
    Thanks for this information, this is really helpful! I'll also take a look at G-Audio as well as Master Audio.
     
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    You hear Master Audio is good? We try our best :)

    Neither feature you want is available out of the box with Unity 5. The synchronized song part is totally doable with no scripting and using our plugin. The other partial loop we don't have yet, but it is on our roadmap to add soon. However, if you split the song into 2 clips (intro and loop portion), you can set up a Playlist with gapless transition to do that. Again no coding is required.
     
  6. Nifflas

    Nifflas

    Joined:
    Jun 13, 2013
    Posts:
    119
    Ah, never considered Master Audio. From what I can gather, Master Audio simplifies the workflow for a lot for people who want to focus on sound and not programming. It's probably really great, but not for my needs. G-Audio is on the other hand meant to be low-level-ish, and is harder to use than just the general Unity audio features, but it is very powerful and extendable. As always, pick whatever is right for you!
     
    Last edited: Mar 8, 2015
  7. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    G-Audio can do some pretty advanced stuff that Master Audio cannot. And vice versa. Mostly our product does as much as possible without writing any code, including quite a few things that would normally be thought of as "requiring coding". But there's still a large API for doing other things as well.

    Good idea to check out both!