InAudio 2 - New & Open Source

Hi there, I would like to tell you a bit about InAudio and why its now open source. Well, it’s open source because I got a job in an AAA game company and now I want to to make it available to as many people as possible and on all platforms. So why waste your money on another solution? And this does not mean that developed is dead, don’t worry!

What is InAudio? It’s in my opinion, a powerful tool to add great audio to your game. It has dedicated tools for playing music, sound effects and an event system. All audio design and events are created code-free with an extensive API to control the playback, including an event hook for common things like enabling and collisions.

Grab it now on the Asset Store or Github for free!

With the release of the new audio system in Unity 5, InAudio got a lot better. It now has a brand new music player that supports layered music, easy crossfading and it is always gap-free. Alongside this is a deep AudioMixer intergration, and a total rewrite of the audio clip loading to take advantage of the new Unity 5 loading system. Did I mention it is fast? Even on mobile, your hardware will give up long before InAudio is even breaking a sweat.

For sound effects, you can easily combine, sequence, (weighted) randomize and loop your audio clips, all gap-free of course. For your variation needs, volume, pitch, looping and delay can all be fully randomized for every single clip if you so desire.

Using InAudio is on the design front always code-free with an extensive API to control the playback during runtime. If also has an event hook for your daily needs with hooks for enabling/disabling and collisions among others.

I really hope you will find this new and free version of InAudio useful and please let me know below or on email about any thoughts, comments or feature requests.

Asset Store | Documentation | Support email: inaudio@outlook.com | Github

Core features:
:: Music player, layered & sample-accurate.
:: Deep Audio Mixer integration.
:: Lots of randomization options.
:: Always sample accurate audio.
:: Event hooks for code free implementation.
:: Instance limiting.
:: Audio splines for volumetric audio.
:: High-performance with hundreds of audio sources even on mobile.
:: Scene independent, no scene clutter.
:: Easily handle 100+ audio sources on mobile.
:: Memory handling via Unity 5 clip loading.
:: Preview audio right from the editor.
:: Code-free memory management.
:: Minimal allocations.



1 Like

Changelog

InAudio 2
-Remastered for Unity 5
-Completely new Music system
-Highly improved audio clip loading
-Event Actions for music with playback and volume control
-Improved GUI

For a full history, please check the full changelog.

Hm, just so you know, your video is repeating about a minute or so of content at around the 4:30 mark.

  • Josh

Thank you for pointing that out. Will fix it swiftly.

This asset seems interesting. How does it compare with the much more expensive Master Audio?

[Well, now its open source]

Quite well I would say. I have sent you a copy of the newest version of InAudio to use in any of your project(s). If you need support and/or newer versions, please consider buying it.

Hi everyone, I just released a major upgrade to InAudio and released it open source!
Please check it out!

Awesome asset. The audio mixers work well using Music, but not when using audio via the Audio Window. I have it set on the parent folder of the audio nodes I’m using, but it just won’t route through the mixer. :frowning:

Any idea?

Edit:

I fixed it by modifying InPlayer.cs. In PlayNode, I have it searching parents for the mixergroup to use. I’m not sure if this is right, since it might be better to be setting it somewhere rather than walking up the chain.

InAudioNode currentNode = current;
AudioMixerGroup mixerGroup = current.MixerGroup;
while (mixerGroup == null)
{
        currentNode = currentNode._parent;
                if (currentNode != null)
                {

                    mixerGroup = currentNode.MixerGroup;
                }
                else
                {
                    break;
                }

   }

   Current.AudioSource.outputAudioMixerGroup = mixerGroup;

Very cool, thanks for making this free!

Do you know if it will compile to universal windows store apps?

Hi sballew7, thanks for finding the bug. Your solution is correct, I have sent you a new version of InAudio with this bug fixed alongside another small other one I found while looking into this. You can simply import it onto your current project and you won’t loose your InAudio project data.

It does! In the version on the asset store right now, you will have to change a single line 354 in InPlayer.cs to

get { return new ReadOnlyCollection<InRuntimePlayer>(audioSources); }

As with sballew7, I have send you a new version with this bug fixed.

Hey InnerSystems,

I encountered another bug that I hopefully have found a fix for.

Here are some reproduction steps, followed by the solution I put in place.

  1. Play a music group using InAudio.Music.PlayWithFadeIn(someMusicGroup, 1f);
  2. After fading is done, fade the music out. InAudio.Music.FadeAndStop(someMusicGroup, duration);
  3. After fading is done, fade the music back in. InAudio.Music.PlayWithFadeIn(someMusicGroup, 1f);
  4. When the music finishes fading in, it will stop playing.

In step #2, starting a fade out will set toFade.PlayingInfo.DoAtEnd = MusicState.Stopped.
Unfortunately, this remains on the music group. When fading back in, this property is still set, and the music will stop playing as soon as it fades in.

I have done two different solutions. I am not sure which is better, and I could use some guidance.

One was to add the following line at the end of each FadeIn method:

musicGroup.PlayingInfo.DoAtEnd = MusicState.Nothing;

My worry is that there are too many places where this needs to be done (probably any time music is to be played), and I know I missed some areas.

My second solution was to try fixing it in a single location. I modified the MusicVolumeUpdater’s section that handles fade completion. Upon completion, it sets the DoAtEnd to MusicState.Nothing. This ran into an issue with too many threads and made Unity crash, so I obviously missed something. (EDIT: The thread crash seems to be unrelated, so I’m trying to get to the bottom of it myself.)

if (playingInfo.Fading)
                {
                    float currentTime = Time.time;
                    if (currentTime >= playingInfo.EndTime)
                    {
                        group.runtimeVolume = playingInfo.TargetVolume;
                        playingInfo.Fading = false;
                        if (playingInfo.DoAtEnd == MusicState.Stopped)
                        {
                            InAudio.Music.Stop(group);
                        }
                        else if (playingInfo.DoAtEnd == MusicState.Paused)
                        {
                            InAudio.Music.Pause(group);
                        }
                        playingInfo.DoAtEnd = MusicState.Nothing; // <--- NEW LINE: The music state switches to nothing after fading is done.
                    }
                    else
                    {
                        var duration = playingInfo.EndTime - playingInfo.StartTime;
                        var left = playingInfo.EndTime - currentTime;
                        group.runtimeVolume = AudioTween.DirectTween(playingInfo.TweenType, playingInfo.StartVolume, playingInfo.TargetVolume, 1 - left / duration);
                    }
                }

I finally got to the bottom of the “too many threads” error. I thought it was unrelated, but I have finally pinpointed it to when I upgraded to the latest InAudio. Perhaps I missed some upgrade steps? A thread dump of Unity shows a TON of threads being created when using the latest InAudio version. It only happens in the editor while in play mode. This was tried on Unity 5.0.1 and 5.0.2.

I have reverted back to my previous version and the thread issue is resolved. I also patched it by using a third solution, which was to modify the MusicPlayer’s PlayMusicGroup method. It looks like all Play methods end up here, so it seemed like a good central place.

private static void PlayMusicGroup(InMusicGroup toPlay, double playTime)
        {
            var musicPool = InAudioInstanceFinder.InMusicPlayerPool;
            var mixer = toPlay.GetUsedMixerGroup();

            var editorClips = toPlay._clips;
            int clipCount = editorClips.Count;
            for (int j = 0; j < clipCount; j++)
            {
                var playingInfo = toPlay.PlayingInfo;
                playingInfo.State = MusicState.Playing;
                playingInfo.DoAtEnd = MusicState.Nothing; // <---- NEW LINE: Set end state to nothing.
                var player = musicPool.GetObject();
                toPlay.PlayingInfo.Players.Add(player);
                player.clip = editorClips[j];
                player.loop = toPlay._loop;
                player.outputAudioMixerGroup = mixer;
                player.PlayScheduled(playTime);
            }


            for (int i = 0; i < toPlay._children.Count; i++)
            {
                PlayMusicGroup(toPlay._children[i] as InMusicGroup, playTime);
            }
        }

That is a very odd problem, which I haven’t seen while testing it. I’m gonna investigate this issue and report back.

Using Process Explorer, the threads look to be created and destroyed rapidly. But they are created faster than they are destroyed.

The threads look to be called:
Behaviour::Transfer

First of all, thank you very much for the bug fix. I have submitted a new version with this included.
However, I cannot reproduce your issue. Looking at Unity’s thread count, it only fluctuates with 1-2.
InAudio does not directly spawn any threads, so the additional ones must be a weird coincidence.
If it keeps not working, please write a message to me with more detail so we solve this problem.

Thanks for looking at it. When I get time, likely next week, I will attempt the upgrade again and report back.

Very Nice work InnerSystems!

I’m currently doing a deep evaluation of all Interactive Music solutions in Unity prior to starting a couple of projects and almost overlooked this. Glad I checked it out!

What’s the quickest way to change the selected element color in the editor?
The current dark blue makes it really hard to read.

What’s the best strategy for using layers in an interactive music composition when you might need to control track dynamics by turning layers on and off?

Right now it would probably be best to simply change the volume of the tracks that you shouldn’t hear.
You though also use PlayAtSkipSamples() to play at the at correct time and skip any samples so it matches up. I am currently working on a better solution utilizing something like PlayAtBeat() or something like that. I don’t have an ETA though.

For the color, change the texture SelectedBackground in InAudio/Icons. I may find a better way to set the color at some point.

Hey guys! Do you know if InAudio works correctly on Unity 5.1.1f1 and supports WebGL builds?
I’ve been using “Fabric”, but to my surprise when I want to build for WebGL, lots of .dll errors appear.
It works correctly on Unity Editor but fails to build.

Just want to know if using InAudio will avoid this problem

Thanks!