private void timer1_Tick(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;

            if (!initialised)
            {
                ERRCHECK(result = FMOD.Event_Factory.EventSystem_Create(ref eventsystem));
                ERRCHECK(result = eventsystem.init(64, FMOD.INITFLAGS.NORMAL, (IntPtr)null, FMOD.EVENT_INITFLAGS.NORMAL));
                ERRCHECK(result = eventsystem.setMediaPath("../../../../examples/media/"));
                ERRCHECK(result = eventsystem.load("examples.fev"));
                ERRCHECK(result = eventsystem.getGroup("examples/FeatureDemonstration/SequencingAndStitching", false, ref eventgroup));

                ERRCHECK(result = eventsystem.getSystemObject(ref sys));
                ERRCHECK(result = sys.createStream("../../../../examples/media/tutorial_bank.fsb", (FMOD.MODE._2D | FMOD.MODE.SOFTWARE), ref fsb));

                initialised = true;
            }

            /*
             *  "Main Loop"
             */
            ERRCHECK(result = eventsystem.update());

            if (eventstart)
            {
                ERRCHECK(result = eventgroup.getEvent("ProgrammerSounds", FMOD.EVENT_MODE.DEFAULT, ref _event));
                ERRCHECK(result = _event.setCallback(eventcallback, (IntPtr)null));
                ERRCHECK(result = _event.start());

                eventstart = false;
            }

            /*
             *  Cleanup and exit
             */
            if (exit)
            {
                ERRCHECK(result = eventsystem.unload());
                ERRCHECK(result = fsb.release());
                ERRCHECK(result = eventsystem.release());

                Application.Exit();
            }
        }
Example #2
0
    private void clean(bool checkForHandles)
    {
        int nbEventSystemHandles = FmodEventSystemHandle.NbHandles;

        if (m_eventSystem != null &&
            (checkForHandles == false || nbEventSystemHandles <= 1))
        {
            List <FmodEventAudioSource> tmpList = m_eventPoolManager.getAllActiveSources();
            foreach (FmodEventAudioSource src in tmpList)
            {
                if (src != null)
                {
                    src.Clean();
                }
            }
            if (m_musicSystem != null)
            {
                m_musicSystem.release();
                m_musicSystem = null;
            }
            if (_unloadAllFiles())
            {
                ERRCHECK(m_eventSystem.unload());
            }
            if (m_eventSystem != null)
            {
                ERRCHECK(m_eventSystem.release());
                m_eventSystem = null;
            }

            if (m_system != null)
            {
                ERRCHECK(m_system.release());
                m_system = null;
            }

            m_eventSystemWasCleaned = true;
            m_eventSystemWasInit    = false;
            WasCleaned = true;
            FmodEventSystem.m_FmodEventSystem = null;
        }
    }