![]() ![]() ![]() If you wait a bit and play the 4th sound and some earlier sound ended, SoundPool knows which one to reuse. Those native source are sometimes referrred as "stream".įor example you play 3 different sounds quickly while having 2 sources, it will allocate you a new one. One from many native sources will be selected and maintained automatically, instantiated more if not enough. The definition of SoundPool is so that you don't have to worry about underlying "native source" but rather a pool of sounds you want to use. I have confirmed that SoundPool is slower than (Java) AudioTrack. Which you will get to know them next.Ī SoundPool is a collection of samples that can be loaded into memory from a resource inside the APK or from a file in… This open up a way to access MediaPlayer, SoundPool, and (Java) AudioTrack from Unity. They are not directly related to audio, but with these helper classes, you are able to use Java stuff from C# without writing a single Java code. AndroidJavaClass / AndroidJavaObject / AndroidJavaProxy / AndroidJNI / AndroidJNIHelper This is opposite of “Best Performance” with BIG buffer to ensure the audio does not drop out but the latency will go to hell with that setting. (It minimize the buffer size, but we don’t know how small it is or could it be smaller). Note : When I say “faster than Unity” from this point on, that is compared with Unity + the setting “Best Latency” (plays the fastest possible) in Audio Settings. We will start from learning why my plugin Native Audio choose OpenSL ES as the implementation in Android side. ![]() Ways of playing native audio in Android from Unity You will learn about "native source" later how to get the fast one and various experiments like, what happen if we request too many. They will sound at slightly different time depending on which one comes first, since native plugin doesn't wait for frame. Imagine you do 3 AudioSource.Play in a different Update."Native source" is a limited resource per device, NA only allocates 3 by default and that means only 3 concurrent audio maximum until you have to cut off old sounds.One source is exclusively for one preloaded audio.On NativeAudioPointer.Play, one of the native sourcce is seleted to play at specified audio bytes memory area immediately, right at that C# line without waiting for the end of frame, and without mixing or effects.On application start, NA allocates several "native source" with settings geared toward low latency.They will sound exactly at the same time after passing through latency. You get virtually unlimited concurrent audio. That one native source get the mixed audio bytes.When at the end of frame, Unity will calculate based on fall off, mixer, effects, etc.On AudioSource.Play in C# code, it will wait and collects all these kind of commands until the end of frame.This native source is configured based on unknown algorithm that sometimes results in a slow source. On application start, Unity request 1 "native source" from Android device.Native Audio is a plugin that helps you easily loads and plays an audio using each platform's fastest native method… What is Unity doing Native Audio - Lower audio latency via OS's native audio library. If you have time you can read all of the reason from this front page : Latency! It is quite critical in some kind of games. (Also I hate manually editing HTML for long article with proper code tags and uploading images is a chore so I choose to put it here instead.)īe prepared for an hour-long audio lesson! Android is really complicated! Why skip Unity’s audio? What is the point of Native Audio? I will demystify the “black box” surrounding the Android audio system and analyze why Unity’s way of using it makes your audio latency even higher than the already awful Android latency.Īctually a supplementary documentation for the plugin Native Audio which skips all Unity’s audio system for the best latency, but it should also be useful for anyone who want to know more about the mystery of Android’s audio. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |