Search Unity

Audio Defining Loop Points

Discussion in 'Audio & Video' started by tobiasforsberg_4, May 10, 2019.

  1. tobiasforsberg_4

    tobiasforsberg_4

    Joined:
    May 10, 2019
    Posts:
    2
    I've been looking around YouTube, google and the Unity manual for info about how to define loop points for audio clips that Unity recognises but came up with only really old posts that are no longer relevant.


    Can anyone enlighten me when it comes to making audio files with defined loop points that will work with Unity?
     
  2. tobiasforsberg_4

    tobiasforsberg_4

    Joined:
    May 10, 2019
    Posts:
    2
    Does nobody know?
     
  3. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    140
    How you use it depends on exactly what you want to do, but, your best bet is probably going to be using PlayScheduled and SetScheduledEndTime and AudioSource.TimeSamples to alter when clips start, stop etc.

    Between these functions you'll be able to change a loop point or loop an entirely different section. I don't believe there's a way to create a loop point that Unity just recognises, instead you'll need to queue up clips sequentially, and edit the start/end times, to get the effect you want.

    I wrote a huge article on how to queue up audio clips precisely, which you can try here: https://johnleonardfrench.com/articles/ultimate-guide-to-playscheduled-in-unity/

    Or if you don't mind explaining exactly what you want to happen I can probably suggest a way for you to do it.
     
  4. Snowy_Fox

    Snowy_Fox

    Joined:
    Sep 10, 2017
    Posts:
    4
    I've always wondered this myself. As a composer, I'd love to be able to make it as easy as possible for people to integrate my music into their games, with the result intended during composition. I come from the RPG Maker community, and the various RPG Maker engines make it incredibly easy to loop streaming OGG files with simple LOOPSTART and LOOPLENGTH comments included in the files' metadata.

    If there were a way of making Unity recognise these loop comments, or a similarly embedded equivalent, that would make it so much more straightforward, both for composers and for end users. I have had users of my music ask about its compatibility with Unity, but I am admittedly new to the engine, and the best answer I've been able to come up with so far is simply to use the versions of my tracks that are edited to loop from start to finish, with no intro or any kind of interactivity.
     
    KOF11 likes this.
  5. kingkdawg

    kingkdawg

    Joined:
    Jun 12, 2016
    Posts:
    5
    I'm currently writing a system for this but not being able to play with the audio thread very much is making it difficult, my only gateway in so far has been using OnAudioFilterRead, but even with that I get chops occasionally when a track loops