private void AudioTriggerArea_OnTriggerAreaEvent(object sender, AudioTriggerAreaEventArgs e) { if (e.triggerEventType == AudioTriggerAreaEventArgs.TriggerEventType.TriggerEnter) { insideCount++; if (insideCount == 1 && initializationSuccesfull) { snapshotInstance = FMODUnity.RuntimeManager.CreateInstance(snapshotPath); if (snapshotInstance.isValid()) { snapshotInstance.start(); } else { Debug.LogError("Snapshot event path is invalid for Reverb Zone " + gameObject.name + "."); } } } else { insideCount--; if (insideCount == 0 && initializationSuccesfull) { if (snapshotInstance.isValid()) { snapshotInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); snapshotInstance.release(); } } } }
void Update() { if (isSpeaking) { if (eventInstance.isValid()) { FMOD.Studio.PLAYBACK_STATE playbackState; eventInstance.getPlaybackState(out playbackState); if (playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED) { eventInstance.release(); if (!coroutineRunning) { isSpeaking = false; } if (!string.IsNullOrEmpty(currentDialogue) && !coroutineRunning) { string latestDialogue = currentDialogue; currentDialogue = null; if (voiceoverManager != null) { voiceoverManager.ReportSpeakerAvailability(speaker, latestDialogue); } } } } else if (!coroutineRunning) { isSpeaking = false; } } }
/// <summary> /// Stop running music and ambience with fade out. /// </summary> public void StopMusicAmbience() { music.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); music.release(); ambience.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); ambience.release(); currentAmbienceEvent = null; currentMusicEvent = null; }
public void OnExit() { if (isPlayheadInside) { if (eventInstance.isValid()) { if (stopType != STOP_MODE.None) { eventInstance.stop(stopType == STOP_MODE.Immediate ? FMOD.Studio.STOP_MODE.IMMEDIATE : FMOD.Studio.STOP_MODE.ALLOWFADEOUT); } eventInstance.release(); } isPlayheadInside = false; } }
public void Play() { if (TriggerOnce && hasTriggered) { return; } if (String.IsNullOrEmpty(Event)) { return; } if (eventDescription == null) { Lookup(); eventDescription.isOneshot(out isOneshot); } // Let previous oneshot instances play out if (isOneshot && instance != null) { instance.release(); instance = null; } if (instance == null) { eventDescription.createInstance(out instance); } instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, cachedRigidBody)); foreach (var param in Params) { instance.setParameterValue(param.Name, param.Value); } instance.start(); hasTriggered = true; // Only want to update if we need to set 3D attributes bool is3d = false; eventDescription.is3D(out is3d); if (is3d) { enabled = true; } }
public void Dispose() { if (Ready) { Stop(); _instance.release(); } }
// -- // void PlayOneShot(string eventName, EventPayload data) { FMODEventInstance = FMODUnity.RuntimeManager.CreateInstance(eventName); SetupSpacePosition(data.Has(_customPositionInEventPayload), data.Get <Vector3>(_customPositionInEventPayload)); FMODEventInstance.start(); FMODEventInstance.release(); }
public void Stop() { if (instance != null) { instance.stop(AllowFadeout ? FMOD.Studio.STOP_MODE.ALLOWFADEOUT : FMOD.Studio.STOP_MODE.IMMEDIATE); instance.release(); instance = null; } }
public void StopSpotAmbience() { if (!IsInitialized) { return; } if (InstanceAlreadyPlaying && spotAmbienceInstance.isValid()) { spotAmbienceInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); spotAmbienceInstance.release(); InstanceAlreadyPlaying = false; } else { InstanceAlreadyPlaying = false; } }
/// <summary> /// Use this for overriding the event's 3D-attenuation settings (the min/max distance of the sound, usually set in the 3D-panner of the event). /// </summary> public static void PlayOneShot3D(string eventPath, Vector3 position, float minDistanceOverride, float maxDistanceOverride) { FMOD.Studio.EventInstance eventInstance = CreateFmodEventInstance(eventPath); Set3DAttenuationSettings(eventInstance, minDistanceOverride, maxDistanceOverride); eventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(position)); eventInstance.start(); eventInstance.release(); }
void OnDestroy() { if (!isQuitting) { HandleGameEvent(EmitterGameEvent.ObjectDestroy); if (instance.isValid()) { RuntimeManager.DetachInstanceFromGameObject(instance); if (eventDescription.isValid() && isOneshot) { instance.release(); instance.clearHandle(); } } if (Preload) { eventDescription.unloadSampleData(); } } }
public static void PreviewStop() { if (previewEventInstance != null) { previewEventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); previewEventInstance.release(); previewEventInstance = null; previewEventDesc = null; previewBank.unload(); masterBank.unload(); } }
public static void PreviewStop() { if (previewEventInstance.isValid()) { previewEventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); previewEventInstance.release(); previewEventInstance.clearHandle(); previewEventDesc.clearHandle(); previewBanks.ForEach(x => { x.unload(); x.clearHandle(); }); masterBanks.ForEach(x => { x.unload(); x.clearHandle(); }); previewState = PreviewState.Stopped; } }
// Update is called once per frame protected override void Update() { float tipHeight = transform.Find("Tip").transform.localScale.y - 0.33f; Vector3 tip = transform.Find("Tip").transform.position; if (Physics.Raycast(tip, transform.up, out touch, tipHeight)) { if (!(touch.collider.tag == "Ground")) { return; } this.blackboard = touch.collider.GetComponent <BlackboardControllerCopy>(); Debug.Log("Touching!"); this.blackboard.SetColor(new Color(1, 1, 1, 1)); this.blackboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y); this.blackboard.ToggleTouch(true); rigidbody.freezeRotation = true; if (!lastTouch) { lastTouch = true; chalk = FMODUnity.RuntimeManager.CreateInstance(chalkEvent); chalk.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject)); chalk.start(); } } else { if (lastTouch) { this.blackboard.ToggleTouch(false); } rigidbody.freezeRotation = false; chalk.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); chalk.release(); lastTouch = false; } if (this.IsGrabbed() && FrustumCheckerCharacter() && !voIsPlayed) { StartCoroutine(StareTimerCharacter()); } }
/// <summary> /// Plays the passed in fmod event as a one shot event, meaning it is set to release the event automatically as soon as it stops playing. /// This allows for instanced fmod events without letting them infinitely build up. /// </summary> /// <param name="fmodEvent"> The name of the event we want to play as a one shot event </param> /// <param name="volume"> The volume of the event we want to play as a one shot event </param> /// <param name="paramData"> An array of param data that should be passed to our fmod event before playing it </param> public void PlayOneShotFmodEvent(FMOD.Studio.EventInstance fmodEvent, float volume = 1.0f, FmodParamData[] paramData = null) { if (paramData != null) { for (int i = 0; i < paramData.Length; i++) { SetFmodParameterValue(fmodEvent, paramData[i].paramName, paramData[i].paramValue); } } fmodEvent.setVolume(volume); if (debugOneShotEvents) { Debug.Log("1. START ONE SHOT EVENT"); FMOD.Studio.EVENT_CALLBACK stoppedOneShotEventCallback; stoppedOneShotEventCallback = new FMOD.Studio.EVENT_CALLBACK(StoppedOneShotEventCallback); fmodEvent.setCallback(stoppedOneShotEventCallback, FMOD.Studio.EVENT_CALLBACK_TYPE.STOPPED); } fmodEvent.start(); fmodEvent.release(); }
private void StopAmbience(FMOD.Studio.STOP_MODE stopMode) { if (!ambienceStarted) { return; } if (baseAmbienceInstance.isValid()) { baseAmbienceInstance.stop(stopMode); baseAmbienceInstance.release(); } foreach (var spotAmbience in enteredSpotAmbienceAreas) { if (spotAmbience != null) { spotAmbience.StopSpotAmbience(); } } ambienceStarted = false; }
public void Play() { if (TriggerOnce && hasTriggered) { return; } if (String.IsNullOrEmpty(Event)) { return; } if (eventDescription == null) { Lookup(); } bool isOneshot = false; if (!Event.StartsWith("snapshot", StringComparison.CurrentCultureIgnoreCase)) { eventDescription.isOneshot(out isOneshot); } bool is3D; eventDescription.is3D(out is3D); if (instance != null && !instance.isValid()) { instance = null; } // Let previous oneshot instances play out if (isOneshot && instance != null) { instance.release(); instance = null; } if (instance == null) { eventDescription.createInstance(out instance); // Only want to update if we need to set 3D attributes if (is3D) { var rigidBody = GetComponent <Rigidbody>(); var transform = GetComponent <Transform>(); instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody)); RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody); } } foreach (var param in Params) { instance.setParameterValue(param.Name, param.Value); } instance.start(); hasTriggered = true; }
public void Play() { if (TriggerOnce && hasTriggered) { return; } if (string.IsNullOrEmpty(Event)) { return; } if (!eventDescription.isValid()) { Lookup(); } bool isOneshot = false; if (!Event.StartsWith("snapshot", StringComparison.CurrentCultureIgnoreCase)) { eventDescription.isOneshot(out isOneshot); } bool is3D; eventDescription.is3D(out is3D); if (!instance.isValid()) { instance.clearHandle(); } // Let previous oneshot instances play out if (isOneshot && instance.isValid()) { instance.release(); instance.clearHandle(); } if (!instance.isValid()) { eventDescription.createInstance(out instance); // Only want to update if we need to set 3D attributes if (is3D) { var rigidBody = GetComponent <Rigidbody>(); var rigidBody2D = GetComponent <Rigidbody2D>(); var transform = GetComponent <Transform>(); if (rigidBody) { instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody)); RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody); } else { instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody2D)); RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D); } } } foreach (var param in Params) { instance.setParameterByID(param.ID, param.Value); } if (is3D && OverrideAttenuation) { instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance); instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance); } instance.start(); hasTriggered = true; }
/// <summary> /// Stops the passed in fmod event /// </summary> /// <param name="fmodEvent"> The name of the event we want to stop </param> public void StopFmodEvent(FMOD.Studio.EventInstance fmodEvent) { fmodEvent.setUserData(IntPtr.Zero); fmodEvent.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); fmodEvent.release(); }
public void TightenBeltEvent() { FMOD.Studio.EventInstance beltTightenEvent = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/Belt/BeltTighten"); beltTightenEvent.start(); beltTightenEvent.release(); }
public void HelmetStartSlidingOntoHeadEvent() { FMOD.Studio.EventInstance helmetEvent = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/HelmetApplication/HelmetApplication"); helmetEvent.start(); helmetEvent.release(); }
public void Play(string audioFile) { if (String.IsNullOrEmpty(audioFile)) { return; } if (TriggerOnce && hasTriggered) { return; } if (String.IsNullOrEmpty(Event)) { return; } if (!eventDescription.isValid()) { Lookup(); } bool isOneshot = false; if (!Event.StartsWith("snapshot", StringComparison.CurrentCultureIgnoreCase)) { eventDescription.isSnapshot(out isOneshot); } bool is3D = false; eventDescription.is3D(out is3D); if (!instance.isValid()) { instance.clearHandle(); } if (isOneshot && instance.isValid()) { instance.release(); instance.clearHandle(); } if (!instance.isValid()) { eventDescription.createInstance(out instance); if (is3D) { var rigidBody = GetComponent <Rigidbody>(); var rigidBody2D = GetComponent <Rigidbody2D>(); var transform = GetComponent <Transform>(); if (rigidBody) { instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody)); RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody); } else { instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody2D)); RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D); } } } foreach (var param in Params) { instance.setParameterValue(param.Name, param.Value); } if (is3D && OverrideAttenuation) { instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance); instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance); } ExtensionsManager.PlayProgrammerSound(audioFile, this.instance); hasTriggered = true; }
private void OnDestroy() { instance.release(); }