Example #1
0
        public static void PlayClip(UnityEngine.AudioClip audioClip, int startSample = 0, bool loop = false)
        {
            if (audioClip == null)
            {
                return;
            }

            if (UnitySymbol.UNITY_2020_2_OR_NEWER)
            {
                UnityEditorAudioUtil.PlayPreviewClip(audioClip, startSample, loop);
            }
            else
            {
                UnityEditorAudioUtil.PlayClip(audioClip, startSample, loop);
            }
        }
Example #2
0
        static StackObject *get_samples_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AudioClip instance_of_this_method = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.samples;

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method;
            return(__ret + 1);
        }
Example #3
0
        static StackObject *get_length_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AudioClip instance_of_this_method = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.length;

            __ret->ObjectType       = ObjectTypes.Float;
            *(float *)&__ret->Value = result_of_this_method;
            return(__ret + 1);
        }
        public static byte[] GetOggVorbis(
            UnityEngine.AudioClip audioClip,
            float quality     = 0.4f,
            int samplesToRead = 1024)
        {
            if (audioClip == null)
            {
                throw new System.ArgumentNullException(nameof(audioClip));
            }
            if (samplesToRead <= 0)
            {
                throw new System.ArgumentOutOfRangeException(nameof(samplesToRead));
            }
            short finalChannelsCount = (short)audioClip.channels;

            if (finalChannelsCount != 1 && finalChannelsCount != 2)
            {
                throw new System.ArgumentException($"Only one or two channels are supported, provided channels count: {finalChannelsCount}");
            }
            int returnCode;

            System.IntPtr bytesPtr = System.IntPtr.Zero;
            byte[]        bytes;
            try
            {
                float[] pcm = new float[audioClip.samples * audioClip.channels];
                audioClip.GetData(pcm, 0);
                returnCode = NativeBridge.WriteAllPcmDataToMemory(
                    out bytesPtr,
                    out int bytesLength,
                    pcm,
                    pcm.Length,
                    finalChannelsCount,
                    audioClip.frequency,
                    quality,
                    samplesToRead);
                NativeErrorException.ThrowExceptionIfNecessary(returnCode);
                bytes = new byte[bytesLength];
                Marshal.Copy(bytesPtr, bytes, 0, bytesLength);
            }
            finally
            {
                returnCode = NativeBridge.FreeMemoryArrayForWriteAllPcmData(bytesPtr);
                NativeErrorException.ThrowExceptionIfNecessary(returnCode);
            }
            return(bytes);
        }
Example #5
0
 /** オーディオクリップ。取得。
  */
 public void GetAudioClip(int a_index, out UnityEngine.AudioClip a_audioclip, out float a_volume)
 {
     if (this.pack_audioclip_monobehaviour != null)
     {
         if ((0 <= a_index) && (a_index < this.pack_audioclip_monobehaviour.audioclip_list.Count))
         {
             if (this.pack_audioclip_monobehaviour.audioclip_list[a_index] != null)
             {
                 a_audioclip = this.pack_audioclip_monobehaviour.audioclip_list[a_index];
                 a_volume    = this.pack_audioclip_monobehaviour.volume_list[a_index];
                 return;
             }
         }
     }
     a_audioclip = null;
     a_volume    = 0.0f;
 }
Example #6
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    UnityEngine.AudioClip gen_ret = new UnityEngine.AudioClip();
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AudioClip constructor!"));
        }
Example #7
0
        protected override void OnUpdate()
        {
            //Prevent this from being null when scene is loaded from another scene (Something about the lifecycle of ECS not behaving well with normal gameobject instantiating -> i can not always guarantee that oncreate receives the gameobject)
            if (this.audioSourceGameObject == null)
            {
                this.audioSourceGameObject = UnityEngine.Object.FindObjectOfType <UnityEngine.AudioSource>();
            }

            this.Entities.ForEach((Entity entity, ref SFXComponent sfxComponent) =>
            {
                UnityEngine.AudioClip clipToPlay = AudioClipCache.Instance.GetOrCreateSFX(sfxComponent.SFXType);

                this.audioSourceGameObject.PlayOneShot(clipToPlay);

                this.PostUpdateCommands.AddComponent <DeletionTag>(entity);
            });
        }
        public static UnityEngine.AudioClip ToAudioClip(byte[] bytes, string audioClipName, int maxSamplesToRead = 1024)
        {
            if (bytes == null)
            {
                throw new System.ArgumentNullException(nameof(bytes));
            }
            if (bytes.Length < 10)
            {
                throw new System.ArgumentException(nameof(bytes));
            }
            if (string.IsNullOrWhiteSpace(audioClipName))
            {
                throw new System.ArgumentException("Please provide an audio clip name");
            }
            if (maxSamplesToRead <= 0)
            {
                throw new System.ArgumentOutOfRangeException(nameof(maxSamplesToRead));
            }
            int returnCode;

            System.IntPtr         pcmPtr    = System.IntPtr.Zero;
            UnityEngine.AudioClip audioClip = null;
            try
            {
                returnCode = NativeBridge.ReadAllPcmDataFromMemory(
                    bytes,
                    bytes.Length,
                    out pcmPtr,
                    out int pcmLength,
                    out short channels,
                    out int frequency,
                    maxSamplesToRead);
                NativeErrorException.ThrowExceptionIfNecessary(returnCode);
                float[] pcm = new float[pcmLength];
                Marshal.Copy(pcmPtr, pcm, 0, pcmLength);
                audioClip = UnityEngine.AudioClip.Create(audioClipName, pcmLength / channels, channels, frequency, false);
                audioClip.SetData(pcm, 0);
            }
            finally
            {
                returnCode = NativeBridge.FreeSamplesArrayNativeMemory(ref pcmPtr);
                NativeErrorException.ThrowExceptionIfNecessary(returnCode);
            }
            return(audioClip);
        }
Example #9
0
        private void InitBackgroudMusic(int scene_id)
        {
            Data_SceneConfig dsc = SceneConfigProvider.Instance.GetSceneConfigById(scene_id);

            if (null != dsc)
            {
                UnityEngine.GameObject go = UnityEngine.GameObject.Find("Audio");
                if (null != go)
                {
                    UnityEngine.AudioSource[] audio_source = go.GetComponents <UnityEngine.AudioSource>();
                    if (null == audio_source)
                    {
                        return;
                    }
                    for (int i = 0; i < audio_source.Length; i++)
                    {
                        if (null != audio_source[i])
                        {
                            if (audio_source[i].isPlaying)
                            {
                                continue;
                            }
                            string name   = "";
                            float  volume = 1.0f;
                            if (0 == i)
                            {
                                name   = dsc.m_BkMusic;
                                volume = dsc.m_BkMusicVolume;
                            }
                            else
                            {
                                name   = dsc.m_StoryMusic;
                                volume = dsc.m_StoryMusicVolume;
                            }
                            UnityEngine.AudioClip clip = (UnityEngine.AudioClip)UnityEngine.Resources.Load(name) as UnityEngine.AudioClip;
                            if (null != clip)
                            {
                                audio_source[i].clip   = clip;
                                audio_source[i].volume = dsc.m_BkMusicVolume * 0.0f; // tmp disable backgroud music
                            }
                        }
                    }
                }
            }
        }
Example #10
0
        /// <summary>
        /// Start Recording with device.
        /// </summary>
        /// <param name="deviceName">The name of the device. (not uses)</param>
        /// <param name="loop">Indicates whether the recording should continue recording if lengthSec is reached, and wrap around and record from the beginning of the AudioClip.</param>
        /// <param name="lengthSec">Is the length of the AudioClip produced by the recording.</param>
        /// <param name="frequency">The sample rate of the AudioClip produced by the recording.</param>
        /// <returns>The function returns null if the recording fails to start.</returns>
        public UnityEngine.AudioClip Start(string deviceName, bool loop, int lengthSec, int frequency)
        {
            if (IsRecording(deviceName))
            {
                return(_microphoneClip);
            }

            Cleanup();

            _frequency      = frequency;
            _loopRecording  = loop;
            _microphoneClip = UnityEngine.AudioClip.Create("Microphone", _frequency * lengthSec, 1, _frequency, false);
            _audioDataArray = new float[_frequency * lengthSec];

            start(deviceName, loop ? 1 : 0, lengthSec, _frequency);

            return(_microphoneClip);
        }
Example #11
0
        static StackObject *PlayOneShotSound_38(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AudioClip @clip = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            FairyGUI.GRoot instance_of_this_method = (FairyGUI.GRoot) typeof(FairyGUI.GRoot).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.PlayOneShotSound(@clip);

            return(__ret);
        }
        static StackObject *set_clip_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AudioClip @value = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.AudioSource instance_of_this_method = (UnityEngine.AudioSource) typeof(UnityEngine.AudioSource).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.clip = value;

            return(__ret);
        }
Example #13
0
        static StackObject *Enqueue_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AudioClip @item = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Collections.Generic.Queue <UnityEngine.AudioClip> instance_of_this_method = (System.Collections.Generic.Queue <UnityEngine.AudioClip>) typeof(System.Collections.Generic.Queue <UnityEngine.AudioClip>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Enqueue(@item);

            return(__ret);
        }
Example #14
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 2 && translator.Assignable <UnityEngine.AudioClip>(L, 2))
                {
                    UnityEngine.AudioClip _audioClip = (UnityEngine.AudioClip)translator.GetObject(L, 2, typeof(UnityEngine.AudioClip));

                    FairyGUI.NAudioClip gen_ret = new FairyGUI.NAudioClip(_audioClip);
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to FairyGUI.NAudioClip constructor!"));
        }
        public async Task PlayRandomAudio(UnityEngine.AudioClip fallback, LevelCompletionResults results, bool highScore)
        {
            await SiraUtil.Utilities.AwaitSleep(250);

            if (results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Failed && _config.ResultFailedSoundsEnabled)
            {
                var hasAudio = _config.EnabledResultFailedSounds.Count != 0;

                if (!hasAudio)
                {
                    return;
                }

                var randomAudioFile = _config.EnabledResultFailedSounds[_random.Next(0, _config.EnabledResultFailedSounds.Count)];
                _siraLog.Info($"Loading Audio File: {randomAudioFile.FullName}");
                var clip = await _audioClipAsyncLoader.LoadAudioClipAsync(randomAudioFile.FullName, CancellationToken.None);

                Play(clip);
            }
            else if (results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared && _config.ResultSoundsEnabled)
            {
                var info     = results.fullCombo ? (_config.EnabledResultFCSounds.Count == 0 ? _config.EnabledResultSounds : _config.EnabledResultFCSounds) : _config.EnabledResultSounds;
                var hasAudio = info.Count != 0;

                if (!hasAudio)
                {
                    if (highScore)
                    {
                        _songPreviewPlayer.CrossfadeTo(fallback, 0f, fallback.length);
                    }
                    return;
                }

                var randomAudioFile = info[_random.Next(0, info.Count)];
                _siraLog.Info($"Loading Audio File: {randomAudioFile.FullName}");
                var clip = await _audioClipAsyncLoader.LoadAudioClipAsync(randomAudioFile.FullName, CancellationToken.None);

                if (highScore)
                {
                    Play(clip);
                }
            }
        }
Example #16
0
        static int _m_GetAudio(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                QP.Framework.ResMgr gen_to_be_invoked = (QP.Framework.ResMgr)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TSTRING))
                {
                    string _module     = LuaAPI.lua_tostring(L, 2);
                    string _prefabName = LuaAPI.lua_tostring(L, 3);
                    string _bundleName = LuaAPI.lua_tostring(L, 4);

                    UnityEngine.AudioClip gen_ret = gen_to_be_invoked.GetAudio(_module, _prefabName, _bundleName);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING))
                {
                    string _module     = LuaAPI.lua_tostring(L, 2);
                    string _prefabName = LuaAPI.lua_tostring(L, 3);

                    UnityEngine.AudioClip gen_ret = gen_to_be_invoked.GetAudio(_module, _prefabName);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to QP.Framework.ResMgr.GetAudio!"));
        }
Example #17
0
        static int _m_PlayBattleSFX(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            xc.AudioManager __cl_gen_to_be_invoked = (xc.AudioManager)translator.FastGetCSObj(L, 1);


            int __gen_param_count = LuaAPI.lua_gettop(L);

            try {
                if (__gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <xc.SoundType>(L, 3))
                {
                    string       res_path = LuaAPI.lua_tostring(L, 2);
                    xc.SoundType type; translator.Get(L, 3, out type);

                    uint __cl_gen_ret = __cl_gen_to_be_invoked.PlayBattleSFX(res_path, type);
                    LuaAPI.xlua_pushuint(L, __cl_gen_ret);



                    return(1);
                }
                if (__gen_param_count == 3 && translator.Assignable <UnityEngine.AudioClip>(L, 2) && translator.Assignable <xc.SoundType>(L, 3))
                {
                    UnityEngine.AudioClip clip = (UnityEngine.AudioClip)translator.GetObject(L, 2, typeof(UnityEngine.AudioClip));
                    xc.SoundType          type; translator.Get(L, 3, out type);

                    uint __cl_gen_ret = __cl_gen_to_be_invoked.PlayBattleSFX(clip, type);
                    LuaAPI.xlua_pushuint(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to xc.AudioManager.PlayBattleSFX!"));
        }
Example #18
0
        static int _m_PlayOneShotSound(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                FairyGUI.Stage gen_to_be_invoked = (FairyGUI.Stage)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable <UnityEngine.AudioClip>(L, 2))
                {
                    UnityEngine.AudioClip _clip = (UnityEngine.AudioClip)translator.GetObject(L, 2, typeof(UnityEngine.AudioClip));

                    gen_to_be_invoked.PlayOneShotSound(
                        _clip);



                    return(0);
                }
                if (gen_param_count == 3 && translator.Assignable <UnityEngine.AudioClip>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    UnityEngine.AudioClip _clip = (UnityEngine.AudioClip)translator.GetObject(L, 2, typeof(UnityEngine.AudioClip));
                    float _volumeScale          = (float)LuaAPI.lua_tonumber(L, 3);

                    gen_to_be_invoked.PlayOneShotSound(
                        _clip,
                        _volumeScale);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to FairyGUI.Stage.PlayOneShotSound!"));
        }
Example #19
0
        public void __Gen_Delegate_Imp3(UnityEngine.AudioClip p0)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            RealStatePtr L = luaEnv.rawL;
            int errFunc    = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
            ObjectTranslator translator = luaEnv.translator;
            translator.Push(L, p0);

            PCall(L, 1, 0, errFunc);



            LuaAPI.lua_settop(L, errFunc - 1);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
        static int _m_UnloadAudioData(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.AudioClip __cl_gen_to_be_invoked = (UnityEngine.AudioClip)translator.FastGetCSObj(L, 1);


            try {
                {
                    bool __cl_gen_ret = __cl_gen_to_be_invoked.UnloadAudioData(  );
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Example #21
0
 internal void Play(Sound sound, UnityEngine.AudioClip clip, bool looping, bool paused, float fadeinTime)
 {
     source.clip = clip;
     if (source.isPlaying)
     {
         throw new Lime.Exception("AudioSource must be stopped before play");
     }
     source.loop = looping;
     if (Sound != null)
     {
         Sound.Channel = NullAudioChannel.Instance;
     }
     this.Sound    = sound;
     sound.Channel = this;
     StartupTime   = DateTime.Now;
     this.paused   = true;
     if (!paused)
     {
         Resume(0);
     }
 }
        static StackObject *PlayOneShotSound_23(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Single @volumeScale = *(float *)&ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.AudioClip @clip = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            FairyGUI.Stage instance_of_this_method = (FairyGUI.Stage) typeof(FairyGUI.Stage).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.PlayOneShotSound(@clip, @volumeScale);

            return(__ret);
        }
        static StackObject *Play_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Boolean @loop = ptr_of_this_method->Value == 1;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.AudioClip @ac = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            Zero.AudioDevice instance_of_this_method = (Zero.AudioDevice) typeof(Zero.AudioDevice).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Play(@ac, @loop);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
        static int _m_LoadAudioClipByBaseWindow_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    xc.ui.ugui.UIBaseWindow win = (xc.ui.ugui.UIBaseWindow)translator.GetObject(L, 1, typeof(xc.ui.ugui.UIBaseWindow));
                    string audioClipName        = LuaAPI.lua_tostring(L, 2);

                    UnityEngine.AudioClip __cl_gen_ret = xc.ui.ugui.UIHelper.LoadAudioClipByBaseWindow(win, audioClipName);
                    translator.Push(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
        static StackObject *Add_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AudioClip @value = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @key = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Collections.Generic.Dictionary <System.String, UnityEngine.AudioClip> instance_of_this_method = (System.Collections.Generic.Dictionary <System.String, UnityEngine.AudioClip>) typeof(System.Collections.Generic.Dictionary <System.String, UnityEngine.AudioClip>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Add(@key, @value);

            return(__ret);
        }
Example #26
0
        static int _m_SetClip(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            xc.AudioManager __cl_gen_to_be_invoked = (xc.AudioManager)translator.FastGetCSObj(L, 1);


            try {
                {
                    UnityEngine.AudioClip audio = (UnityEngine.AudioClip)translator.GetObject(L, 2, typeof(UnityEngine.AudioClip));
                    xc.BackGroundType     type; translator.Get(L, 3, out type);

                    __cl_gen_to_be_invoked.SetClip(audio, type);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
        static StackObject *SetData_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 @offsetSamples = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Single[] @data = (System.Single[]) typeof(System.Single[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            UnityEngine.AudioClip instance_of_this_method = (UnityEngine.AudioClip) typeof(UnityEngine.AudioClip).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.SetData(@data, @offsetSamples);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
Example #28
0
        static int _m_Reload(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                FairyGUI.NAudioClip gen_to_be_invoked = (FairyGUI.NAudioClip)translator.FastGetCSObj(L, 1);



                {
                    UnityEngine.AudioClip _audioClip = (UnityEngine.AudioClip)translator.GetObject(L, 2, typeof(UnityEngine.AudioClip));

                    gen_to_be_invoked.Reload(_audioClip);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
        static int _m_SetData(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.AudioClip __cl_gen_to_be_invoked = (UnityEngine.AudioClip)translator.FastGetCSObj(L, 1);


            try {
                {
                    float[] data          = (float[])translator.GetObject(L, 2, typeof(float[]));
                    int     offsetSamples = LuaAPI.xlua_tointeger(L, 3);

                    bool __cl_gen_ret = __cl_gen_to_be_invoked.SetData(data, offsetSamples);
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Example #30
0
        static int _m_Start_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    string _deviceName = LuaAPI.lua_tostring(L, 1);
                    bool   _loop       = LuaAPI.lua_toboolean(L, 2);
                    int    _lengthSec  = LuaAPI.xlua_tointeger(L, 3);
                    int    _frequency  = LuaAPI.xlua_tointeger(L, 4);

                    UnityEngine.AudioClip gen_ret = UnityEngine.Microphone.Start(_deviceName, _loop, _lengthSec, _frequency);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Example #31
0
        /// <summary>
        /// Returns the next randomly chosen clip for this state. You can pass the seed for constant results. 
        /// </summary>
        /// <returns>The next clip.</returns>
        /// <param name="pSeed">seed</param>
        public UnityEngine.AudioClip GetNextClip( int pSeed )
        {
            System.Random r = new Random( pSeed );
            if(mMusicClips.Count == 0)
                return null;

            mLastIndex = r.Next(0,mMusicClips.Count);

            Unload();

            mClip = UnityEngine.Resources.Load(mMusicClips[mLastIndex]) as UnityEngine.AudioClip;
            return mClip;
        }