Пример #1
0
 public FmodEventUpdater(FMOD.Event evt, Func <Vector3> getPosFunc, string name, int?stateInfo = null)
 {
     EventName  = name;
     Event      = evt;
     GetPosFunc = getPosFunc;
     StateInfo  = stateInfo;
 }
Пример #2
0
        public void load(string eventName, ref FMOD.Event evt)
        {
            // Acces to the Gem EVENT
            eventgroup.getEvent(eventName, FMOD.EVENT_MODE.DEFAULT, ref evt);

            // Acces to the master CATEGORY
            eventsystem.getCategory("master", ref mastercategory);
        }
Пример #3
0
        /// <summary>
        /// Loads a new FMOD sound system.
        /// </summary>
        /// <param name="eventName">
        /// The name of the event to call.
        /// </param>
        /// <param name="paramName">
        /// The name of the param that will be applied on our sound  .
        /// </param>
        public void load(string eventName, string paramName, ref FMOD.Event evt, ref FMOD.EventParameter evtParam)
        {
            // Acces to the Gem EVENT
            eventgroup.getEvent(eventName, FMOD.EVENT_MODE.DEFAULT, ref evt);

            // Acces to the master CATEGORY
            eventsystem.getCategory("master", ref mastercategory);

            // We CALL our param to handle
            evt.getParameter(paramName, ref evtParam);
        }
Пример #4
0
        public RESULT getRealEvent(ref Event realevent)
        {
            RESULT result = RESULT.OK;
            IntPtr eventraw = new IntPtr();

            try
            {
                result = FMOD_EventQueueEntry_GetRealEvent(eventqueueentryraw, ref eventraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (realevent == null)
            {
                Event eventnew = new Event();
                eventnew.setRaw(eventraw);
                realevent = eventnew;
            }
            else
            {
                realevent.setRaw(eventraw);
            }

            return result;
        }
Пример #5
0
        public RESULT getEvent(string name, EVENT_MODE mode, ref Event _event)
        {
            RESULT result   = RESULT.OK;
            IntPtr eventraw = new IntPtr();
            Event  eventnew = null;

            try
            {
                result = FMOD_EventProject_GetEvent(eventprojectraw, name, mode, ref eventraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (_event == null)
            {
                eventnew = new Event();
                eventnew.setRaw(eventraw);
                _event = eventnew;
            }
            else
            {
                _event.setRaw(eventraw);
            }

            return result;
        }
Пример #6
0
        public RESULT getEventByIndex(int index, EVENT_MODE mode, ref Event _event)
        {
            RESULT result   = RESULT.OK;
            IntPtr eventraw = new IntPtr();
            Event  eventnew = null;

            try
            {
                result = FMOD_EventGroup_GetEventByIndex(eventgroupraw, index, mode, ref eventraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (_event == null)
            {
                eventnew = new Event();
                eventnew.setRaw(eventraw);
                _event = eventnew;
            }
            else
            {
                _event.setRaw(eventraw);
            }

            return result;
        }
Пример #7
0
 public RESULT freeEventData(Event _event, bool waituntilready)
 {
     return FMOD_EventGroup_FreeEventData(eventgroupraw, _event.getRaw(), waituntilready ? 1 : 0);
 }
Пример #8
0
 public RESULT freeEventData(Event _event)
 {
     return FMOD_EventGroup_FreeEventData(eventgroupraw, _event.getRaw(), 1);
 }
Пример #9
0
 void cleanInvalidHandle()
 {
     foreach (FmodRuntimeEventParameter p in m_parameters) {
         p.Clean();
     }
     // in the case of a invalid handle, we don't put the handle back in the pool, since it's invalid. The one that stole it should alreayd be in it anyway.
     // however, we should remove the audiosource from the list of active sources
     m_runtimeEvent = null;
     if (m_eventSystemHandle != null &&
         m_eventSystemHandle.getEventSystem() != null &&
         m_eventSystemHandle.getEventSystem().wasCleaned()) {
         m_eventSystemHandle.getEventSystem().releaseRunningInstance(this);
     }
     m_status = Status.Stopped;
 }
Пример #10
0
 public void SetEvent(FMOD.Event evt)
 {
     if (evt == null) {
         if (m_runtimeEvent != null) {
             if (m_eventSystemHandle != null &&
                 m_eventSystemHandle.getEventSystem() != null &&
                 m_eventSystemHandle.getEventSystem().wasCleaned() == false) {
                 Stop();
                 CleanParameters();
                 m_eventSystemHandle.getEventSystem().releaseRunningInstance(this);
             }
             freeEventData();
             m_runtimeEvent = null;
         }
     } else {
         m_runtimeEvent = evt;
         foreach (FmodRuntimeEventParameter param in getParameters()) {
             param.SetEvent(m_runtimeEvent);
         }
         setMinRange(getMinRange());
         setMaxRange(getMaxRange());
         if (! m_selfHandle.IsAllocated) {
             m_selfHandle = GCHandle.Alloc(this, GCHandleType.Normal);
         }
         ERRCHECK(evt.setCallback(FmodEventAudioSource.EventStoppedCallbackStatic, (IntPtr)m_selfHandle));
     }
 }
Пример #11
0
        private static bool PlayEvent(string eventName, Func <Vector3> getPosFunc = null)
        {
            if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 ||
                  GameDataManager.GameType == GameDataManager.GameTypes.DS1R ||
                  GameDataManager.GameType == GameDataManager.GameTypes.DS3 ||
                  GameDataManager.GameType == GameDataManager.GameTypes.SDT))
            {
                return(false);
            }

            bool result = false;

            Main.WinForm.Invoke(new Action(() =>
            {
                FMOD.EventProject evProject = null;

                bool foundEvent = false;

                FMOD.Event newEvent = null;

                foreach (var fevName in LoadedFEVs)
                {
                    var fres = _eventSystem.getProject(fevName, ref evProject);
                    if (fres == RESULT.OK)
                    {
                        int groupCount = 0;
                        fres           = evProject.getNumGroups(ref groupCount);
                        if (fres == RESULT.OK)
                        {
                            for (int i = 0; i < groupCount; i++)
                            {
                                FMOD.EventGroup innerGroup = null;
                                fres = evProject.getGroupByIndex(i, cacheevents: false, ref innerGroup);
                                if (fres == RESULT.OK)
                                {
                                    fres = innerGroup.getEvent(eventName, EVENT_MODE.DEFAULT, ref newEvent);
                                    if (fres == RESULT.OK)
                                    {
                                        foundEvent = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                if (!foundEvent)
                {
                    result = false;
                    return;
                }

                ERRCHECK(newEvent.setVolume(BaseSoundVolume * AdjustSoundVolume));

                if (getPosFunc != null)
                {
                    lock (_lock_eventsToUpdate)
                    {
                        _eventsToUpdate.Add(new FmodEventUpdater(newEvent, getPosFunc, eventName));
                    }
                }

                ERRCHECK(newEvent.start());
                result = true;
            }));

            return(result);
        }
Пример #12
0
 public FmodEventUpdater(FMOD.Event evt, Func <Vector3> getPosFunc, string name)
 {
     EventName  = name;
     Event      = evt;
     GetPosFunc = getPosFunc;
 }
Пример #13
0
        private static bool PlayEvent(string eventName, Func <Vector3> getPosFunc, int?stateInfo)
        {
            //if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 ||
            //   GameDataManager.GameType == GameDataManager.GameTypes.DS1R ||
            //   GameDataManager.GameType == GameDataManager.GameTypes.DS3 ||
            //   GameDataManager.GameType == GameDataManager.GameTypes.SDT))
            //{
            //    return false;
            //}

            bool result = false;

            Main.WinForm.Invoke(new Action(() =>
            {
                FMOD.EventProject evProject = null;

                bool foundEvent = false;

                FMOD.Event newEvent         = null;
                string newEvent_FullFevPath = null;

                foreach (var fevName in LoadedFEVs)
                {
                    var fres = _eventSystem.getProject(fevName, ref evProject);
                    if (fres == RESULT.OK)
                    {
                        int groupCount = 0;
                        fres           = evProject.getNumGroups(ref groupCount);
                        if (fres == RESULT.OK)
                        {
                            bool searchGroup(FMOD.EventGroup grp)
                            {
                                fres = grp.getEvent(eventName, EVENT_MODE.DEFAULT, ref newEvent);
                                if (fres == RESULT.OK)
                                {
                                    newEvent_FullFevPath = _loadedFEVs_FullPaths[fevName];
                                    return(true); // Returning from searchGroup() lol
                                }
                                int numInnerGroups = 0;
                                fres = grp.getNumGroups(ref numInnerGroups);

                                if (fres == RESULT.OK)
                                {
                                    for (int j = 0; j < numInnerGroups; j++)
                                    {
                                        FMOD.EventGroup innerInnerGroup = null;
                                        fres = grp.getGroupByIndex(j, false, ref innerInnerGroup);
                                        if (fres == RESULT.OK)
                                        {
                                            if (searchGroup(innerInnerGroup))
                                            {
                                                newEvent_FullFevPath = _loadedFEVs_FullPaths[fevName];
                                                return(true);
                                            }
                                        }
                                    }
                                }

                                return(false);
                            }

                            for (int i = 0; i < groupCount; i++)
                            {
                                FMOD.EventGroup innerGroup = null;
                                fres = evProject.getGroupByIndex(i, cacheevents: false, ref innerGroup);
                                if (fres == RESULT.OK)
                                {
                                    if (searchGroup(innerGroup))
                                    {
                                        foundEvent = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                if (!foundEvent)
                {
                    result = false;
                    return;
                }

                lock (_lock_MediaRoot)
                {
                    UpdateMediaRoot(Path.GetDirectoryName(newEvent_FullFevPath));

                    ERRCHECK(newEvent.setVolume(BaseSoundVolume * (AdjustSoundVolume / 100)));

                    if (getPosFunc != null)
                    {
                        lock (_lock_eventsToUpdate)
                        {
                            _eventsToUpdate.Add(new FmodEventUpdater(newEvent, getPosFunc, eventName, stateInfo));
                        }
                    }

                    ERRCHECK(newEvent.start());
                    result = true;
                }
            }));

            return(result);
        }
Пример #14
0
 // PLAY THE SOUND OF THE CURRENT EVENT
 public void start(ref FMOD.Event evt)
 {
     evt.start();
 }
Пример #15
0
        public RESULT createEventQueueEntry(Event _event, ref EventQueueEntry entry)
        {
            RESULT result = RESULT.OK;
            IntPtr entryraw = new IntPtr();

            try
            {
                result = FMOD_EventSystem_CreateEventQueueEntry(eventsystemraw, _event.getRaw(), ref entryraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (entry == null)
            {
                EventQueueEntry entrynew = new EventQueueEntry();
                entrynew.setRaw(entryraw);
                entry = entrynew;
            }
            else
            {
                entry.setRaw(entryraw);
            }

            return result;
        }
Пример #16
0
    protected void CleanRuntimeEvent()
    {
        CleanParameters();
        // replace the member handle by a tmp handle created here... or not. it could lead to another one being created.
        if (m_runtimeEvent != null && m_eventSystemHandle != null) {
            if (m_eventSystemHandle.getEventSystem().wasCleaned() == false) {
                FMOD.RESULT result = FMOD.RESULT.OK;

                result = m_runtimeEvent.stop(false);
                SetEvent(null);
                ERRCHECK(result);
                if (result != FMOD.RESULT.ERR_INVALID_HANDLE) {
                    //m_runtimeEvent.release(true, false); //we should check EVENTPROPERTY_EVENTTYPE to know if it is a simple event, and only call it if the event is simple
                }
            }
            m_runtimeEvent = null;
        }
    }
Пример #17
0
        public RESULT getEventBySystemID(uint systemid, EVENT_MODE mode, ref Event _event)
        {
            RESULT result   = RESULT.OK;
            IntPtr eventraw = new IntPtr();
            Event eventnew  = null;

            try
            {
                result = FMOD_EventSystem_GetEventBySystemID(eventsystemraw, systemid, mode, ref eventraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (_event == null)
            {
                eventnew = new Event();
                eventnew.setRaw(eventraw);
                _event = eventnew;
            }
            else
            {
                _event.setRaw(eventraw);
            }

            return result;
        }
Пример #18
0
 // Stop's the sound of the current Event
 public void stop(ref FMOD.Event evt)
 {
     evt.stop();
 }