/// <summary> /// Play one sound from a container based on container behavior. /// </summary> /// <param name="currentContainer"></param> /// <param name="activeEvent"></param> /// <returns>The estimated ActiveTime for the clip, or InfiniteLoop if the container and/or clip are set to loop.</returns> private float PlaySingleClip(AudioContainer currentContainer, ActiveEvent activeEvent) { float tempDelay = 0; if (currentContainer.ContainerType == AudioContainerType.Random) { currentContainer.CurrentClip = Random.Range(0, currentContainer.Sounds.Length); } UAudioClip currentClip = currentContainer.Sounds[currentContainer.CurrentClip]; // Trigger sound and save the delay (in seconds) to add to the total amount of time the event will be considered active. tempDelay = PlayClipAndGetTime(currentClip, activeEvent.PrimarySource, activeEvent); // Ready the next clip in the series if sequence container. if (currentContainer.ContainerType == AudioContainerType.Sequence) { currentContainer.CurrentClip++; if (currentContainer.CurrentClip >= currentContainer.Sounds.Length) { currentContainer.CurrentClip = 0; } } // Return active time based on Looping or clip time. return(GetActiveTimeEstimate(currentClip, activeEvent, tempDelay)); }
public Rmh_Customise() { SaveInMenu = true; SaveOnSceneSwitch = true; EnableExpGainedPopup = true; EnableLevelReachedPopup = true; PersistGameObjectInfo = true; SaveEnemyStatus = true; SaveGameObjectPosition = true; SaveGameObjectRotation = true; SaveGameObjectDestroyed = true; SaveGameObjectEnabled = true; WorldMapLocations = new List <WorldArea>(); GameHasAchievements = true; AchievementUnlockedSound = new AudioContainer(); LoadingScreen = new ImageContainer(); TopDownHeight = 10; TopDownDistance = 10; CameraXOffset = 0; CameraYOffset = 0; CameraZOffset = 0; PressBothMouseButtonsToMove = true; RotateCameraWithPlayer = true; EnableOrbitPlayer = true; OrbitPlayerOption = ClickOption.Left; EnableClickToRotate = true; ClickToRotateOption = ClickOption.Right; TooltipFollowsCursor = true; }
public AudioContainer AchievementUnlocked; //todo: remove public Rmh_Questing() { ShowQuestMarkers = true; QuestComplete = new AudioContainer(); QuestStarted = new AudioContainer(); AchievementUnlocked = new AudioContainer(); }
/// <summary> /// Play a non-continuous container. /// </summary> private float PlayOneOffContainer(ActiveEvent activeEvent) { AudioContainer currentContainer = activeEvent.AudioEvent.Container; // Fading or Looping overrides immediate volume settings. if (activeEvent.AudioEvent.FadeInTime == 0 && !activeEvent.AudioEvent.Container.Looping) { activeEvent.VolDest = activeEvent.PrimarySource.volume; } // Simultaneous sounds. float clipTime = 0; if (currentContainer.ContainerType == AudioContainerType.Simultaneous) { clipTime = PlaySimultaneousClips(currentContainer, activeEvent); } // Sequential and Random sounds. else { clipTime = PlaySingleClip(currentContainer, activeEvent); } activeEvent.ActiveTime = clipTime; return(clipTime); }
/// <summary> /// Play all clips in container simultaneously /// </summary> private float PlaySimultaneousClips(AudioContainer currentContainer, ActiveEvent activeEvent) { float tempDelay = 0; float finalActiveTime = 0f; if (currentContainer.Looping) { finalActiveTime = InfiniteLoop; } for (int i = 0; i < currentContainer.Sounds.Length; i++) { tempDelay = PlayClipAndGetTime(currentContainer.Sounds[i], activeEvent.PrimarySource, activeEvent); if (finalActiveTime != InfiniteLoop) { float estimatedActiveTimeNeeded = GetActiveTimeEstimate(currentContainer.Sounds[i], activeEvent, tempDelay); if (estimatedActiveTimeNeeded == InfiniteLoop || estimatedActiveTimeNeeded > finalActiveTime) { finalActiveTime = estimatedActiveTimeNeeded; } } } return(finalActiveTime); }
/// <summary> /// The first 10 items will be pplayed by its Audio Container /// </summary> /// <param name="item"></param> private static void OnTheFirst40Items(KeyValuePair <string, AudioReport> item) { //if is there will be set to a NewLevel() if (_audioContainers.ContainsKey(item.Key)) { _audioContainers[item.Key].Play(item.Value.AverageDistance()); } //Other wise will be spawned else { if (!_roots.ContainsKey(item.Key)) { return; } if (string.IsNullOrEmpty(_roots[item.Key])) { _roots[item.Key] = DefineRoot(item.Key); } var root = _roots[item.Key]; _audioContainers.Add(item.Key, AudioContainer.Create(item.Key, root, item.Value.AverageDistance(), container: AudioPlayer.SoundsCointaner.transform)); } }
static void PlayPerson(List <string> list) { //if a sound for a lang is not being added yet just return if (list.Count == 0) { return; } //the root is determined by the languages and the type of person //English/Man/ is an ex var buildRoot = list[Random.Range(0, list.Count)]; var key = buildRoot.Substring(infoIndex, buildRoot.Length - (4 + infoIndex)); //Debug.Log("Key: " + key); //Debug.Log("buildRoot: " + buildRoot); if (!_audioContainers.ContainsKey(key)) { var audioConta = AudioContainer.Create(key, key, 20, container: AudioPlayer.SoundsCointaner.transform); _audioContainers.Add(key, audioConta); _languages.Add(key, buildRoot + key); } else { _audioContainers[key].PlayAShot(20);//15 is half way } }
public void TestAddingContainerAsEnumerableRangeThrows(Type containerType) { Assert.Throws <InvalidOperationException>(() => { var unused = new Container { Children = (IReadOnlyList <Drawable>)Activator.CreateInstance(containerType) }; }); Assert.Throws <InvalidOperationException>(() => { var unused = new Container(); unused.AddRange((IEnumerable <Drawable>)Activator.CreateInstance(containerType)); }); Assert.Throws <InvalidOperationException>(() => { var unused = new AudioContainer { Children = (IReadOnlyList <Drawable>)Activator.CreateInstance(containerType) }; }); Assert.Throws <InvalidOperationException>(() => { var unused = new AudioContainer(); unused.AddRange((IEnumerable <Drawable>)Activator.CreateInstance(containerType)); }); }
protected override void OnUpdate() { for (int i = 0; i < _audioPlayedGroup.Length; i++) { Entity instanceEntity = _audioPlayedGroup.Played[i].InstanceEntity; AudioContainer audioContainer = AudioContainerFindBook[instanceEntity]; audioContainer.OnPlayed(instanceEntity); PostUpdateCommands.RemoveComponent <AudioMessage_InstancePlayed>(instanceEntity); } for (int i = 0; i < _audioStoppedGroup.Length; i++) { Entity instanceEntity = _audioStoppedGroup.Stopped[i].InstanceEntity; AudioContainer audioContainer = AudioContainerFindBook[instanceEntity]; audioContainer.OnStopped(instanceEntity); PostUpdateCommands.RemoveComponent <AudioMessage_InstanceStopped>(instanceEntity); } for (int i = 0; i < _audioMutedGroup.Length; i++) { Entity instanceEntity = _audioMutedGroup.Muted[i].InstanceEntity; AudioContainer audioContainer = AudioContainerFindBook[instanceEntity]; audioContainer.OnMuted(instanceEntity); PostUpdateCommands.RemoveComponent <AudioMessage_InstanceMuted>(instanceEntity); } for (int i = 0; i < _audioUnmutedGroup.Length; i++) { Entity instanceEntity = _audioUnmutedGroup.Unmuted[i].InstanceEntity; AudioContainer audioContainer = AudioContainerFindBook[instanceEntity]; audioContainer.OnUnmuted(instanceEntity); PostUpdateCommands.RemoveComponent <AudioMessage_InstanceUnmuted>(instanceEntity); } }
public virtual void Initialize(AudioContainer audioContainer) { if (audioContainer == null) { return; } pitch = initialPitch; lastPlayedTime = 0f; nextAvailablePlayTime = 0f; lastPlayedIndex = -1; RandomizeIndex(); // Add AudioSource component for event source = audioContainer.gameObject.AddComponent(typeof(AudioSource)) as AudioSource; if (clips.Length == 0) { Debug.LogWarning("There are no clips in the audio event '" + name + "' (" + audioContainer.name + ")"); } else { source.clip = clips[0]; } source.volume = initialVolume; source.loop = loop; source.playOnAwake = false; source.outputAudioMixerGroup = audioContainer.audioMixerGroup; source.spatialBlend = audioContainer.spatialBlend; source.dopplerLevel = audioContainer.dopplerLevel; source.minDistance = audioContainer.minDistance; source.maxDistance = audioContainer.maxDistance; }
public async Task JoinAsync(IVoiceChannel voiceChannel, IMessageChannel channel) { if (voiceChannel == null) { await channel.SendMessageAsync("<Mention> __User must be in a voice channel__"); return; } var guildId = voiceChannel.Guild.Id; if (_container.TryGetValue(guildId, out _)) { return; } var Container = new AudioContainer { AudioClient = await voiceChannel.ConnectAsync(), CancellationTokenSource = new CancellationTokenSource(), QueueManager = new QueueManager(), }; Container.AudioOutStream = Container.AudioClient.CreatePCMStream(AudioApplication.Music, bitrate: 128000); _container.TryAdd(guildId, Container); }
public void ResizeOrCreateAudioClips() { if (audioClips == null || audioClips.Length == 0) { audioClips = new AudioContainer[IDamageInfo.DamageTypCount]; for (int i = 0; i < IDamageInfo.DamageTypCount; i++) { audioClips[i] = new AudioContainer(); } } else if (audioClips.Length != IDamageInfo.DamageTypCount) { AudioContainer[] tmpStor = OribowsUtilitys.DeepCopy(audioClips); audioClips = new AudioContainer[IDamageInfo.DamageTypCount]; int smallerSize = Mathf.Min(IDamageInfo.DamageTypCount, tmpStor.Length); for (int i = 0; i < smallerSize; i++) { audioClips[i] = new AudioContainer(); if (tmpStor[i] != null) { audioClips[i].audioClips = new AudioClip[tmpStor[i].audioClips.Length]; for (int k = 0; k < tmpStor[i].audioClips.Length; k++) { audioClips[i][k] = tmpStor[i][k]; } } } for (int i = smallerSize; i < IDamageInfo.DamageTypCount; i++) { audioClips[i] = new AudioContainer(); } } }
/// <summary> /// Coroutine for "continuous" random containers that alternates between two sources to crossfade clips for continuous playlist Looping. /// </summary> /// <param name="audioContainer">The audio container.</param> /// <param name="activeEvent">The persistent reference to the event as long as it is playing.</param> /// <param name="waitTime">The time in seconds to wait before switching AudioSources for crossfading.</param> /// <returns>The coroutine.</returns> private IEnumerator ContinueRandomContainerCoroutine(AudioContainer audioContainer, ActiveEvent activeEvent, float waitTime) { while (!activeEvent.CancelEvent) { yield return(new WaitForSeconds(waitTime)); audioContainer.CurrentClip = Random.Range(0, audioContainer.Sounds.Length); UAudioClip tempClip = audioContainer.Sounds[audioContainer.CurrentClip]; // Play on primary source. if (activeEvent.PlayingAlt) { activeEvent.PrimarySource.volume = 0f; activeEvent.VolDest = activeEvent.AudioEvent.VolumeCenter; activeEvent.AltVolDest = 0f; activeEvent.CurrentFade = audioContainer.CrossfadeTime; waitTime = (tempClip.Sound.length / activeEvent.PrimarySource.pitch) - audioContainer.CrossfadeTime; PlayClipAndGetTime(tempClip, activeEvent.PrimarySource, activeEvent); } // Play on secondary source. else { activeEvent.SecondarySource.volume = 0f; activeEvent.AltVolDest = activeEvent.AudioEvent.VolumeCenter; activeEvent.VolDest = 0f; activeEvent.CurrentFade = audioContainer.CrossfadeTime; waitTime = (tempClip.Sound.length / activeEvent.SecondarySource.pitch) - audioContainer.CrossfadeTime; PlayClipAndGetTime(tempClip, activeEvent.SecondarySource, activeEvent); } activeEvent.PlayingAlt = !activeEvent.PlayingAlt; } }
public RPGAction(RPGActionType actionType) { ID = Guid.NewGuid().ToString(); Type = actionType; Params = new Dictionary <string, object>(); Animation = null; Sound = null; }
public RPGAction(RPGActionType actionType, Dictionary <string, object> parameters) { ID = Guid.NewGuid().ToString(); Type = actionType; Params = parameters; Animation = null; Sound = null; }
public void PlayTaunt(AudioContainer audioContainer) { if (tauntSource != null && audioContainer != null) { tauntSource.clip = audioContainer.PickAudioClip(); tauntSource.Play(); } }
public static void PlaySound(AudioSource source, AudioContainer audioContainer) { if (source != null && audioContainer != null) { source.clip = audioContainer.PickAudioClip(); source.Play(); } }
public override void OnItemDataRefresh(ItemPhysic data) { base.OnItemDataRefresh(data); if (!string.IsNullOrEmpty(useSound)) { Catalog.LoadAssetAsync <AudioContainer>(useSound, ac => useSoundAsset = ac, null); } }
/// <summary> /// Initializes a new instance of the <see cref="PostAddAudioRequest"/> class. /// </summary> /// <param name="name">Original video name.</param> /// <param name="destinationPath">Path where to save the result file.</param> /// <param name="audio">Audio options. </param> /// <param name="folder">Original video folder.</param> /// <param name="storage">File storage, which have to be used.</param> /// <param name="destFileName">Result name of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.</param> public PostAddAudioRequest(string name, string destinationPath, AudioContainer audio, string folder = null, string storage = null, string destFileName = null) { this.Name = name; this.DestinationPath = destinationPath; this.Audio = audio; this.Folder = folder; this.Storage = storage; this.DestFileName = destFileName; }
public void Stop(string name) { AudioContainer container = audioDictionary[name]; container.source.Stop(); container.mode = Mode.NONE; audioDictionary[name] = container; }
/// <summary> /// This event is called everytime speed is changed on game /// </summary> /// <param name="e"></param> void OnChangeSpeed(EventArgs e) { if (ChangeSpeed != null) { ChangeSpeed(this, e); Rotate.SpeedChanged(); AudioContainer.SpeedChanged(); } }
private void Reset() { audioContainer = AssetDatabase.LoadAssetAtPath <AudioContainer>(_assetPath); if (!audioContainer) { audioContainer = ScriptableObject.CreateInstance <AudioContainer>(); AssetDatabase.CreateAsset(audioContainer, _assetPath); } }
public SpectrumCreatorGPU(AudioContainer audioContainer) : base(audioContainer) { _cl = CL.GetApi(); InitializePlatformId(); InitializeDeviceId(); CreateContext(); CreateCommandQueue(); BuildProgram(); }
public void PlayEventSound(string eventName) { AudioContainer ac = (from AudioContainer in AudioContainers where AudioContainer.eventName == eventName select AudioContainer) as AudioContainer; if (ac != null) { ac.PlaySound(); } }
public RPGAction WithSound(AudioContainer audioContainer, bool whileActionIsActive = false) { Sound = audioContainer; if (whileActionIsActive) { WhileActionIsActive = true; } return(this); }
public static RPGAction PlaySound(AudioContainer audioContainer, AudioType audioType) { var parameters = new Dictionary <string, object>() { { "AudioContainer", audioContainer }, { "AudioType", audioType } }; return(new RPGAction(RPGActionType.PlaySound, parameters)); }
/// <summary> /// This event is called everytime speed is changed on game /// </summary> /// <param name="e"></param> private void OnChangeSpeed(EventArgs e) { if (ChangeSpeed != null) { ChangeSpeed(this, e); Rotate.SpeedChanged(); AudioContainer.SpeedChanged(); MyText.UpdateNow(); } }
// Adds a counter to the activeSounds storage private void addSound(AudioContainer sound) { if (ActiveSounds.ContainsKey(sound)) { ActiveSounds[sound]++; } else { ActiveSounds[sound] = 1; } }
private static void LoadAMusic(KeyValuePair <string, string> item) { var root = DefineRoot(item.Key); var audCont = AudioContainer.Create(item.Key, root, 0, container: AudioPlayer.SoundsCointaner.transform); LevelChanged += audCont.LevelChanged; _musics.Add(item.Key, audCont); }
//public access members public void Load(string name, string filename) { AudioContainer container = new AudioContainer(); container.source = gameObject.AddComponent(typeof(AudioSource)) as AudioSource; container.source.clip = Resources.Load <AudioClip>(filename) as AudioClip; container.source.volume = 0f; container.mode = Mode.NONE; audioDictionary[name] = container; }