public static AudioSource SetClip(AudioBundle bundle, string audioName, AudioSourceType source = AudioSourceType.SFX) { AudioClip clip = GetClip(bundle, audioName); GetSource(source).clip = clip; return(SFXSource); }
public AudioAsset CreateAudioAssetByPool(GameObject gameObject, bool is3D, AudioSourceType sourceType) { AudioAsset au = null; if (audioAssetsPool.Count > 0) { au = audioAssetsPool.Dequeue(); au.ResetData(); } else { au = new AudioAsset(); au.audioSource = gameObject.AddComponent <AudioSource>(); } au.audioSource.spatialBlend = is3D ? 1 : 0; au.sourceType = sourceType; if (sourceType == AudioSourceType.Music) { au.TotleVolume = musicVolume; } else { au.TotleVolume = sfxVolume; } return(au); }
public void TestSourceType() { bool tested = false; AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.ClassicAudioMain, helper => { var rawCommands = helper.Server.GetParsedDataDump(); IEnumerable <long> useIds = helper.Helper.BuildLibState().Audio.Inputs.Keys.ToList(); foreach (long id in useIds) { tested = true; AtemState stateBefore = helper.Helper.BuildLibState(); var inputState = stateBefore.Audio.Inputs[id].Properties; var srcCommand = RawGetCommand(rawCommands, id); for (int i = 0; i < 5; i++) { AudioSourceType target = Randomiser.EnumValue <AudioSourceType>(); inputState.SourceType = target; srcCommand.SourceType = target; helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(srcCommand); }); } } }); Assert.True(tested); }
void OnEnable() { string currentDevice = string.Empty; //获取设备麦克风;如果没有激活的麦克风,则自动转换成音频 try { string[] devices = Microphone.devices; if (devices.Length <= 0) { throw new Exception("None of microphone devices was found!"); } currentDevice = devices[0]; } catch (Exception e) { m_AudioSourceType = AudioSourceType.audioSource; } //获取music音频源 p_spectrumSource = new AudioSpectrumSource(VisualizerCount, MusicSource, MicrophoneSource, DefaultMusicName, currentDevice); p_spectrumSource.ChangeSource(m_AudioSourceType); m_Visualizer = new FrankAudioVisualizer(GraphicVisualizer.transform); }
public static void Play(AudioBundle bundle, string audioName, AudioSourceType source = AudioSourceType.SFX, ulong delay = 0) { AudioClip clip = GetClip(bundle, audioName); GetSource(source).clip = clip; GetSource(source).Play(delay); }
/// <summary> /// 播放指定音效 /// </summary> /// <param name="audioSouce"></param> /// <param name="audioClip"></param> public void PlayAudioSource(AudioSourceType audioSouce, AudioClip audioClip) { switch (audioSouce) { case AudioSourceType.Default: if (audioSourcDefault.clip != audioClip) { audioSourcDefault.clip = audioClip; } audioSourcDefault.Play(); break; case AudioSourceType.Move: if (audioSourceMove.clip != audioClip) { audioSourceMove.clip = audioClip; } audioSourceMove.Play(); break; case AudioSourceType.BGM: if (audioSourceBGM.clip != audioClip) { audioSourceBGM.clip = audioClip; } audioSourceBGM.Play(); break; default: break; } }
public AudioSourceTileModel(string configuredName, string hardwareName, AudioSourceType sourceType, AudioSourceStatus status) { this.Id = Guid.NewGuid().ToString("N"); this.ConfiguredName = configuredName; this.HardwareName = hardwareName; this.SourceType = sourceType; this.Status = status; }
public void ChangeSource(AudioSourceType audioType) { if (p_AudioSourceType == audioType) { return; } p_AudioSourceType = audioType; UpdateAudioSource(); }
void CreateSource(AudioSourceType type, AudioBus bus) { ManagedAudioSource tempSource; tempSource = Instantiate(sourceObjectPrefab, transform).GetComponent <ManagedAudioSource>(); tempSource.type = type; tempSource.bus = bus; tempSource.SetParent(transform); tempSource.gameObject.SetActive(false); sources.Add(tempSource); }
private void SetPauseAudio(AudioSourceType audioSourceType, int sourceIndex, bool pause) { if (pause) { _audioSources[(int)audioSourceType][sourceIndex].Pause(); } else { _audioSources[(int)audioSourceType][sourceIndex].UnPause(); } }
/// <summary> /// 播放场景中的音乐 /// </summary> /// <param name="type"></param>音源的类型 /// <param name="clipName"></param>音效片段名称 public void PlayAudioClip(AudioSourceType type, string clipName) { AudioClip clipPlay = null; bool isExist = audioClipDic.TryGetValue(clipName, out clipPlay); if (isExist == false) { Debug.Log("Can't find the AduioClip need to play,AduioClip name is " + clipName + "!"); return; } switch (type) { case AudioSourceType._BGAudioSource: if (_BackgrounAS.clip == clipPlay) { return; //防止重复播放同一个背景音乐 } _BackgrounAS.clip = clipPlay; _BackgrounAS.Play(); _BackgrounAS.loop = true; // _BackgrounAS.volume = GlobalManager._BGAS_VolumeValue;//待定 break; case AudioSourceType._EffectAudioSource: _EffectAS.clip = clipPlay; _EffectAS.loop = false; // _EffectAS.volume = GlobalManager._EffectAS_VolumeValue; _EffectAS.Play(); break; case AudioSourceType._PlayerActionAS: _PlayerActionAS.clip = clipPlay; _PlayerActionAS.loop = false; // _PlayerActionAS.volume = GlobalManager._EffectAS_VolumeValue; _PlayerActionAS.Play(); break; case AudioSourceType._JsActionAS: _JsActionAS.loop = false; // _JsActionAS.volume = GlobalManager._EffectAS_VolumeValue; if (_JsActionAS.clip == clipPlay && _JsActionAS.clip != null) { _JsActionAS.Play(); } else { _JsActionAS.clip = clipPlay; _JsActionAS.Play(); } break; } }
private float GetVolume(AudioSourceType audioSourceType, float volume = 1f) { if (audioSourceType == AudioSourceType.Music) { return(_globalMasterVolume * _globalBGMVolume * _masterMuteVolume * _bgmMuteVolume * volume); } else { return(_globalMasterVolume * _globalSFXVolume * _masterMuteVolume * _sfxMuteVolume * volume); } }
public void SetMute(AudioSourceType audioSourceType, bool mute) { if (audioSourceType == AudioSourceType.Music) { _bgmIsMuted = mute; } else { _sfxIsMuted = mute; } }
public void InitInstance(string AudioPath, bool IsLooping, float Volume, AudioSourceType Type) { this.GetComponent <AudioSource>().clip = GetClip(AudioPath); this._Type = Type; SetVolume(Volume); this.GetComponent <AudioSource>().loop = IsLooping; this.GetComponent <AudioSource>().Play(); if (IsLooping == false) { StartCoroutine(waitForSound()); //Start Coroutine } }
private AudioSource GetAudioSource(AudioSourceType _audioSourceType) { //根据枚举类型的个数生成需要的空间个数 if (m_audioSource == null) { m_audioSource = new AudioSource[3]; for (int i = 0; i < 3; i++) { m_audioSource[i] = gameObject.AddComponent <AudioSource>(); } } return(m_audioSource[(int)_audioSourceType]); }
/// <summary> /// Plays any sound in the stored dictionary, on the specified audiosource /// </summary> public void PlaySound(AudioSourceType source, Sound soundToPlay) { //switch to determine which audiosource to use switch (source) { case AudioSourceType.Background: //check that the audiosource exists if (backroundAudioSource != null) { //stop whatever is already playing and play a new sound backroundAudioSource.Stop(); backroundAudioSource.PlayOneShot(SoundClips[soundToPlay], backgroundVolume); backroundAudioSource.volume = backgroundVolume; } break; case AudioSourceType.Effects: //check that the audiosource exists if (effectsAudioSource != null) { //stop whatever is already playing and play a new sound effectsAudioSource.Stop(); effectsAudioSource.PlayOneShot(SoundClips[soundToPlay], effectVolume); effectsAudioSource.volume = effectVolume; } break; case AudioSourceType.UI: //check that the audiosource exists if (UIAudioSource != null) { //stop whatever is already playing and play a new sound UIAudioSource.Stop(); UIAudioSource.PlayOneShot(SoundClips[soundToPlay], UIVolume); UIAudioSource.volume = UIVolume; } break; default: //check that the audiosource exists if (effectsAudioSource != null) { //stop whatever is already playing and play a new sound effectsAudioSource.Stop(); effectsAudioSource.PlayOneShot(SoundClips[soundToPlay], effectVolume); effectsAudioSource.volume = effectVolume; } break; } }
public AudioSource GetAudioSource(AudioSourceType audioSourceType) { switch (audioSourceType) { case AudioSourceType.Music: return(audioSourceMusic); case AudioSourceType.UI: return(audioSourceUI); case AudioSourceType.Effects: return(audioSourceEffects); default: return(audioSourceDefault); } }
ManagedAudioSource GetFreeSource(AudioBus priority, AudioSourceType sourceType) { ManagedAudioSource source = sources.Where(r => !r.gameObject.activeInHierarchy && r.type == sourceType).FirstOrDefault(); if (source == null) { source = sources.Where(r => r.bus < priority && r.type == sourceType).FirstOrDefault(); } if (source == null) { source = sources.Where(r => !r.gameObject.activeInHierarchy && r.bus != AudioBus.Music).FirstOrDefault(); source.type = sourceType; } if (source == null) { Debug.LogError("Insufficient Sources"); } return(source); }
/// <summary> /// 调节声音大小 /// </summary> /// <param name="type"></param>音源的类型 /// <param name="_value"></param>声音大小 public void SetVolumeValue(AudioSourceType type, float _value) { switch (type) { case AudioSourceType._BGAudioSource: // GlobalManager._BGAS_VolumeValue = _value; this._BGAS_VolumeValue = _value; _BackgrounAS.volume = this._BGAS_VolumeValue; break; case AudioSourceType._EffectAudioSource: // GlobalManager._EffectAS_VolumeValue = _value; this._EffectAS_VolumeValue = _value; _EffectAS.volume = this._EffectAS_VolumeValue; _PlayerActionAS.volume = this._EffectAS_VolumeValue; _JsActionAS.volume = this._EffectAS_VolumeValue; break; } }
// CALCULATE AN INSTANCE VOLUME WITH CURRENT PLAYER SETTINGS public float CalculateVolume(float BaseVolume, AudioSourceType Type) { switch (Type) { case AudioSourceType.Music: return(BaseVolume * _GeneralVolume * _MusicVolume); case AudioSourceType.Sound: return(BaseVolume * _GeneralVolume * _SoundVolume); case AudioSourceType.UI: return(BaseVolume * _GeneralVolume * _UIVolume); case AudioSourceType.Voice: return(BaseVolume * _GeneralVolume * _VoiceVolume);; default: return(BaseVolume * _GeneralVolume); } }
public void MuteSounds(AudioSourceType source) { switch (source) { case AudioSourceType.Background: backroundAudioSource.Stop(); break; case AudioSourceType.Effects: effectsAudioSource.Stop(); break; case AudioSourceType.UI: UIAudioSource.Stop(); break; default: effectsAudioSource.Stop(); break; } }
public ManagedAudioSource PlaySound(AudioSourceType sourceType, AudioClipInfoClass clipInfo, AudioBus priority, Transform sourceOrigin = null, bool loop = false) { if (ClipPlayedThisFrame(clipInfo.Clip)) { return(null); } ManagedAudioSource source = GetFreeSource(priority, sourceType); source.gameObject.SetActive(true); if (sourceOrigin != null) { source.SetParent(sourceOrigin); } source.SetAudioClipInfo(clipInfo); source.bus = priority; source.PlaySound(loop); AddClipPlayedLastFrame(clipInfo.Clip); UpdateActiveAudioVolumes(); return(source); }
public static AudioSource LoadAudioSource(AudioSourceType type, string filename) { string Audiotype = " "; if (string.IsNullOrEmpty(filename)) { Debug.Log("Loading AudioSource Failed!"); return(null); } if (type == AudioSourceType.BGM) { Audiotype = "BGM"; } else if (type == AudioSourceType.SE) { Audiotype = "SE"; } string filepath = string.Format("Sounds/{0}/{1}", Audiotype, filename); AudioSource audioSource = Resources.Load <AudioSource>(filename); return(audioSource); }
private void shuffle() { int count = this.m_astList.Count; if (count > 2) { AudioSourceType type; AudioSourceType type2 = this.m_astList[0]; for (int i = 0; i < count; i++) { int num3 = i + m_rnd.Next(count - i); type = this.m_astList[num3]; this.m_astList[num3] = this.m_astList[i]; this.m_astList[i] = type; } if (((AudioSourceType)this.m_astList[0]) == type2) { type = this.m_astList[0]; this.m_astList[0] = this.m_astList[count - 1]; this.m_astList[count - 1] = type; } } }
public void StopAudioSource(AudioSourceType audioSourceType) { GetAudioSource(audioSourceType).Stop(); }
public void FadeOutVolume(AudioSourceType audioSourceType, float time) { AudioSource source = GetAudioSource(audioSourceType); DOTween.To(() => source.volume, x => source.volume = x, 0, time); }
public void SetVolume(AudioSourceType audioSourceType, float volume) { GetAudioSource(audioSourceType).volume = volume; }
public AudioSourceTypeAttribute(AudioSourceType type) { Type = type; }
// CALL THIS FUNC TO PLAY A NEW UNIQUE ADUIO FILE // AudioManager.AddAudio("TEST", "Audio/Music/Confrontation/Confrontation_001", true, 1.0f, AudioSourceType.Music); public static void AddAudio(string AudioId, string AudioPath, bool IsLooping, float Volume, AudioSourceType Type) { CheckOrCreateManager().AddAudioFrk(AudioId, AudioPath, IsLooping, Volume, Type); }
// INTERNAL ADD AUDIO CALLED BY STATIC FUNC private void AddAudioFrk(string AudioId, string AudioPath, bool IsLooping, float Volume, AudioSourceType Type) { string FullPath = "Audio/AudioInstance"; GameObject Prefab = (GameObject)Resources.Load(FullPath, typeof(GameObject)) as GameObject; if (Prefab == null) { Debug.LogError("Audio Instance Prefab not Found !"); } GameObject Instance = Instantiate( Prefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject; Instance.transform.parent = this.transform; Instance.transform.name = AudioId; Instance.transform.position = Vector3.zero; Instance.GetComponent <AudioInstance>().InitInstance(AudioPath, IsLooping, Volume, Type); // return Instance.GetComponent<AudioInstance>(); }
// INTERNAL ADD AUDIO CALLED BY STATIC FUNC private void FindOrAddAudioFrk(string AudioId, string AudioPath, bool IsLooping, float Volume, AudioSourceType Type) { if (CheckAudioExist(AudioId) == false) { // ADD NEW AUDIO INSTANCE IF == NULL AddAudio(AudioId, AudioPath, IsLooping, Volume, Type); } else { // UPDATE AUDIO INSTANCE IF != NULL FindAudio(AudioId).InitInstance(AudioPath, IsLooping, Volume, Type); } }