Problems/Suggestions : Click here and post in the forum or

Getting Started

Here's how to play your first audio with Introloop.


First you should license this plugin from Unity's Asset Store as usual. Folder Asset/Introloop will appear in your project's Root, along with Asset/Resources/Introloop/IntroloopPlayer.prefab in your Resources folder. I will call it a template prefab, and I will explain more later.

Audio file and boundaries

After you got the audio that you would like to play, we needed 2 time points. The first point is called "Intro Boundary" which is the point that separate the intro from the rest of this song, and "Looping Boundary" which is when the playhead arrive at this point it will go back to Intro Boundary. Ideally the audio bits after both boundary should sound exactly the same, so you have to be precise here.

If possible you should ask these point directly from your composer, since in the Digital Audio Workstation (DAW) there is a beat grid to snap to and it is a sure fire way to get the exact time!

Getting exact boundaries from DAW

What if I already have the music but cannot contact composer?

In this situation you can use free program like Audacity to find the Intro and Looping Boundary by yourself. Timing might be difficult since there is no snap, but zooming closely to the waveform you should see a meaningful transient that you can match. There is an article from Audacity team of how to make looping audio. If you follow the guide and successfully cut a looping part, you have already got 2 time points required for Introloop which is the begining and end point that you cut.

Using Audacity to get boundaries

So the music data after Looping Boundary is never heard?

Correct, but you should leave some tail after that boundary anyway (like 1 second) just in case an unexpected lag happen and for small compression artifact. Tell your composer to render a bit more after the planned Looping Boundary.

Making IntroloopAudio asset file from your audio file

Next please right click the audio file in Unity, you will notice a new entry Introloop > Create IntroloopAudio. Select it and a new asset file should appear alongside your original audio file.

Making IntroloopAudio file

This is called an IntroloopAudio file. You will use this file instead of original audio. (But don't remove the original audio file from project!) Notice that if you click it, there is a custom inspector displayed. The Audio Clip field is already connected for you to the file you right clicked, next you should input the Intro Boundary and Looping Boundary you got earlier in seconds. You can also set a default volume here which is convenience for balancing music level, since normally Unity cannot store volume information in the AudioClip directly.

Setting IntroloopAudio's values

There are 3 playback modes to choose from which you can set per audio. The Introloop is what this plugin good at, but Loop and Non looping is also provided to play music like Unity normally did with Loop checked and unchecked in AudioSource respectively. For these 2 modes the boundaries will be disregarded.

Playing IntroloopAudio with IntroloopPlayer

You can either declare public IntroloopAudio myIntroloopAudio; in your script to expose the variable and then drag the IntroloopAudio file to the slot, or place the file in Resources folder and dynamically load it via Resources.Load(string). (not recommended) Either way you will get an instance of type IntroloopAudio in your script. Next, there is a player that can play this IntroloopAudio called IntroloopPlayer.

It uses singleton pattern, so you can simply get it via static property IntroloopPlayer.Instance then you can call method like IntroloopPlayer.Instance.Play(myIntroloopAudio);. You should hear your audio now! Do the same with other audio files. The image below demonstrate a simple class that can choose to play one of many IntroloopAudio that I have.

Scripting Introloop example

Wait, where did the audio came from!?

The first time reference to the IntroloopPlayer.Instance will create a set of GameObject named IntroloopPlayer on your scene which will then persist throughout your game. It is made from 4 AudioSource with additional complex scripts to juggle your audio and achieve the function that this plugin should do but you should not have to worry about the inside.

Introloop in hierarchy

This IntroloopPlayer game object is being cloned from Assets/Resources/Introloop/IntroloopPlayer.prefab which I call it the template prefab. (It is installed at the same time along with the plugin) I prefer this way rather than creating anew since this provide a way to set the default audio mixer routing.

Routing audio to your own AudioMixerGroup and other settings

As explained earlier you should drag your audio mixer group to the template prefab in Assets/Resources/Introloop/IntroloopPlayer.prefab and the first time IntroloopPlayer.Instance was called the settings you did will be copied along.

Introloop mixer routing

On that template prefab you can find other settings such as default fade length, used when calling method with the word Fade without fadeLengthSeconds argument and even an option to turn on logging.

Pay attention to your AudioClip import settings!

I recommended you to uncheck Preload Audio Data for all audio you planned to use with Introloop. Since if checked, merely having reference to IntroloopAudio in any GameObject's inspector slot will cause the audio to be loaded into memory at scene start even if you are not going to play it yet. (The same happen if you connect a vanilla AudioClip to the slot with Preload Audio Data checked)

Recommended audio import settings