public AudioSettingsViewModel(PropertyAudioViewModel property, TrackableViewModel parent) : base(property, parent) { AudioSources.AddRange(AudioHelper.GetAudioSources()); UpdateAudioSourcesCommand = new Prism.Commands.DelegateCommand(UpdateSources); }
/* * public void Play(Color colour, float velocity = 10, float length = 1, float speed = 1) * { * if (PianoKeyController.ShowMIDIChannelColours) * { * _colour = colour; * } * * this.Play(velocity, length, speed); * } */ #endregion //WE NEED TO CHECK THIS IENUMERATOR BECAUSE ROTATION AFFECTS VOLUME AND WE DON'T NEED ROTATION.. //UPDATE :: Apparently this was only for KayMode.Physical #region [------------ THE VOLUME DEPENDS OF THE ROTATION OF THE KEY BUT WE DONT HAVE A PIANO KEY..------------] /* * [Obsolete("We need to check this Ienumerator")] * IEnumerator PlayPressedAudio() * { * if (!PianoKeyController.NoMultiAudioSource && CurrentAudioSource.isPlaying) * { * bool foundReplacement = false; * int index = AudioSources.IndexOf(CurrentAudioSource); * * for (int i = 0; i < AudioSources.Count; i++) * { * if (i != index && (!AudioSources[i].isPlaying || AudioSources[i].volume <= 0)) * { * foundReplacement = true; * CurrentAudioSource = AudioSources[i]; * _toFade.Remove(AudioSources[i]); * break; * } * } * * if (!foundReplacement) * { * AudioSource newAudioSource = CloneAudioSource(); * AudioSources.Add(newAudioSource); * CurrentAudioSource = newAudioSource; * } * * _toFade.Add(AudioSources[index]); * } * * _startAngle = transform.eulerAngles.x; * * yield return new WaitForFixedUpdate(); * yield return new WaitForFixedUpdate(); // two yields in a row? mmm wtf okay.. * * * if (Mathf.Abs(_startAngle - transform.eulerAngles.x) > 0) * { * CurrentAudioSource.volume = Mathf.Lerp(0, 1, Mathf.Clamp((Mathf.Abs(_startAngle - transform.eulerAngles.x) / 2f), 0, 1)); * } * * CurrentAudioSource.Play(); * } */ #endregion void PlayVirtualAudio() { if (!PianoKeyController.NoMultiAudioSource && CurrentAudioSource.isPlaying) { bool foundReplacement = false; int index = AudioSources.IndexOf(CurrentAudioSource); for (int i = 0; i < AudioSources.Count; i++) { if (i != index && (!AudioSources[i].isPlaying || AudioSources[i].volume <= 0)) { foundReplacement = true; CurrentAudioSource = AudioSources[i]; _toFade.Remove(AudioSources[i]); break; } } if (!foundReplacement) { AudioSource newAudioSource = CloneAudioSource(); AudioSources.Add(newAudioSource); CurrentAudioSource = newAudioSource; } _toFade.Add(AudioSources[index]); } CurrentAudioSource.volume = _velocity / 127f; CurrentAudioSource.Play(); }
public void UpdateSources() { AudioSources.Clear(); AudioSources.AddRange(AudioHelper.GetAudioSources(true)); ((PropertyAudioViewModel)this.Property).SelectedSource = AudioSources.FirstOrDefault(); }
// Use this for initialization void Awake () { if (audioSourcesInstance == null) { audioSourcesInstance = this; DontDestroyOnLoad(transform.root.gameObject); } else { Destroy (gameObject); } }
//Remove a HDR audio source to the collection public void RemoveAudioSource(HDRAudioSource source) { int index = AudioSources.FindIndex(p => p.Audio == source); if (index != -1) { AudioSources.RemoveAt(index); } }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (FriendlyName != null) { p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName)); } if (Enabled != null) { p.Add(new KeyValuePair <string, string>("Enabled", Enabled.Value.ToString().ToLower())); } if (VideoLayout != null) { p.Add(new KeyValuePair <string, string>("VideoLayout", Serializers.JsonObject(VideoLayout))); } if (AudioSources != null) { p.AddRange(AudioSources.Select(prop => new KeyValuePair <string, string>("AudioSources", prop))); } if (AudioSourcesExcluded != null) { p.AddRange(AudioSourcesExcluded.Select(prop => new KeyValuePair <string, string>("AudioSourcesExcluded", prop))); } if (Trim != null) { p.Add(new KeyValuePair <string, string>("Trim", Trim.Value.ToString().ToLower())); } if (Format != null) { p.Add(new KeyValuePair <string, string>("Format", Format.ToString())); } if (Resolution != null) { p.Add(new KeyValuePair <string, string>("Resolution", Resolution)); } if (StatusCallback != null) { p.Add(new KeyValuePair <string, string>("StatusCallback", Serializers.Url(StatusCallback))); } if (StatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("StatusCallbackMethod", StatusCallbackMethod.ToString())); } return(p); }
private ExtendedAudioSource CreateAudioInstance(int index = 1) { var go = new GameObject("AudioInstance " + index, typeof(ExtendedAudioSource)); var source = go.GetComponent <ExtendedAudioSource>(); go.transform.SetParent(Trans); AudioSources.Add(source); go.SetActive(false); return(source); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
// Use this for initialization void Awake() { if (audioSourcesInstance == null) { audioSourcesInstance = this; DontDestroyOnLoad(transform.root.gameObject); } else { Destroy(gameObject); } }
public ExtendedAudioSource GetAudioSource() { foreach (var source in AudioSources.Where(source => source.isPlaying == false)) { source.gameObject.SetActive(true); ActiveAudioSources.Add(source); return(source); } var newSource = CreateAudioInstance(); newSource.gameObject.SetActive(true); return(newSource); }
// Use this for initialization void Awake() { if (instance == null) { instance = this; audioSources = GetComponents <AudioSource>(); DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public void Remove(SourceComponent audioSource) { SoundToolKitDebug.Assert(audioSource != null, "Source component is null"); if (AudioSources.Contains(audioSource)) { m_audioSources.Remove(audioSource); } else { SoundToolKitDebug.LogWarning("Source component wasn't registered."); } }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (AudioSources != null) { p.AddRange(AudioSources.Select(prop => new KeyValuePair <string, string>("AudioSources", prop.ToString()))); } if (VideoSources != null) { p.AddRange(VideoSources.Select(prop => new KeyValuePair <string, string>("VideoSources", prop.ToString()))); } if (VideoLayout != null) { p.Add(new KeyValuePair <string, string>("VideoLayout", VideoLayout.ToString())); } if (Resolution != null) { p.Add(new KeyValuePair <string, string>("Resolution", Resolution)); } if (Format != null) { p.Add(new KeyValuePair <string, string>("Format", Format.ToString())); } if (DesiredBitrate != null) { p.Add(new KeyValuePair <string, string>("DesiredBitrate", DesiredBitrate.Value.ToString())); } if (DesiredMaxDuration != null) { p.Add(new KeyValuePair <string, string>("DesiredMaxDuration", DesiredMaxDuration.Value.ToString())); } if (StatusCallback != null) { p.Add(new KeyValuePair <string, string>("StatusCallback", Serializers.Url(StatusCallback))); } if (StatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("StatusCallbackMethod", StatusCallbackMethod.ToString())); } return(p); }
private void UpdateAudioSources() { var selectedId = GetSceneAudio(false)?.Source?.DeviceName?.DeviceId; ListHelper.UpdateCollection(CoreData, _sceneState.Device.AudioInputs.Values.OrderBy(s => s.Name).ToList(), AudioSources, s => s.Id, (s, id) => new AudioSourceModel(id, s, () => Select(id), new Property <bool>())); AudioSources.ToList().ForEach(s => s.IsSelected.Value = s.Id == selectedId); }
// Use this for initialization void Awake() { if (audioSourcesInstance == null) { audioSourcesInstance = this; //当加载一个新关卡时,所有场景中所有的物体被销毁,然后新关卡中的物体被加载进来。为了保持在加载新关卡时物体不被销毁,使用DontDestroyOnLoad保持,如果物体是一个组件或游戏物体,它的整个transform层次将不会被销毁,全部保留下来。 //加载新场景的时候使目标物体不被自动销毁 DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public void Initialize() { var matches = Assembly.GetExecutingAssembly() .GetTypes() .Where(x => typeof(BaseSourceProvider).IsAssignableFrom(x) && !x.IsAbstract) .ToArray(); LogHandler <SourceHandler> .Log.Debug($"Discovered {matches.Length} SourceProviders."); foreach (var match in matches) { Singleton.Add(match); } _sources = Singleton.Of <Configuration>().Sources; _cache = Singleton.Of <CacheHandler>(); }
void Awake() { ambientSource = GetComponent <AudioSource>(); shootSources = new AudioSources(shootSoundSources, gameObject); pickupSources = new AudioSources(pickupSoundSources, gameObject); boundarySources = new AudioSources(boundarySoundSources, gameObject); explosionSource = new AudioSources(1, gameObject); shootSources.clip = shootSound; pickupSources.clip = pickupSound; boundarySources.clip = boundarySound; explosionSource.clip = explosionSound; shootSources.mixerGroup = effectsGroup; pickupSources.mixerGroup = effectsGroup; boundarySources.mixerGroup = effectsGroup; explosionSource.mixerGroup = effectsGroup; }
public void Add(SourceComponent audioSource) { // <STK.LITE> - Why are we even here? if (AudioSources.Count >= StkLite.AvailableSources()) { return; } // </STK.LITE> SoundToolKitDebug.Assert(audioSource != null, "Source component is null"); if (!AudioSources.Contains(audioSource)) { m_audioSources.Add(audioSource); } else { SoundToolKitDebug.LogWarning("Source component already registered."); } }
IEnumerator PlayPressedAudio() { if (!PianoKeyController.NoMultiAudioSource && CurrentAudioSource.isPlaying) { bool foundReplacement = false; int index = AudioSources.IndexOf(CurrentAudioSource); for (int i = 0; i < AudioSources.Count; i++) { if (i != index && (!AudioSources[i].isPlaying || AudioSources[i].volume <= 0)) { foundReplacement = true; CurrentAudioSource = AudioSources[i]; _toFade.Remove(AudioSources[i]); break; } } if (!foundReplacement) { AudioSource newAudioSource = CloneAudioSource(); AudioSources.Add(newAudioSource); CurrentAudioSource = newAudioSource; } _toFade.Add(AudioSources[index]); } _startAngle = transform.eulerAngles.x; yield return(new WaitForFixedUpdate()); yield return(new WaitForFixedUpdate()); if (Mathf.Abs(_startAngle - transform.eulerAngles.x) > 0) { CurrentAudioSource.volume = Mathf.Lerp(0, 1, Mathf.Clamp((Mathf.Abs(_startAngle - transform.eulerAngles.x) / 2f), 0, 1)); } CurrentAudioSource.Play(); }
public virtual void Start() { audioSources = GetComponent <AudioSources>(); }
//Add a HDR audio source to the collection, don't add the same twice public void AddAudioSource(HDRAudioSource source) { AudioSources.Add(new HDRAudio.AudioTuple(source)); }
void SetActiveSource(AudioSources src) { if ((int)AudioSources.SOURCE_MAX != activeSource) source[activeSource].Stop(); activeSource = (int)src; source[activeSource].Play(); }
void Awake() { if (Instance != null) throw new UnityException("More than one AudioSources component right now!"); Instance = this; }
private async void Ws_SceneChanged(SLOBSWebsocket sender, SLOBSSceneEvent eventdata) { if (eventdata.Type == ESLOBSEventType.SceneAdded) { SOBSScene item = _translateScene(eventdata.Scene); Scenes.Add(item); if (SceneChanged != null) { SceneChanged(this, EOBSEvent.SceneAdded, item); } } else if (eventdata.Type == ESLOBSEventType.SceneRemoved) { int reindex = 0; SOBSScene item = _translateScene(eventdata.Scene); for (int i = 0; i < Scenes.Count; i++) { if (Scenes[i].Id == eventdata.Scene.Id) { Scenes.RemoveAt(i); } else { var scene = Scenes[i]; scene.Index = reindex; Scenes[i] = scene; reindex++; } } if (SceneChanged != null) { SceneChanged(this, EOBSEvent.SceneRemoved, item); } } else if (eventdata.Type == ESLOBSEventType.SceneSwitched) { if (!_setActiveScene(eventdata.Scene)) { var ascenes = await ws.ListScenes(); Scenes.Clear(); Scenes = _translateScenes(ascenes); _setActiveScene(eventdata.Scene); } var audio = await ws.ListAudioSources(); AudioSources.Clear(); AudioSources = _translateAudioSources(audio); if (AudioSourceChanged != null) { AudioSourceChanged(this, EOBSEvent.SourceAdded); } if (SceneChanged != null) { SceneChanged(this, EOBSEvent.SceneSwitched, ActiveScene); } } else if (eventdata.Type == ESLOBSEventType.SceneCollectionChanged) { var ascenes = await ws.ListScenes(); Scenes.Clear(); Scenes = _translateScenes(ascenes); var active_scene = await ws.GetActiveScene(); if (active_scene != null) { for (int i = 0; i < Scenes.Count; i++) { if (Scenes[i].Id == ((SLOBSScene)active_scene).Id) { ActiveScene = Scenes[i]; } } } if (SceneChanged != null) { SceneChanged(this, EOBSEvent.SceneUpdated, ActiveScene); } } }
private async void Ws_SourceChanged(SLOBSWebsocket sender, SLOBSSourceEvent eventdata) { if (eventdata.Type == ESLOBSEventType.SourceAdded) { var sourceItem = _translateSource(eventdata.Source, Sources.Count + 1); Sources.Add(sourceItem); if (SourceChanged != null) { SourceChanged(this, EOBSEvent.SourceAdded, sourceItem); } //Audio item if (sourceItem.Audio) { var audio = await ws.ListAudioSources(); AudioSources.Clear(); AudioSources = _translateAudioSources(audio); if (AudioSourceChanged != null) { AudioSourceChanged(this, EOBSEvent.SourceAdded); } } } else if (eventdata.Type == ESLOBSEventType.SourceRemoved) { var sourceItem = _translateSource(eventdata.Source, 0); int reindex = 0; for (int i = 0; i < Sources.Count; i++) { if (Sources[i].Id == eventdata.Source.Id) { Sources.RemoveAt(i); sourceItem.Index = i; if (SourceChanged != null) { SourceChanged(this, EOBSEvent.SourceRemoved, sourceItem); //audio item if (sourceItem.Audio) { for (int ia = 0; ia < AudioSources.Count; ia++) { if (AudioSources[i].SourceId == sourceItem.Id) { AudioSources.RemoveAt(ia); if (AudioSourceChanged != null) { AudioSourceChanged(this, EOBSEvent.SourceUpdated); } } } } } } else { var source = Sources[i]; source.Index = reindex; Sources[i] = source; reindex++; } } } else if (eventdata.Type == ESLOBSEventType.SourceUpdated) { var sourceItem = _translateSource(eventdata.Source, 0); for (int i = 0; i < Sources.Count; i++) { if (Sources[i].Id == eventdata.Source.Id) { sourceItem.Index = i; Sources[i] = sourceItem; if (SourceChanged != null) { SourceChanged(this, EOBSEvent.SourceUpdated, sourceItem); } //audio item if (sourceItem.Audio) { var audio = await ws.ListAudioSources(); AudioSources.Clear(); AudioSources = _translateAudioSources(audio); if (AudioSourceChanged != null) { AudioSourceChanged(this, EOBSEvent.SourceUpdated); } } } } } }