public AudioEventPosition MakeAudioEvent(Vector2 position, float lifespan, AK.Wwise.Event wwiseEvent) { var audioEventObject = Instantiate <AudioEventPosition>(m_audioEventPrefab); audioEventObject.SetLifespan(lifespan); wwiseEvent.Post(audioEventObject.gameObject); return(audioEventObject); }
/// <summary> /// This method is used to post events that use the Wwise Audio Input plug-in. /// </summary> /// <param name="akEvent">The event to post.</param> /// <param name="gameObject">The GameObject that the event will be posted on.</param> /// <param name="sampleDelegate">The C# audio sample delegate.</param> /// <param name="formatDelegate">The C# audio format delegate. If not specified, defaults to a mono source running at the sample rate of the sound engine.</param> /// <returns>The playingID of the newly instantiated sound associated with the posted event.</returns> static public uint PostAudioInputEvent(AK.Wwise.Event akEvent, GameObject gameObject, AudioSamplesDelegate sampleDelegate, AudioFormatDelegate formatDelegate = null) { TryInitialize(); uint playingID = akEvent.Post(gameObject, (uint)AkCallbackType.AK_EndOfEvent, EventCallback); AddPlayingID(playingID, sampleDelegate, formatDelegate); return(playingID); }
IEnumerator setWwiseGlobal() { yield return(new WaitUntil(() => wwiseInSceneScript.getWwiseGlobal() != null)); wwiseGlobalGO = wwiseInSceneScript.getWwiseGlobal(); AK.Wwise.Event[] events = wwiseGlobalGO.GetComponent <SFX_UI>().WGA_GetUIEvents(); UIHover = events[0]; UISelect = events[1]; UIBack = events[2]; }
static public MinMaxEventDuration GetMinMaxDuration(AK.Wwise.Event akEvent) { MinMaxEventDuration result = new MinMaxEventDuration(); string FullSoundbankPath = AkBasePathGetter.GetPlatformBasePath(); string filename = Path.Combine(FullSoundbankPath, "SoundbanksInfo.xml"); float MaxDuration = 1000000.0f; if (File.Exists(filename)) { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlNodeList soundBanks = doc.GetElementsByTagName("SoundBanks"); for (int i = 0; i < soundBanks.Count; i++) { XmlNodeList soundBank = soundBanks[i].SelectNodes("SoundBank"); for (int j = 0; j < soundBank.Count; j++) { XmlNodeList includedEvents = soundBank[j].SelectNodes("IncludedEvents"); for (int ie = 0; ie < includedEvents.Count; ie++) { XmlNodeList events = includedEvents[i].SelectNodes("Event"); for (int e = 0; e < events.Count; e++) { if (events[e].Attributes["Id"] != null && uint.Parse(events[e].Attributes["Id"].InnerText) == (uint)akEvent.ID) { if (events[e].Attributes["DurationType"] != null && events[e].Attributes["DurationType"].InnerText == "Infinite") { // Set both min and max to MaxDuration for infinite events result.MinDuration = MaxDuration; result.MaxDuration = MaxDuration; } if (events[e].Attributes["DurationMin"] != null) { result.MinDuration = float.Parse(events[e].Attributes["DurationMin"].InnerText); } if (events[e].Attributes["DurationMax"] != null) { result.MaxDuration = float.Parse(events[e].Attributes["DurationMax"].InnerText); } break; } } } } } } return(result); }
void DoGenerativePhase() { playingClipNumber = 0; enableButton = true; GenerativeUI generativeUI = generativeCanvas.GetComponent <GenerativeUI>(); generativeState.Post(gameObject); for (int i = 0; i < 3; i++) { AK.Wwise.Event keyEvent = (selectedCardData[i].cardKeyArray[i]); keyEvent.Post(gameObject); Debug.Log(i + " " + keyEvent); } //StartCoroutine(generativeUI.DoGeneration(selectedCardData)); }
public void PostEvent(AK.Wwise.Event _akEvent, bool _killOnEventEnd) { uint result; result = _akEvent.Post(gameObject, (uint)AkCallbackType.AK_EndOfEvent, EventEndCallback, null); if (_killOnEventEnd) { m_flagForDeath = _killOnEventEnd; } // Check if an event actually started, then update number of playing events if (result != 0) { m_playingEvents++; } }
public static void PostEvent(AK.Wwise.Event wwEvent, GameObject go) { wwEvent.Post(go); }
/// <summary> /// Posts a Wwise event using the gameobject supplied if the sound is not occluded. /// Set any RTPC values before calling this method. /// </summary> /// <param name="postingObject">The gameobject that wishes to post an event.</param> /// <param name="postingEvent">The event which you wish to post.</param> /// <param name="attenuationRTPCName">The name of the object's attenuation RTPC.</param> public void PostEventAndAddLocation(GameObject postingObject, AK.Wwise.Event postingEvent, string attenuationRTPCName) { //If the object posting the event is the listener then no raycasting or attenuation is needed. if (postingObject.name == listenerName) { postingEvent.Post(postingObject); PlayFootstep(); return; } float distance = Vector3.Distance(postingObject.transform.position, listenerTransform.position); if (distance > maxAttenuationRange) { return; } RaycastHit hit; Vector3 direction = listenerTransform.position - postingObject.transform.position; Vector3 startPosition = postingObject.transform.position; bool playerHit = false; float occlusionModifier = 1.0f; bool nothingHit = false; float rangeModifier = 0; while (!playerHit && !(occlusionModifier <= 0.0f) && !nothingHit) { if (Physics.Raycast(startPosition, direction, out hit, maxAttenuationRange - rangeModifier)) { if (hit.collider.gameObject.name == listenerName) { playerHit = true; if (attenuationRTPCName != "") { AkSoundEngine.SetRTPCValue(attenuationRTPCName, distance, postingObject); } if (postingObject.name != "Radio") { postingEvent.Post(postingObject); } //The amount to modify the sound radius by. float attenuationModifier = 1.0f; //The percentage of sound being attenuated float attenuationPercentage = ((distance / maxAttenuationRange)); attenuationModifier -= attenuationPercentage; if (occlusionModifier < 0) { occlusionModifier = 0; } AkSoundEngine.SetRTPCValue("Occlusion_RTPC", occlusionModifier * 100.0f, postingObject); switch (postingObject.name) { case "Pickup": AddBrickSound(postingObject.transform.position, attenuationModifier, occlusionModifier); break; case "Enemy": PlayEnemySound(postingObject.transform.position, attenuationModifier, occlusionModifier); break; case "Radio": RadioPlayer radioPlayer; if (postingObject.TryGetComponent(out radioPlayer)) { radioPlayer.ActivateSound(attenuationModifier, occlusionModifier); } break; case "Gate": AddMiscLocation(postingObject.transform.position, attenuationModifier, occlusionModifier, "Gate"); break; default: AddMiscLocation(postingObject.transform.position, attenuationModifier, occlusionModifier, "Unknown"); break; } } else { switch (hit.collider.tag) { case "Wood": occlusionModifier -= 0.1f; break; case "Metal": occlusionModifier -= 0.2f; break; case "Stone": occlusionModifier -= 0.8f; break; default: occlusionModifier -= 0.1f; break; } rangeModifier += Vector3.Magnitude(startPosition - hit.point); startPosition = hit.point; direction = listenerTransform.position - startPosition; startPosition += direction * 0.01f; } } else { nothingHit = true; } } }
public void PostEventSimple(AK.Wwise.Event _akEvent) { _akEvent.Post(gameObject); }