// Plays a oneshot with a parameter attached. Usefll for footsteps with material. Objects with no rigidbody can set it to null public static EventInstance PlayOneShot(string eventName, Transform position, Rigidbody rb, PARAMETER_ID parameterId, float value) { EventDescription description = RuntimeManager.GetEventDescription(eventName); description.createInstance(out EventInstance instance); if (string.IsNullOrEmpty(eventName)) { return(instance); } description.is3D(out bool is3D); instance.setParameterByID(parameterId, value); if (is3D) { instance.set3DAttributes(RuntimeUtils.To3DAttributes(position, rb)); RuntimeManager.AttachInstanceToGameObject(instance, position, rb); } instance.start(); instance.release(); instance.clearHandle(); return(instance); }
/// <summary> /// Play an audio file inside an FMOD event. Will play once at a given position /// </summary> /// <param name="audioFile">Audio file.</param> /// <param name="eventName">Event name.</param> /// <param name="position">Position.</param> public static void PlayOneShotProgrammerSound(string audioFile, string eventName, Vector3 position) { audioFile = ExtensionsUtils.FindFile(audioFile); EVENT_CALLBACK callback = new EVENT_CALLBACK(ProgrammerEventCallback); EventDescription eventDescription = RuntimeManager.GetEventDescription(eventName); EventInstance eventInstance; eventDescription.createInstance(out eventInstance); eventInstance.set3DAttributes(RuntimeUtils.To3DAttributes(position)); eventInstance.setCallback(callback); ProgrammerSoundContext context = new ProgrammerSoundContext(); context.file = audioFile; context.mode = MODE.CREATESAMPLE | MODE._3D_LINEARSQUAREROLLOFF | MODE.LOOP_NORMAL | MODE.NONBLOCKING; GCHandle handle = GCHandle.Alloc(context, GCHandleType.Pinned); eventInstance.setUserData(GCHandle.ToIntPtr(handle)); eventInstance.start(); eventInstance.release(); }
public void Init_Event() { event_Description = RuntimeManager.GetEventDescription(event_Ref); event_Description.loadSampleData(); event_Description.getMaximumDistance(out _maxDistance); event_Description.is3D(out _is3D); }
/// <summary> /// Play an audio file inside an FMOD Event. Will play once without taking in 3D position /// </summary> /// <param name="audioFile">Audio file.</param> /// <param name="eventName">Event name.</param> public static void PlayOneShotProgrammerSound(string audioFile, string eventName) { audioFile = ExtensionsUtils.FindFile(audioFile); // Create the callback that will handle creating and destroying the programmer sound EVENT_CALLBACK callback = new EVENT_CALLBACK(ProgrammerEventCallback); // Create our one time event EventDescription eventDescription = RuntimeManager.GetEventDescription(eventName); EventInstance eventInstance; eventDescription.createInstance(out eventInstance); // Set callback eventInstance.setCallback(callback); // Create our user data that we'll user later when playing the event ProgrammerSoundContext context = new ProgrammerSoundContext { file = audioFile, mode = MODE.CREATESAMPLE | MODE.LOOP_NORMAL | MODE.NONBLOCKING }; // Create our pointer. It is unpinned when we get this data later GCHandle handle = GCHandle.Alloc(context, GCHandleType.Pinned); eventInstance.setUserData(GCHandle.ToIntPtr(handle)); eventInstance.start(); eventInstance.release(); }
public void Init_Ref() { event_Instance = RuntimeManager.CreateInstance(event_Ref); event_Description = RuntimeManager.GetEventDescription(event_Ref); event_Description.getMaximumDistance(out maxDistance); event_Description.getMinimumDistance(out minDistance); EventDescription isShyEventDescription; event_Instance.getDescription(out isShyEventDescription); PARAMETER_DESCRIPTION isShyParameterDescription; isShyEventDescription.getParameterDescriptionByName("isShy", out isShyParameterDescription); isShyParameterId = isShyParameterDescription.id; event_Description.is3D(out is3D); if (is3D) { Init_Attachment(transform, GetComponent <Rigidbody>()); } if (playFromStart) { Init_Event(); } }
//[SerializeField] //[Range(0f, 1f)] //public float wind_IntensityValue; // kommentera ut ifall WorldState-värde används, kan användas i Debug-syfte private void Awake() { if (Instance != null && Instance != this) { Destroy(this.gameObject); } else { Instance = this; } event_Instance = RuntimeManager.CreateInstance(event_Ref); event_Description = RuntimeManager.GetEventDescription(event_Ref); event_Description.is3D(out is3D); if (is3D) { Init_Attachment(transform, GetComponent <Rigidbody>()); } EventDescription ambGlobalOverrideEventDescription; event_Instance.getDescription(out ambGlobalOverrideEventDescription); PARAMETER_DESCRIPTION ambGlobalOverrideParameterDescription; ambGlobalOverrideEventDescription.getParameterDescriptionByName("amb_global_override", out ambGlobalOverrideParameterDescription); ambGlobalOverrideParameterId = ambGlobalOverrideParameterDescription.id; RuntimeManager.StudioSystem.getParameterDescriptionByName(parameter, out windIntensityDescription); }
public static PARAMETER_ID GetParameterID(this StudioEventEmitter emitter, string parameterName) { EventDescription eventDescription = RuntimeManager.GetEventDescription(GetGuid(emitter.Event)); eventDescription.getParameterDescriptionByName(parameterName, out PARAMETER_DESCRIPTION parameterDescription); return(parameterDescription.id); }
private static PARAMETER_ID GetParameterIDInternal(string eventPath, string parameter) { EventDescription eventDescription = RuntimeManager.GetEventDescription(RuntimeManager.PathToGUID(eventPath)); eventDescription.getParameterDescriptionByName(parameter, out PARAMETER_DESCRIPTION parameterDescription); return(parameterDescription.id); }
// Start is called before the first frame update void Start() { //startCar= FMODUnity.RuntimeManager.CreateInstance("event:/SFX/Car/Car_Start"); carMoving = RuntimeManager.CreateInstance("event:/SFX/Car/Car_Moving"); carReached = RuntimeManager.GetEventDescription("event:/SFX/Car/Car_Moving"); carMoving.start(); }
private void Start() { _collider2DEvents.onTriggerEnter += HandleCollider2DEventsOnTriggerEnter; _collider2DEvents.onTriggerExit += HandleCollider2DEventsOnTriggerExit; var eventDescription = RuntimeManager.GetEventDescription(_transferEventRef); eventDescription.createInstance(out _transferEventInstance); }
///////////////////////////////////////////////// // Local parameters ///////////////////////////////////////////////// /// <summary> /// Will set the parameter to the newValue for **ALL** instances of this event /// </summary> public static void SetEventParameter(string eventPath, string parameter, float newValue) { RuntimeManager.GetEventDescription(RuntimeManager.PathToGUID(eventPath)) .getInstanceList(out EventInstance[] instances); foreach (EventInstance instance in instances) { instance.setParameterByName(parameter, newValue); } }
// Returns the Id of a parameter. More performant for repeated access than using the string method. public static PARAMETER_ID GetParameterId(string eventName, string parameterName) { EventDescription eventDescription = RuntimeManager.GetEventDescription(eventName); PARAMETER_DESCRIPTION parameterDescription; eventDescription.getParameterDescriptionByName(parameterName, out parameterDescription); PARAMETER_ID parameterId = parameterDescription.id; return(parameterId); }
public void Init_Event(string event_Ref) { if (event_Ref == null) { return; } event_Description = RuntimeManager.GetEventDescription(event_Ref); event_Description.getMaximumDistance(out _maxDistance); Attach_Wind_Emitter(); }
void Start() { var eventDesc = RuntimeManager.GetEventDescription(_insideNoiseEventRef); eventDesc.createInstance(out _insideNoiseEventInstance); _gameManager.levelFinishedEvent += HandleGameManagerLevelFinished; _insideNoiseEventInstance.start(); _insideNoiseEventInstance.setVolume(0.0f); }
private void Start() { Audio = RuntimeManager.CreateInstance(SelectAudio); RuntimeManager.AttachInstanceToGameObject(Audio, GetComponent <Transform>(), GetComponent <Rigidbody>()); Audio.start(); Audio.release(); AudioDes = RuntimeManager.GetEventDescription(SelectAudio); AudioDes.getMaximumDistance(out MaxDistance); Listener = FindObjectOfType <StudioListener>(); }
private void OnEnable() { event_Instance = RuntimeManager.CreateInstance(event_Ref); event_Description = RuntimeManager.GetEventDescription(event_Ref); event_Description.getMaximumDistance(out _maxDistance); event_Description.is3D(out _is3D); if (_is3D) { RuntimeManager.AttachInstanceToGameObject(event_Instance, transform, GetComponent <Rigidbody>()); } Init_Parameter(); }
public void Setup(Music music, string parameterName, float value) { string eventName = GetMusicPath(music); if (!audioEvents.ContainsKey(eventName)) { return; } var desc = RuntimeManager.GetEventDescription(eventName); desc.getParameterDescriptionByName(parameterName, out PARAMETER_DESCRIPTION pd); audioEvents[eventName].setParameterByID(pd.id, value); }
private void Start() { audioInstance = RuntimeManager.CreateInstance(selectAudio); RuntimeManager.AttachInstanceToGameObject(audioInstance, GetComponent <Transform>(), GetComponent <Rigidbody>()); audioDes = RuntimeManager.GetEventDescription(selectAudio); audioDes.getMaximumDistance(out maxDistance); listening = FindObjectOfType <StudioListener>(); if (isMenuMusic) { audioInstance.setParameterByName("is Calm", _currentValue); } }
private void ChangePlayingMusic() { if (GetMusicPath() != null) { StopMusic(); } musicEvent = RuntimeManager.CreateInstance(gameMusic); musicEvent.set3DAttributes(RuntimeUtils.To3DAttributes(m_CameraGO)); musicEvent.start(); musicDes = RuntimeManager.GetEventDescription(gameMusic); musicDes.getParameterDescriptionByName("ChangeTrack", out musicPD); musicPiD = musicPD.id; }
void Awake() { MasterBus = RuntimeManager.GetBus("Bus:/"); MasterBus.stopAllEvents(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); music = RuntimeManager.CreateInstance("event:/Music/Music"); musicDescription = RuntimeManager.GetEventDescription("event:/Music/Music"); musicDescription.getParameterDescriptionByName("Health", out triggerMusic); mID = triggerMusic.id; music.setParameterByID(mID, 4.00f); //Debug.Log("on Wake"); music.start(); }
private void HandleGameManagerLevelStart() { var eventDescription = RuntimeManager.GetEventDescription(_ambienceEventRef); eventDescription.createInstance(out _ambienceEventInstance); _ambienceEventInstance.start(); eventDescription = RuntimeManager.GetEventDescription(_dirtEventRef); eventDescription.createInstance(out _dirtEventInstance); _dirtEventInstance.start(); RuntimeManager.StudioSystem.setParameterByName(_truthAmountParameterRef, _truthDataModel.GetNormalizedCurrentTruth()); }
// Start is called before the first frame update void Start() { MasterBus = RuntimeManager.GetBus("Bus:/"); MasterBus.stopAllEvents(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); titleMusic = RuntimeManager.CreateInstance("event:/Music/Title"); titleDesc = RuntimeManager.GetEventDescription("event:/Music/Title"); titleDesc.getParameterDescriptionByName("Fade", out titleTrigger); titleID = titleTrigger.id; titleMusic.setParameterByID(titleID, 1.00f); titleMusic.start(); }
public void PlayMusic() { EventDescription = RuntimeManager.GetEventDescription(Event); //this assigns the EventDescription from the Event string variable that we set in the editor EventDescription.createInstance(out EventInstance); //this creates an EventInstance from the EventDescription EventInstance.start(); //this starts the event FMOD.Studio.EVENT_CALLBACK callback; //special type of variable defined by FMOD.studio called EVENT_CALLBACK callback = new FMOD.Studio.EVENT_CALLBACK(BeatEventCallBack); //pointer to the function that we're going to callback which is MusicEventCallBack EventInstance.setCallback(callback, FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_BEAT); // sets a callback on the event that is created with the flag to call this on every Timeline beat FMOD.Studio.PARAMETER_DESCRIPTION distanceToClue_fmodParam; EventDescription.getParameter("DistanceToClue", out distanceToClue_fmodParam); maxClueDistance = distanceToClue_fmodParam.maximum; // sets maxClueDistance to the maximum value of the game parameter in the fmod parameter (30) print("Max Distance to Clue = " + maxClueDistance); }
void Awake() { if (!string.IsNullOrEmpty(feederEvent)) { feederEventDescription = RuntimeManager.GetEventDescription(feederEvent); } if (audioObjectTag != null) { AudioObjectMessenger.StartAudioObjectEvent += AudioObjectMessenger_StartAudioObjectEvent; AudioObjectMessenger.StopAudioObjectEvent += AudioObjectMessenger_StopAudioObjectEvent; } if (startFeedingOnAwake) { StartFeederEvent(); } }
public void Init_Event(string event_Ref) { event_Description = RuntimeManager.GetEventDescription(event_Ref); event_Description.loadSampleData(); event_Description.createInstance(out event_Instance); event_Description.getMaximumDistance(out _maxDistance); event_Description.is3D(out _is3D); event_Description.getParameterDescriptionCount(out int _parameterCount); if (_parameterCount > 0) { EventDescription isShyEventDescription; event_Instance.getDescription(out isShyEventDescription); PARAMETER_DESCRIPTION isShyParameterDescription; isShyEventDescription.getParameterDescriptionByName("is_shy", out isShyParameterDescription); _isShyParameterId = isShyParameterDescription.id; _isShy = true; } }
//GameObject Player; // Start is called before the first frame update private void Start() { audio = RuntimeManager.CreateInstance(SelectAudio); audio.start(); audio.release(); elevateYMecha = new Vector3(0, 20, 0); audioDes = RuntimeManager.GetEventDescription(SelectAudio); audioDes.getMaximumDistance(out maxDistance); listener = FindObjectOfType <StudioListener>(); audio.getPlaybackState(out pbState); if (pbState != PLAYBACK_STATE.PLAYING) { audio.start(); } //points }
// Gets the maximum attenuation on the 3D Object. public static float GetMaxDistance(string eventName) { EventDescription description = RuntimeManager.GetEventDescription(eventName); float maxDistance = 0; if (!description.isValid()) { Debug.LogError("Invalid Event Name" + eventName); return(maxDistance); } description.is3D(out bool is3D); if (!is3D) { Debug.LogError(eventName + "Does not have 3D Property set. Are you sure this is a 3D event?"); return(maxDistance); } description.getMaximumDistance(out maxDistance); return(maxDistance); }
void Lookup() { if (ShootEvent != "") { ShootEventDescription = RuntimeManager.GetEventDescription(ShootEvent); } if (DodgeEvent != "") { DodgeEventDescription = RuntimeManager.GetEventDescription(DodgeEvent); } if (HitEvent != "") { HitEventDescription = RuntimeManager.GetEventDescription(HitEvent); } if (RobotIdle != "") { RobotIdleDescription = RuntimeManager.GetEventDescription(RobotIdle); } if (Death != "") { RobotDeathDescription = RuntimeManager.GetEventDescription(Death); } }
// Creates and starts and instance of the sound. Remember to Stop the sound later. Otherwise it will create a memory leak from not being cleared. Use PlayOneShot if the sound aren't looping. Object with no rigidbody can be set to null public static EventInstance Play(string eventName, Transform position, Rigidbody rb) { EventDescription description = RuntimeManager.GetEventDescription(eventName); description.createInstance(out EventInstance instance); //EventInstance instance = RuntimeManager.CreateInstance(eventName); if (string.IsNullOrEmpty(eventName)) { return(instance); } description.is3D(out bool is3D); if (is3D) { instance.set3DAttributes(RuntimeUtils.To3DAttributes(position, rb)); RuntimeManager.AttachInstanceToGameObject(instance, position, rb); } instance.start(); return(instance); }
private void InstantiateAudioObject(Transform follow = null, List <AudioObjectParameter> parameters = null) { if (destructionInProgress || !initializationSuccesfull) { return; } if (singleton && instantiations.Count > 0) { return; } int index = 0; if (eventReferences.Count > 1) { index = SelectRandomIndex(); } EventInstance eventInstance; eventInstance = RuntimeManager.CreateInstance(eventReferences[index]); if (!eventInstance.isValid()) { Debug.LogError("Creating an event instance failed for Audio Object '" + gameObject.name + "'."); return; } if (parameters != null) { for (int i = 0; i < parameters.Count; i++) { AudioObjectParameter parameter = parameters[i]; FMOD.RESULT result = eventInstance.setParameterByName(parameter.name, parameter.value); if (result != FMOD.RESULT.OK) { Debug.LogWarning("Setting a value for local parameter '" + parameter.name + "' failed for '" + gameObject.name + "'. Fmod error: " + result); } } } EventDescription eventDescription = RuntimeManager.GetEventDescription(eventReferences[index]); bool is3D; eventDescription.is3D(out is3D); Transform transformToFollow = null; if (is3D) { // Transform follow priority: // 1. Transform optionally provided with the event instantiation // 2. Transform optionally provided in the inspector // 3. The Transform of this Audio Object. if (follow != null) { transformToFollow = follow; } else if (followTransform) { transformToFollow = followTransform; } else { transformToFollow = gameObject.transform; } // If the followed game object has a rigibody, retrieve it and pass it to FMOD RuntimeManager for velocity updates. Rigidbody rb = transformToFollow.gameObject.GetComponent <Rigidbody>(); RuntimeManager.AttachInstanceToGameObject(eventInstance, transformToFollow, rb); } if (spatialAudioRoomAware && SpatialAudioManager.Instance != null) { if (is3D) { if (_usesResonanceAudioSource) { var delayedRegistree = new DelayedSpatialAudioRegistree(); delayedRegistree.transformToFollow = transformToFollow; delayedRegistree.eventInstance = eventInstance; delayedSpatialAudioRegistrees.Add(delayedRegistree); GCHandle registreeHandle = GCHandle.Alloc(delayedRegistree, GCHandleType.Pinned); eventInstance.setUserData(GCHandle.ToIntPtr(registreeHandle)); eventInstance.setCallback(instanceCreatedCallback, EVENT_CALLBACK_TYPE.CREATED | EVENT_CALLBACK_TYPE.DESTROYED); return; } else { float maxDistance; eventDescription.getMaximumDistance(out maxDistance); SpatialAudioManager.Instance.RegisterRoomAwareInstance(eventInstance, transformToFollow, maxDistance, initialRoom, false); } } } instantiations.Add(eventInstance); eventInstance.start(); }