public static Delegate AudioClip_PCMSetPositionCallback(LuaFunction func) { AudioClip.PCMSetPositionCallback d = (param0) => { int top = func.BeginPCall(); IntPtr L = func.GetLuaState(); LuaScriptMgr.Push(L, param0); func.PCall(top, 1); func.EndPCall(top); }; return(d); }
private void loadOgg(string filePath) { if (string.IsNullOrWhiteSpace(filePath) || !Path.GetExtension(filePath).Equals(".ogg")) { Debug.Log($"Unable to load audio clip from path '{filePath}', only OGG format supported."); return; } _vorbis = new VorbisReader(filePath); AudioClip.PCMReaderCallback onAudioRead = data => { _vorbis.ReadSamples(data, 0, data.Length); }; AudioClip.PCMSetPositionCallback onAudioSetPosition = newPos => { _vorbis.DecodedPosition = newPos; }; string fileName = Path.GetFileName(filePath); Clip = AudioClip.Create(fileName, (int)_vorbis.TotalSamples, _vorbis.Channels, _vorbis.SampleRate, true, onAudioRead, onAudioSetPosition); }
public static AudioClip Create(string name, int lengthSamples, int channels, int frequency, bool stream, AudioClip.PCMReaderCallback pcmreadercallback, AudioClip.PCMSetPositionCallback pcmsetpositioncallback) { if (name == null) { throw new NullReferenceException(); } if (lengthSamples <= 0) { throw new ArgumentException("Length of created clip must be larger than 0"); } if (channels <= 0) { throw new ArgumentException("Number of channels in created clip must be greater than 0"); } if (frequency <= 0) { throw new ArgumentException("Frequency in created clip must be greater than 0"); } AudioClip audioClip = AudioClip.Construct_Internal(); if (pcmreadercallback != null) { audioClip.m_PCMReaderCallback += pcmreadercallback; } if (pcmsetpositioncallback != null) { audioClip.m_PCMSetPositionCallback += pcmsetpositioncallback; } audioClip.Init_Internal(name, lengthSamples, channels, frequency, stream); return(audioClip); }
public static AudioClip Create(string name, int lengthSamples, int channels, int frequency, bool _3D, bool stream, AudioClip.PCMReaderCallback pcmreadercallback, AudioClip.PCMSetPositionCallback pcmsetpositioncallback) { return(AudioClip.Create(name, lengthSamples, channels, frequency, stream, pcmreadercallback, pcmsetpositioncallback)); }
static int Create(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 5) { string arg0 = LuaScriptMgr.GetLuaString(L, 1); int arg1 = (int)LuaScriptMgr.GetNumber(L, 2); int arg2 = (int)LuaScriptMgr.GetNumber(L, 3); int arg3 = (int)LuaScriptMgr.GetNumber(L, 4); bool arg4 = LuaScriptMgr.GetBoolean(L, 5); AudioClip o = AudioClip.Create(arg0, arg1, arg2, arg3, arg4); LuaScriptMgr.Push(L, o); return(1); } else if (count == 6) { string arg0 = LuaScriptMgr.GetLuaString(L, 1); int arg1 = (int)LuaScriptMgr.GetNumber(L, 2); int arg2 = (int)LuaScriptMgr.GetNumber(L, 3); int arg3 = (int)LuaScriptMgr.GetNumber(L, 4); bool arg4 = LuaScriptMgr.GetBoolean(L, 5); AudioClip.PCMReaderCallback arg5 = null; LuaTypes funcType5 = LuaDLL.lua_type(L, 5); if (funcType5 != LuaTypes.LUA_TFUNCTION) { arg5 = (AudioClip.PCMReaderCallback)LuaScriptMgr.GetNetObject(L, 6, typeof(AudioClip.PCMReaderCallback)); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 6); arg5 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.PushArray(L, param0); func.PCall(top, 1); func.EndPCall(top); }; } AudioClip o = AudioClip.Create(arg0, arg1, arg2, arg3, arg4, arg5); LuaScriptMgr.Push(L, o); return(1); } else if (count == 7) { string arg0 = LuaScriptMgr.GetLuaString(L, 1); int arg1 = (int)LuaScriptMgr.GetNumber(L, 2); int arg2 = (int)LuaScriptMgr.GetNumber(L, 3); int arg3 = (int)LuaScriptMgr.GetNumber(L, 4); bool arg4 = LuaScriptMgr.GetBoolean(L, 5); AudioClip.PCMReaderCallback arg5 = null; LuaTypes funcType5 = LuaDLL.lua_type(L, 5); if (funcType5 != LuaTypes.LUA_TFUNCTION) { arg5 = (AudioClip.PCMReaderCallback)LuaScriptMgr.GetNetObject(L, 6, typeof(AudioClip.PCMReaderCallback)); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 6); arg5 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.PushArray(L, param0); func.PCall(top, 1); func.EndPCall(top); }; } AudioClip.PCMSetPositionCallback arg6 = null; LuaTypes funcType6 = LuaDLL.lua_type(L, 6); if (funcType6 != LuaTypes.LUA_TFUNCTION) { arg6 = (AudioClip.PCMSetPositionCallback)LuaScriptMgr.GetNetObject(L, 7, typeof(AudioClip.PCMSetPositionCallback)); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 7); arg6 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.Push(L, param0); func.PCall(top, 1); func.EndPCall(top); }; } AudioClip o = AudioClip.Create(arg0, arg1, arg2, arg3, arg4, arg5, arg6); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: AudioClip.Create"); } return(0); }
public static AudioClip Create(string name, int lengthSamples, int channels, int frequency, bool stream, AudioClip.PCMReaderCallback pcmreadercallback, AudioClip.PCMSetPositionCallback pcmsetpositioncallback) { bool flag = name == null; if (flag) { throw new NullReferenceException(); } bool flag2 = lengthSamples <= 0; if (flag2) { throw new ArgumentException("Length of created clip must be larger than 0"); } bool flag3 = channels <= 0; if (flag3) { throw new ArgumentException("Number of channels in created clip must be greater than 0"); } bool flag4 = frequency <= 0; if (flag4) { throw new ArgumentException("Frequency in created clip must be greater than 0"); } AudioClip audioClip = AudioClip.Construct_Internal(); bool flag5 = pcmreadercallback != null; if (flag5) { audioClip.m_PCMReaderCallback += pcmreadercallback; } bool flag6 = pcmsetpositioncallback != null; if (flag6) { audioClip.m_PCMSetPositionCallback += pcmsetpositioncallback; } audioClip.CreateUserSound(name, lengthSamples, channels, frequency, stream); return(audioClip); }