Exemplo n.º 1
0
        /// <summary>
        /// Shave off as much start up time as possible to play a sound. The majority of load time is already in `Load` but `Prepare` might help a bit more, or not at all. You can also call `Play()` without calling this first. The effectiveness depends on platform's audio library's approach :

        /// [iOS] Assigns OpenAL audio buffer to a source. `NativeAudioPointer` then remembers this source index. The next `Play()` you call will immediately play this remembered source without caring what sound is in it instead of using a buffer index to get sound to pair with the next available source. This means if in between `Prepare()` and `Play()` you have played 32 sounds, the resulting sound will be something else as other sound has already put their buffer into the source you have remembered.

        /// [Android] `write` a loaded audio byte array to any non-playing `AudioTrack` so that the next `Play()` does not require a `write` and can play right away. If all `AudioTrack` is playing the first `AudioTrack` will immediately stop to receive a new `byte[]` data.

        /// </summary>
        public void Prepare()
        {
#if UNITY_IOS
            prepareIndex = NativeAudio._PrepareAudio(NextIndex);
            prepared     = true;
#elif UNITY_ANDROID
            NativeAudio.AndroidNativeAudio.CallStatic(NativeAudio.AndroidPrepareAudio, NextIndex);
#endif
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shave off as much start up time as possible to play a sound. The majority of load time is already in `Load` but `Prepare` might help a bit more, or not at all. You can also call `Play()` without calling this first. The effectiveness depends on platform's audio library's approach :

        /// [iOS] Assigns OpenAL audio buffer to a source. `NativeAudioPointer` then remembers this source index. The next `Play()` you call will immediately play this remembered source without caring what sound is in it instead of using a buffer index to get sound to pair with the next available source. This means if in between `Prepare()` and `Play()` you have played 16 sounds, the resulting sound will be something else as other sound has already put their buffer into the source you have remembered.

        /// [Android] No effect as OpenSL ES play audio by pushing data into `SLAndroidSimpleBufferQueueItf`. All the prepare is already at the `Load()`.

        /// </summary>
        public void Prepare()
        {
#if UNITY_IOS
            prepareIndex = NativeAudio._PrepareAudio(NextIndex);
            prepared     = true;
#elif UNITY_ANDROID
            //There is no possible preparation for OpenSL ES at the moment..
#endif
        }