public GetAudioClip ( bool threeD ) : |
||
threeD | bool | Use this to specify whether the clip should be a 2D or 3D clip /// the .audioClip property defaults to 3D. |
return |
private IEnumerator DownloadAudio() { _url = input_url.text; //#if !UNITY_EDITOR // _url = _url.Replace("http://www.spilldemo.com", Application.dataPath + "/.."); //#endif Debug.Log("_url: " + _url); yield return new WaitForSeconds(0.5f); WWW www = new WWW(_url); yield return www; string extension = _url.Substring(_url.Length - 4); Debug.Log("extension: " + extension); if (extension.Equals(".ogg")) _source.clip = www.GetAudioClip(false, false, AudioType.OGGVORBIS); else if (extension.Equals(".mp3")) _source.clip = www.GetAudioClip(false, false, AudioType.MPEG); else if (extension.Equals(".wav")) _source.clip = www.GetAudioClip(false, false, AudioType.WAV); else _source.clip = www.GetAudioClip(false, false, AudioType.UNKNOWN); yield return new WaitForSeconds(0.5f); _source.Play(); }
private IEnumerator StartLoadMusic(string url, bool broadcast = false) { var s = http + "//tmrace.net/cops/music.php?url=" + WWW.EscapeURL(url); print(s); var w = new WWW(s); yield return w; print(w.text); w = new WWW(w.text); yield return w; var audioClip = w.GetAudioClip(false, true); if (audioClip.length == 0) { Debug.LogError(w.error); yield break; } if (broadcast && _Game && audioClip) { broadCastTime = Time.time; _Game.CallRPC(_ChatGui.Chat, _Player.playerName + " Set music to " + w.text); _Game.CallRPCTo(_Game.LoadMusic, PhotonTargets.Others, w.text); } audio.clip = audioClip; audio.Play(); }
private IEnumerator StartLoadMusic(string url, bool broadcast = false) { var s = http + "://tmrace.net/cops/music.php?url=" + WWW.EscapeURL(url); Debug.LogWarning(s); var w = new WWW(s); yield return w; if(string.IsNullOrEmpty(w.text))yield break; print(w.text); w = new WWW(w.text); yield return w; var audioClip = w.GetAudioClip(false, true, AudioType.OGGVORBIS); if (audioClip.length == 0) { Debug.LogError(w.error); yield break; } if (broadcast && _Game && audioClip) { broadCastTime = Time.time; _GameGui.CallRPC(_GameGui.Chat, _Loader.playerName + " Play music " + Path.GetFileNameWithoutExtension(w.url)); _GameGui.CallRPCTo(_MpGame.LoadMusic, PhotonTargets.Others, s); } audio.clip = audioClip; audio.Play(); }
protected void FileSelected(string path) { fileBrowser = null; if (path != null) { Debug.Log(path); if(path.Contains(".mp3")) { Debug.Log(path); using (Mp3FileReader reader = new Mp3FileReader(path)) { Debug.Log("Reached"); path = path.Replace(".mp3", ".wav"); WaveFileWriter.CreateWaveFile(path , reader); } } path = "file://" + path; WWW wtf = new WWW(path); //Wait for wtf to finish while (!wtf.isDone) { } SceneManager.getInstance.setClip(wtf.GetAudioClip(false)); } }
private IEnumerator OpenAndPlay(string path) { WWW www = new WWW("file://" + path); this.AudioSource.clip = www.GetAudioClip(false, true); while (this.AudioSource.clip.isReadyToPlay == false) yield return null; this.AudioSource.Play(); }
protected override void onFlightStart() { ping = gameObject.AddComponent<AudioSource>(); WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MuonDetector/ping.wav"); if ((ping != null) && (www != null)) { ping.clip = www.GetAudioClip(false); ping.volume = 0; ping.Stop(); } disk = transform.Find("model/disk"); if (disk != null) { MIN_PING_DIST = 150000; MIN_PING_TIME = 0.2; MAX_PING_TIME = 15; led = transform.Find("model/led"); originalLensShader = led.renderer.material.shader; pingLight = led.gameObject.AddComponent<Light>(); pingLight.type = LightType.Point; pingLight.renderMode = LightRenderMode.ForcePixel; pingLight.shadows = LightShadows.None; pingLight.range = 1; pingLight.enabled = false; } RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI)); }
IEnumerator LoadMusic(string[] urls) { foreach (string url in urls){ WWW download = new WWW ("file://" + url); yield return download; music.Add(download.GetAudioClip(false)); } }
public AudioClip GetAudioClip() { var thewww = new WWW(song); while(!thewww.isDone){ } var ac = thewww.GetAudioClip(false, true,AudioType.OGGVORBIS); thewww.Dispose(); return ac; }
static public int GetAudioClip(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); var ret = self.GetAudioClip(); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 2) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); var ret = self.GetAudioClip(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 3) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); var ret = self.GetAudioClip(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 4) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); UnityEngine.AudioType a3; checkEnum(l, 4, out a3); var ret = self.GetAudioClip(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function GetAudioClip to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
public static IEnumerator LoadClip(AudioSource audioSource) { WWW www = new WWW("file://" + tempFolder + "output.wav"); while (!www.isDone) yield return www; AudioClip clip = www.GetAudioClip(false); audioSource.clip = clip; if (clip.length > 0) audioSource.PlayDelayed(0.02f); }
private IEnumerator LoadSound() { WWW www = new WWW("File://" + Application.streamingAssetsPath + "/Audio/buttonSound.ogg"); yield return www; //buttonSound = www.audioClip; buttonSound = www.GetAudioClip(false); www.Dispose(); }
IEnumerator GetWWW(int st) { www = new WWW(urls[st]); int frames = 0; while (www != null && !www.isDone) { m_info = "Loading... " + frames; frames++; yield return new WaitForEndOfFrame(); } if (!string.IsNullOrEmpty(www.error)) { m_info = "Error: " + www.error; } else { m_info = "Done!"; switch (st) { case 0: { m_info += " Press Mouse Button 2 to load texture"; tex = null; if (www.audioClip != null) { _audio = www.GetAudioClip(false, false, AudioType.WAV); if (_audio == null) yield return new WaitForEndOfFrame(); else gameObject.GetComponent<AudioSource>().clip = _audio; } break; } case 1: { m_info += " Press Mouse Button 2 to load texture (non readable) and load into texture"; _audio = null; gameObject.GetComponent<AudioSource>().clip = null; if (www.texture != null) tex = www.texture; } break; case 2: { m_info += " Press Mouse Button 2 to load sound"; if (www.textureNonReadable != null) www.LoadImageIntoTexture(tex); } break; } } }
static int GetAudioClip(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.WWW.Register"); #endif try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1); UnityEngine.AudioClip o = obj.GetAudioClip(); ToLua.PushSealed(L, o); return(1); } else if (count == 2) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); UnityEngine.AudioClip o = obj.GetAudioClip(arg0); ToLua.PushSealed(L, o); return(1); } else if (count == 3) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); bool arg1 = LuaDLL.luaL_checkboolean(L, 3); UnityEngine.AudioClip o = obj.GetAudioClip(arg0, arg1); ToLua.PushSealed(L, o); return(1); } else if (count == 4) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); bool arg1 = LuaDLL.luaL_checkboolean(L, 3); UnityEngine.AudioType arg2 = (UnityEngine.AudioType)ToLua.CheckObject(L, 4, typeof(UnityEngine.AudioType)); UnityEngine.AudioClip o = obj.GetAudioClip(arg0, arg1, arg2); ToLua.PushSealed(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.WWW.GetAudioClip")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int get_audioClip(IntPtr l) { try { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); pushValue(l, true); pushValue(l, self.GetAudioClip()); return(2); } catch (Exception e) { return(error(l, e)); } }
IEnumerator start() { // Remove the "spaces" in excess Regex rgx = new Regex ("\\s+"); // Replace the "spaces" with "% 20" for the link Can be interpreted string result = rgx.Replace ("Hello", "%20"); string url = "http://translate.google.com/translate_tts?tl=en&q=" + result; WWW www = new WWW (url); yield return www; GetComponent<AudioSource>().clip = www.GetAudioClip (false, false, AudioType.MPEG); GetComponent<AudioSource>().Play (); }
IEnumerator AddURLRoutine(string url) { WWW www = new WWW(url); while (!www.isDone) yield return null; AudioClip clip = www.GetAudioClip(false, true); while (clip.loadState != AudioDataLoadState.Failed && clip.loadState != AudioDataLoadState.Loaded) yield return null; if (clip != null) { tracks.Add(clip); } }
IEnumerator DownloadSound() { WWW www = new WWW("http://7ROAD-20140625X.7road.com/music.wav"); yield return www; if (www.error != null) { m_info = www.error; yield return null; } m_downloadClip = www.GetAudioClip(false); audio.PlayOneShot(m_downloadClip); }
public void play() { //the actual play button activation method string fullpath = "file://" + fileinfo [selectedCellIndex].FullName; Debug.Log ("Play, " + fullpath); WWW clip = new WWW (fullpath); Debug.Log (clip.bytes); audioSource.clip = clip.GetAudioClip (false, true); audioSource.Play (); //Animation Anime = jeep.GetComponent<Animation> (); //Anime.Play ("Take 001"); //Debug.Log (Anime.Play ()); }
IEnumerator download(string filePathUrl) { WWW www = new WWW (filePathUrl); while (!www.isDone) { // ダウンロードの進捗を表示 print (Mathf.CeilToInt (www.progress * 100)); yield return null; } if (!string.IsNullOrEmpty (www.error)) { // ダウンロードでエラーが発生した Debug.Log ("error:" + www.error); } else { // ダウンロードが正常に完了した filePath = Application.persistentDataPath + "/" + Path.GetFileName (www.url); File.WriteAllBytes (filePath, www.bytes); Debug.Log ("download file write success." + filePath); audioSource.clip = www.GetAudioClip(false, true, AudioType.MPEG); audioSource.Play(); // 音声の時間を保存しておく maxAudioTime = www.GetAudioClip(false, true, AudioType.MPEG).length; audioTime = maxAudioTime; } }
IEnumerator LoadFile(string path) { WWW www = new WWW("file://" + path); print("loading " + path); AudioClip clip = www.GetAudioClip(false); while (!clip.isReadyToPlay) yield return www; print("done loading"); clip.name = Path.GetFileName(path); clips.Add(clip); }
private IEnumerator startStreamCoroutine() { WWW audioStream = new WWW(streamURL); _clip = audioStream.GetAudioClip(true,true); if(!streamEarly) { while(!_clip.isReadyToPlay) yield return new WaitForSeconds(0.5f); _audioSource.clip = _clip; _audioSource.Play(); } }
static int GetAudioClip(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1); UnityEngine.AudioClip o = obj.GetAudioClip(); ToLua.PushSealed(L, o); return(1); } else if (count == 2) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); UnityEngine.AudioClip o = obj.GetAudioClip(arg0); ToLua.PushSealed(L, o); return(1); } else if (count == 3) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); bool arg1 = LuaDLL.luaL_checkboolean(L, 3); UnityEngine.AudioClip o = obj.GetAudioClip(arg0, arg1); ToLua.PushSealed(L, o); return(1); } else if (count == 4) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L, 1); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); bool arg1 = LuaDLL.luaL_checkboolean(L, 3); UnityEngine.AudioType arg2 = (UnityEngine.AudioType)LuaDLL.luaL_checknumber(L, 4); UnityEngine.AudioClip o = obj.GetAudioClip(arg0, arg1, arg2); ToLua.PushSealed(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.WWW.GetAudioClip")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetAudioClip(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.WWW))) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.ToObject(L, 1); UnityEngine.AudioClip o = obj.GetAudioClip(); ToLua.Push(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.WWW), typeof(bool))) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.ToObject(L, 1); bool arg0 = LuaDLL.lua_toboolean(L, 2); UnityEngine.AudioClip o = obj.GetAudioClip(arg0); ToLua.Push(L, o); return(1); } else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.WWW), typeof(bool), typeof(bool))) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.ToObject(L, 1); bool arg0 = LuaDLL.lua_toboolean(L, 2); bool arg1 = LuaDLL.lua_toboolean(L, 3); UnityEngine.AudioClip o = obj.GetAudioClip(arg0, arg1); ToLua.Push(L, o); return(1); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.WWW), typeof(bool), typeof(bool), typeof(UnityEngine.AudioType))) { UnityEngine.WWW obj = (UnityEngine.WWW)ToLua.ToObject(L, 1); bool arg0 = LuaDLL.lua_toboolean(L, 2); bool arg1 = LuaDLL.lua_toboolean(L, 3); UnityEngine.AudioType arg2 = (UnityEngine.AudioType)ToLua.ToObject(L, 4); UnityEngine.AudioClip o = obj.GetAudioClip(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.WWW.GetAudioClip")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/* --- TTS via Google Translate --- */ IEnumerator Start() { //Remove the "spaces" in excess Regex rgx = new Regex ("\\s+"); //Replace the "spaces" with "% 20" for the link can be interpreted string result = rgx.Replace (words, "%20"); string url = "http://translate.google.com/translate_tts?tl=en&q=" + result; WWW www = new WWW (url); yield return www; //get the processed sound from Google Translate audio.clip = www.GetAudioClip (false, false, AudioType.MPEG); audio.Play (); words = ""; }
public static void generateLevelFromFile(string filePath) { string[] splitedPath = filePath.Split ('\\'); string fileName = splitedPath [splitedPath.Length - 1]; string[] splitedFileName = fileName.Split ('.'); string musicName = splitedFileName[0]; Debug.Log (musicName); //USING WWW to load the audioclip in root/Musics string path = "file://" + Application.dataPath + "/../Musics/" + musicName + ".wav"; string LevelPath = Application.dataPath + "/../Levels/" + musicName + ".JSON"; if (!File.Exists (LevelPath)) { //TODO copier le fichier dans musics File.Copy (filePath, Application.dataPath + "/../Musics/" + musicName + ".wav"); //Debug.Log ("music : " + path); WWW www = new WWW (path); while (!www.isDone) { //Debug.Log ("loading music ..."); } AudioClip clip = www.GetAudioClip (false); float levelLength = 180.0f; //clip.length; depthCount = itemSpaceBase; List<Item> itemList = new List<Item> (); while (depthCount < levelLength) { itemList.Add (new Item (randomItemType (), (int)depthCount, Random.Range (-2.0f, 2.0f))); depthCount += Random.Range (itemSpaceMin, itemSpaceMax); } //clip.name = "zbra"; Level level = new Level (musicName, musicName, "undefined", itemList, false); LevelParser.saveLevelToFile (level); GameModel.ActualLevel = level; } else { GameModel.ActualLevel = LevelParser.parseLevelFile(musicName); } GameModel.CustomLevel = true; }
private IEnumerator LoadSound( string _animal) { if (audioEmitter == null) audioEmitter = GetComponentInChildren<AudioSource>(); if (audioEmitter != null) { while (audioEmitter.isPlaying) yield return null; string fileName = ApplicationScript.getDataFolder() + "audio/" + _animal + "_" + (int)ApplicationScript.current.currentLanguage + ".wav"; WWW www = new WWW("file://" + fileName); AudioClip clip = www.GetAudioClip(false); while (clip.loadState == AudioDataLoadState.Loading) yield return www; if (string.IsNullOrEmpty(www.error)) { audioEmitter.clip = www.GetAudioClip(false); clip.name = Path.GetFileName(fileName); } else Debug.LogWarning(www.error); } }
IEnumerator DownloadSong() { musicDownload = new WWW(musicUrl); yield return musicDownload; if (string.IsNullOrEmpty(musicDownload.error)) { Debug.Log((musicDownload.size / 1024) + " kbytes downloaded"); AudioClip ac = musicDownload.GetAudioClip(false, false); Jukebox.me.SetSong(ac); Jukebox.me.Play(); } else { Debug.Log("Cannot download file: " + musicDownload.error); } }
static int QPYX_GetAudioClip_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 1) { UnityEngine.WWW QPYX_obj_YXQP = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L_YXQP, 1); UnityEngine.AudioClip QPYX_o_YXQP = QPYX_obj_YXQP.GetAudioClip(); ToLua.PushSealed(L_YXQP, QPYX_o_YXQP); return(1); } else if (QPYX_count_YXQP == 2) { UnityEngine.WWW QPYX_obj_YXQP = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L_YXQP, 1); bool QPYX_arg0_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 2); UnityEngine.AudioClip QPYX_o_YXQP = QPYX_obj_YXQP.GetAudioClip(QPYX_arg0_YXQP); ToLua.PushSealed(L_YXQP, QPYX_o_YXQP); return(1); } else if (QPYX_count_YXQP == 3) { UnityEngine.WWW QPYX_obj_YXQP = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L_YXQP, 1); bool QPYX_arg0_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 2); bool QPYX_arg1_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 3); UnityEngine.AudioClip QPYX_o_YXQP = QPYX_obj_YXQP.GetAudioClip(QPYX_arg0_YXQP, QPYX_arg1_YXQP); ToLua.PushSealed(L_YXQP, QPYX_o_YXQP); return(1); } else if (QPYX_count_YXQP == 4) { UnityEngine.WWW QPYX_obj_YXQP = (UnityEngine.WWW)ToLua.CheckObject <UnityEngine.WWW>(L_YXQP, 1); bool QPYX_arg0_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 2); bool QPYX_arg1_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 3); UnityEngine.AudioType QPYX_arg2_YXQP = (UnityEngine.AudioType)ToLua.CheckObject(L_YXQP, 4, typeof(UnityEngine.AudioType)); UnityEngine.AudioClip QPYX_o_YXQP = QPYX_obj_YXQP.GetAudioClip(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP); ToLua.PushSealed(L_YXQP, QPYX_o_YXQP); return(1); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.WWW.GetAudioClip")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
IEnumerator startStream() { _audioSource.Stop(); WWW audioStream = new WWW(audioStreamSource); AudioClip clip = audioStream.GetAudioClip(true,true); _audioSource.clip = clip; if(!streamEarly) { while(!clip.isReadyToPlay) yield return new WaitForSeconds(0.5f); _audioSource.Play(); } }
IEnumerator playRequestCoroutine(string request) { WWW www = new WWW(request); yield return www; try { Debug.Log("Got result " + www.text); source.clip = www.GetAudioClip(false,true, AudioType.WAV); source.Play(); } catch (Exception e) { Debug.Log("Error retrieving result (" + e.Message + "), www data :" + www.text); } }
public void Init() { if (musicName != null) { audioSource = GetComponent<AudioSource>(); samples = new float[size]; //clip = Resources.Load ("Musics/" + musicName, typeof(AudioClip)) as AudioClip; //USING WWW to load the audioclip in root/Musics string path = "file://" + Application.dataPath + "/../Musics/" + musicName + ".wav"; //Debug.Log ("music : " + path); WWW www = new WWW(path); while (!www.isDone) { //Debug.Log ("loading music ..."); } clip = www.GetAudioClip(false); audioSource.clip = clip; // create the texture and assign to the guiTexture: img = (RawImage) image.GetComponent<RawImage>(); cursorImg = (RawImage) cursor.GetComponent<RawImage>(); width = (int) GetComponent<RectTransform>().rect.width; height = (int)GetComponent<RectTransform>().rect.height; texture = new Texture2D(width, height); textureCursor = new Texture2D(width, height); img.texture = texture; cursorImg.texture = textureCursor; // create a 'blank screen' image blank = new Color[width * height]; for (var i = 0; i < blank.Length; i++) { blank[i] = backgroundColor; } textureCursor.SetPixels(blank, 0); textureCursor.Apply(); // refresh the display each 100mS GetWaveForm (); StartCoroutine (UpdateWaveForm ()); } }
static int get_audioClip(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.WWW obj = (UnityEngine.WWW)o; UnityEngine.AudioClip ret = obj.GetAudioClip(); ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index audioClip on a nil value" : e.Message)); } }
static public int GetAudioClip(IntPtr l) { try{ if (matchType(l, 2, typeof(System.Boolean))) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); UnityEngine.AudioClip ret = self.GetAudioClip(a1); pushValue(l, ret); return(1); } else if (matchType(l, 2, typeof(System.Boolean), typeof(System.Boolean))) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); UnityEngine.AudioClip ret = self.GetAudioClip(a1, a2); pushValue(l, ret); return(1); } else if (matchType(l, 2, typeof(System.Boolean), typeof(System.Boolean), typeof(UnityEngine.AudioType))) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); UnityEngine.AudioType a3; checkEnum(l, 4, out a3); UnityEngine.AudioClip ret = self.GetAudioClip(a1, a2, a3); pushValue(l, ret); return(1); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public void AddLayer() { //Read the inpute from the available fields string fileName = fileNameField.text; int totalTracks = int.Parse(totalTracksField.text); filePath = filePathField.text; outputText.text = "Tracks Added : \n"; LayerListText.text += "\n\t" + (++LayerNumber)+ " " + fileName + " (" + totalTracks + " tracks)"; //Create a new Layer in the player lastLayer = playerAudio.AddComponent<Layer>(); Layer newLayer = lastLayer; newLayer.layername = fileName; newLayer.audioTracks = new AudioClip[totalTracks]; //This is required to load audio WWW wtf; for (int i = 1; i <= totalTracks; i++) { string index = "00" + i; index = index.Substring(index.Length - 2); outputText.text += fileName + index + ".wav" +"\n"; //temporary handle AudioClip clip; //Load the Audio wtf = new WWW("file:///"+filePath + fileName + index + ".wav"); clip = wtf.GetAudioClip(false); clip.name = fileName + i.ToString(); newLayer.audioTracks[i - 1] = clip; } refreshed = false; if (lastLayer != null) removeButton.SetActive(true); //Reset the values in the layer newLayer.restartLayer(); }
IEnumerator playradio() { Debug.Log("rrr"); yield return new WaitForSeconds(0.1f); Debug.Log("rrr1"); CommandLine(vlcexe, convert); yield return new WaitForSeconds(3f); Debug.Log("rrr2"); wwwData = new WWW(url); audio.clip = wwwData.GetAudioClip(true,true); a=true; while(!audio.clip.isReadyToPlay){yield return null;} Debug.Log("rrr4"); audio.Play(); //yield return StartCoroutine("retour"); }
public MechJebModuleJoke(MechJebCore core) : base(core) { hidden = true; enabled = true; sorry = core.part.gameObject.AddComponent<AudioSource>(); WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MechJebPod/snd1.wav"); if ((sorry != null) && (www != null)) { sorry.clip = www.GetAudioClip(false); sorry.volume = 0; sorry.Stop(); } glitch = core.part.gameObject.AddComponent<AudioSource>(); glitchClips = new AudioClip[NUM_GLITCH_SOUNDS]; for (int i = 0; i < NUM_GLITCH_SOUNDS; i++) { www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MechJebPod/glitch" + i + ".wav"); if (www != null) { glitchClips[i] = www.GetAudioClip(false); } } foreach (ComputerModule module in core.modules) { if (module is MechJebModuleAscentAutopilot) { ascent = (MechJebModuleAscentAutopilot)module; } if (module is MechJebModuleLandingAutopilot) { landing = (MechJebModuleLandingAutopilot)module; } if (module is MechJebModuleTranslatron) { translatron = (MechJebModuleTranslatron)module; } } }
IEnumerator Load() { string url = "file://" + Application.dataPath + "/Mods/Resources/EventMod/Music/bensound-theelevatorbossanova.wav"; WWW www = new WWW(url); yield return www; elevator = www.GetAudioClip(false); audioSource = gameObject.AddComponent<AudioSource>(); audioSource.enabled = true; audioSource.volume = 0.9f; audioSource.loop = false; audioSource.priority = 10; audioSource.mute = false; audioSource.bypassEffects = true; audioSource.pitch = 0; audioSource.rolloffMode = AudioRolloffMode.Linear; audioSource.minDistance = 100; audioSource.maxDistance = 1000; audioSource.playOnAwake = false; audioSource.clip = elevator; audioSource.Play(); }
private IEnumerator LoadAudioClipCouroutine(DirectoryInfo dInfo, SuccessCallbackEvent<AudioClip> OnSuccess, FailCallbackEvent OnFail) { List<AudioClip> audios = new List<AudioClip>(); //ler todas as imagens da pasta foreach (FileInfo fi in dInfo.GetFiles("*.ogg", SearchOption.AllDirectories)) { WWW www = new WWW("file:///" + fi.FullName); // Start a download of the given URL yield return www; // Wait for download to complete //print("Imagem carregada em: " + fi.FullName); AudioClip audio = www.GetAudioClip(false, true, AudioType.OGGVORBIS); audio.name = fi.Name.Split('.')[0]; audios.Add(audio); } if (audios.Count == 0) { OnFail(new UnityException("Nenhum audio clip encontrado na pasta.")); } OnSuccess(audios.ToArray()); }
static int _m_GetAudioClip(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 1) { UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClip( ); translator.Push(L, __cl_gen_ret); return(1); } if (__gen_param_count == 2 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)) { bool threeD = LuaAPI.lua_toboolean(L, 2); UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClip(threeD); translator.Push(L, __cl_gen_ret); return(1); } if (__gen_param_count == 3 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3)) { bool threeD = LuaAPI.lua_toboolean(L, 2); bool stream = LuaAPI.lua_toboolean(L, 3); UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClip(threeD, stream); translator.Push(L, __cl_gen_ret); return(1); } if (__gen_param_count == 4 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3) && translator.Assignable <UnityEngine.AudioType>(L, 4)) { bool threeD = LuaAPI.lua_toboolean(L, 2); bool stream = LuaAPI.lua_toboolean(L, 3); UnityEngine.AudioType audioType; translator.Get(L, 4, out audioType); UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClip(threeD, stream, audioType); translator.Push(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 UnityEngine.WWW.GetAudioClip!")); }
public static AudioClip GetAudioClip(this WWW www, bool threeD, bool stream) { return(www.GetAudioClip(threeD, stream)); }
static public int GetAudioClip(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); var ret = self.GetAudioClip(); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 2) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); var ret = self.GetAudioClip(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 3) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); var ret = self.GetAudioClip(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 4) { UnityEngine.WWW self = (UnityEngine.WWW)checkSelf(l); System.Boolean a1; checkType(l, 2, out a1); System.Boolean a2; checkType(l, 3, out a2); UnityEngine.AudioType a3; a3 = (UnityEngine.AudioType)LuaDLL.luaL_checkinteger(l, 4); var ret = self.GetAudioClip(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function GetAudioClip to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public void Play(TimeSpan?startOff = null) { #if uAudio_debug UnityEngine.Debug.LogWarning("&c&"); #endif if (State != uAudio_backend.PlayBackState.Playing) { #if uAudio_debug UnityEngine.Debug.LogWarning("&d&"); #endif if (State == uAudio_backend.PlayBackState.Paused) { Pause(); } else { State = uAudio_backend.PlayBackState.Playing; try { //LoadFile(targetFile); #if uAudio_debug UnityEngine.Debug.LogWarning("B"); #endif SongDone = false; flare_SongEnd = false; UAudio.targetFile = targetFile; if (myAudioSource.clip == null) { #if uAudio_debug UnityEngine.Debug.LogWarning("%B1%"); #endif if (UAudio.LoadMainOutputStream()) { #if uAudio_debug UnityEngine.Debug.LogWarning("%B2%"); #endif #if !UNITY_STANDALONE_WIN && blank //WWW w = new WWW(targetFile); //int song_sampleSize; //SongReadLoop = new AudioClip.PCMReaderCallback(Song_Stream_Loop); #if uAudio_debug UnityEngine.Debug.LogWarning("%B4%"); #endif //song_sampleSize = (int)UAudio.uwa.audioPlayback.TotalSamples; #if uAudio_debug UnityEngine.Debug.LogWarning("%B5%"); #endif if (!targetFile.StartsWith("file://")) { targetFile = "file://" + targetFile; } var www = new UnityEngine.WWW(targetFile); UnityEngine.AudioClip myAudioClip = www.GetAudioClip(true, false, UnityEngine.AudioType.MPEG); // UnityEngine.AudioType.MPEG); // yield return www; // Next line hangs var clip = myAudioClip; int i = 100; // todo : check this -=---> clip.loadState != UnityEngine.AudioDataLoadState.Loaded #if !UNITY_2_6 && !UNITY_2_6_1 && !UNITY_3_0 && !UNITY_3_0_0 && !UNITY_3_1 && !UNITY_3_2 && !UNITY_3_3 && !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 && !UNITY_4_6 && !UNITY_4_7 while (clip.loadState != UnityEngine.AudioDataLoadState.Loaded && i > 0) #endif { i--; System.Threading.Thread.Sleep(10); } myAudioSource.clip = clip; #else #if !UNITY_STANDALONE_WIN && !UNITY_EDITOR if (!targetFile.StartsWith("file://")) { targetFile = "file://" + targetFile; } #endif long song_sampleSize; #if uAudio_debug UnityEngine.Debug.LogWarning("%B3%"); #endif AudioClip.PCMReaderCallback SongReadLoop; SongReadLoop = new AudioClip.PCMReaderCallback(Song_Stream_Loop); System.IO.Stream s = System.IO.File.OpenRead(targetFile); if (readFullyStream != null) { readFullyStream.Dispose(); } readFullyStream = new uAudioDemo.Mp3StreamingDemo.ReadFullyStream(s); readFullyStream.stream_CanSeek = true; byte[] buff = new byte[1024]; NLayer.MpegFile c = new NLayer.MpegFile(readFullyStream, true); //playbackDevice = m; if (startOff == TimeSpan.Zero) { c.ReadSamples(buff, 0, buff.Length); } playbackDevice = c; // UAudio.TotalTime // song_sampleSize = playbackDevice.Length;// * playbackDevice.SampleRate; song_sampleSize = UAudio.SongLength; // hack // song_sampleSize = int.MaxValue;// need to better alocate this int setSongSize; if (song_sampleSize > int.MaxValue) { UnityEngine.Debug.LogWarning("uAudioPlayer - Song size over size on int #4sgh54h45h45"); setSongSize = int.MaxValue; } else { setSongSize = (int)song_sampleSize; } myAudioSource.clip = UnityEngine.AudioClip.Create("uAudio_song", setSongSize, c.WaveFormat.Channels, c.WaveFormat.SampleRate, true, SongReadLoop); if (!startOff.HasValue) { CurrentTime = TimeSpan.Zero; } else { CurrentTime = startOff.Value; } #endif try { if (sendPlaybackState != null) { sendPlaybackState(uAudio_backend.PlayBackState.Playing); } } catch { UnityEngine.Debug.LogWarning("theAudioStream_sendStartLoopPump #32fw46hw465h45h"); } #if uAudio_debug UnityEngine.Debug.LogWarning("%B6%"); #endif } else { myAudioSource.clip = null; } } else { #if uAudio_debug UnityEngine.Debug.LogWarning("%B!%"); #endif } if (myAudioSource.clip != null) { #if uAudio_debug UnityEngine.Debug.LogWarning("%B7%"); #endif if (!myAudioSource.isPlaying) { myAudioSource.Play(); } #if uAudio_debug UnityEngine.Debug.LogWarning("%B8%"); #endif updateTime = true; } else { State = uAudio_backend.PlayBackState.Stopped; } } catch (System.Exception ex) { #if uAudio_debug UnityEngine.Debug.LogWarning("%B9%" + System.Environment.NewLine + ex.Message); #endif State = uAudio_backend.PlayBackState.Stopped; UnityEngine.Debug.LogWarning("uAudioPlayer - Play #j356j536j356j56j"); UnityEngine.Debug.LogWarning(ex); } } } }
public static AudioClip GetAudioClip(this WWW www, bool threeD) { return(www.GetAudioClip(threeD, false, AudioType.UNKNOWN)); }
public static AudioClip GetAudioClip(this WWW www) { return(www.GetAudioClip()); }
public static AudioClip GetAudioClip(this WWW www, bool threeD, bool stream, AudioType audioType) { return(www.GetAudioClip(threeD, stream, audioType)); }
public static AudioClip GetAudioClip(this WWW www) { return(www.GetAudioClip(true, false, AudioType.UNKNOWN)); }
public static AudioClip GetAudioClip(this WWW www, bool threeD) { return(www.GetAudioClip(threeD)); }