Developers Club geek daily blog

4 years ago
Work on sound? one of principal directions in preparation of Unity 5.0. After it became clear, over what functions it is necessary to sweat, we have included sound in the list of priorities.
That everything was on ointment, we had to return back and place accents over those areas of sound which would be involved in Unity. That you could connect some good, qualitative sounds in the games, we needed to decide on codecs and to be convinced that such scheme will really work. I will try to paint all nuances in more detailed article, and so far I will tell you about our first sound addon to Unity 5.0, AudioMixer.

First step

If you use Unity, your sound cannot be bad. Or so-so. He is simply obliged to be the best! Because in addition to strong basis for work with it in the future, you have something else? new super function which proves that we are not spent on trifles and we do everything to arm you to the teeth in the war with sound.
In the subsequent releases we will improve more and more work areas with sound. Sometimes it will be minor changes, like elimination of bugs in the existing feature set which has already proved to be from the best party. Some will be become serious, such as opportunity to create tremendous interactive sounds with full immersion and to control all sound landscape entirely.

Why AudioMixer?

To answer this question quite simply? earlier this function was unavailable. In the past all sounds were lost on AudioSource where you could add different effects as Components, and then mix all game sounds in AudioListener and include them in sound landscape.
As solution we have selected AudioMixer and not to stick bad shot, we have decided to make more, and have aggregated set of functions which you can find in well-known the Digital Audio Workstation applications.

Sound categories

We mix favourite bits in the Unity 5.0 program

Any sound technician knows as far as it is convenient? to work with the sounds broken on categories instead of processing each sound separately. Opportunity to aggregate all sounds, in parallel working on parameters of audio effects in the context of game provides global control over all sound landscape. And it well is very important! Perhaps, it is the best way to create mood necessary to you and level of immersion in game. The good sound mix and suitable track will allow the player to experience full range of emotions, and to create such atmosphere of which the graphics is alone not capable.

Mix in Unity

It is also main objective of AudioMixer? with its help users can exercise control over set of all sounds in game. Thus, all sounds which are lost in scene, join in one, two, some AudioMixer? ov which break them on categories and already then edits.
We mix favourite bits in the Unity 5.0 program

In each AudioMixer you can create branched systems of categories which in our context AudioGroup are called. You before eyes will have selection of these AudioGroup and classical panel of mix as it is accepted in the musical and film industry.

DSP

We mix favourite bits in the Unity 5.0 programBut it not still all! Each AudioGroup may contain heap of different DSP of audio of effects which are activated one by one in process of passing of signal through AudioGroup.
It is already interesting, the truth? Now you not only can create the user schemes of trace and apply mix to separate categories. You can distribute any cool DSP of piece on all length of signal, add any effects and enjoy absolute power over sound landscape. Can even add the empty track to process only certain part of signal.
But what if to you not enough built-in effects of Unity? Earlier it was solved by means of return of script of OnAudioFilterRead and only that allowed to process directly independently audio samples at you in scripts. It is enough for unpretentious effects and development of your own filters. But for increase in immersion in game to you the truth can sometimes want to compile the necessary effects independently, after all? From now on you can register and such complex effects as convolution configuration echo or multiband EQ.

We mix favourite bits in the Unity 5.0 program

We hurry to please, now Unity supports the configured effects of DSP of plug-in. And it means that users can write own DSP, and can be even to use Asset Store to exchange super creative ideas with others. Before you the whole world of new opportunities, such as creation of the engine or management of other sound applications like Pure Data opens. These configured DSP plug-ins can request support saydcheyn and use the necessary information from any fragment of mix! Super!

One of interesting innovations during the work with set of effects in AudioGroup? it that you can use attenuation where you want. Can even finish signal to +20dB (we have worked and over it). Use the built-in VU measuring instrument in the check mode to look, the signal at the time of attenuation how exactly changes.
We mix favourite bits in the Unity 5.0 program

Together with nonlinear DSP, Sends/Receives and our new counter of Ducking (which I will in detail describe below in article), you receive the super powerful tool on control over audio signal through mix.

Change of the atmosphere in game

I already mentioned use of mixes of sound landscape for management of the atmosphere in game: you can add or clean new components of music or the sounds creating background. Or to play with mood of the mix. For example, to change the audio level on different segments or if it is about work on audio effects, to pass from one parameters of statuses to another, submerging the player on Wednesday necessary to you.
If to speak openly, AudioMixer possesses ability to distinguish snepshota which fix status of all parameters. Here you can save and execute transitions between any parameters.
We mix favourite bits in the Unity 5.0 program

Can even use the saved snepshota in any order, creating new complex statuses, and to apply them as to you will take in head.
Provide that you leave open section on the card and come into ominous cave. What do you hear there? It is possible to involve transition between mixes to emphasize other, almost inaudible sounds, or to turn on new tools in your ensemble and to change characteristics of echo in new noise design. Provide that for all this you do not need to write lines of new code.

Multidirectional signals

Sends
We mix favourite bits in the Unity 5.0 program
In addition to already available insert of DSP of effects in Unity, you can insert? Send? in any part of mix. Thus, you can send qualitatively sound signal there where you left? Send?, and to solve, what volume of signal you want to involve.
Further? it is more! Considering that the signal level used for branching is part of system of snepshot, you can think how to combine changes of signal flows and transitions between snepshota. Also has rushed? potential installation opportunities expand as snowball.
Here only where the branched-off signal leaves? In the latest version of Unity, Send it is applied together with two other functions: Receives and Volume Ducking.

Receives

? quite simple elements of processing. These are the same inserts, as well as all other effects, and they only collect all branched off by audio from all Send? ov which have selected before and have mixed them, and already transfer all this to the following effect in AudioGroup.
Certainly, if it is about groups of effects or the moment of attenuation in AudioGroup, you can insert Receives anywhere. It gives you huge freedom of action in respect of when to involve the branched-off signal in mix.

Volume Ducking

In addition, Sends interact with Volume Ducking inserts. As well as in case with Receives, these elements can be inserted in parallel with other DSP effects into any place in mix.
We mix favourite bits in the Unity 5.0 program
When Send is aimed at Volume Ducking insert, it in many respects behaves as well as the protocol of the compressor saydcheyn, and it means that you can involve saydcheyn from any place in mix and already from there redirect sound attenuation anywhere!
What does it mean to those who not in subject? Provide that you are occupied with mix of sounds for the shooter and you very much want to deafen the player by sounds of firefight and explosions. Well, it is reasonable, but as about such situation: here you approach not the game character in the battlefield and try to listen to his thoughtful mutter. And? cannot sort anything. Volume Ducking will allow you to lower dynamically the volume of separate segments of mix (in this case, sounds of artillery) is entirely perfect thus without mentioning other segments (conversation of characters). Simply use Send from AudioGroup which contains dialog of characters, and redirect it to Volume Ducking in AudioGroup containing battlefield sounds.
For global setup of all effects you could use and saydcheyn compression in the dynamic mode to squeeze other tools separately from the bass track.
And the coolest, so it that you can make all this in the editor, without creating thus code lines!

Instead of the conclusion

And though I have only superficially outlined possibilities of AudioMixer in this article, I hope, it is enough of it to interest the people in work with sound in Unity 5.0.
From now on and from now on we will approach the future of sound processing in games, and to supply you with tool kit for creation of top-quality sound landscape!

From the translator: on the former it is glad to questions and criticism, and also to wishes on subjects of transfers about Unity

This article is a translation of the original post at habrahabr.ru/post/231841/
If you have any questions regarding the material covered in the article above, please, contact the original author of the post.
If you have any complaints about this article or you want this article to be deleted, please, drop an email here: sysmagazine.com@gmail.com.

We believe that the knowledge, which is available at the most popular Russian IT blog habrahabr.ru, should be accessed by everyone, even though it is poorly translated.
Shared knowledge makes the world better.
Best wishes.

comments powered by Disqus