private void timer1_Tick(object sender, System.EventArgs e)
        {
            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.getEvent("examples/FeatureDemonstration/Basics/SimpleEvent", FMOD.EVENT_MODE.DEFAULT, ref evt));

                initialised = true;
            }


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

            if (eventstart)
            {
                ERRCHECK(evt.start());
            }

            /*
             *  Clean up and exit
             */
            if (exit)
            {
                ERRCHECK(result = eventsystem.release());

                Application.Exit();
            }
        }
Beispiel #2
0
    public void updateSystem(bool force3DSet)
    {
        FMOD.RESULT result = FMOD.RESULT.OK;

        if (m_eventSystem != null && m_eventSystemWasInit)
        {
            if (getAudioListener() != null &&
                (force3DSet || (Time.timeSinceLevelLoad - m_previousListenerUpdateTime) > 0.001f))
            {
                FMOD.VECTOR pos     = new FMOD.VECTOR();
                FMOD.VECTOR vel     = new FMOD.VECTOR();
                FMOD.VECTOR forward = new FMOD.VECTOR();
                FMOD.VECTOR up      = new FMOD.VECTOR();

                pos.x = m_audioListener.transform.position.x;
                pos.y = m_audioListener.transform.position.y;
                pos.z = m_audioListener.transform.position.z;
                if (Time.timeSinceLevelLoad - m_previousListenerUpdateTime > 0)
                {
                    vel.x = (pos.x - m_previousListenerPos.x) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime);
                    vel.y = (pos.y - m_previousListenerPos.y) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime);
                    vel.z = (pos.z - m_previousListenerPos.z) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime);
                }
                forward.x = m_audioListener.transform.forward.x;
                forward.y = m_audioListener.transform.forward.y;
                forward.z = m_audioListener.transform.forward.z;
                up.x      = m_audioListener.transform.up.x;
                up.y      = m_audioListener.transform.up.y;
                up.z      = m_audioListener.transform.up.z;

                result = m_eventSystem.set3DListenerAttributes(0, ref pos, ref vel, ref forward, ref up);
                ERRCHECK(result);
                result = m_system.set3DListenerAttributes(0, ref pos, ref vel, ref forward, ref up);
                ERRCHECK(result);


                m_previousListenerPos = m_audioListener.transform.position;
//					m_previousListenerForward = m_audioListener.transform.forward;
//					m_previousListenerUp = m_audioListener.transform.up;
                m_previousListenerUpdateTime = Time.timeSinceLevelLoad;
            }
            result = m_eventSystem.update();
            ERRCHECK(result);
            result = m_system.update();
            ERRCHECK(result);
        }
    }
        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();
            }
        }
Beispiel #4
0
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            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/AdvancedTechniques", false, ref eventgroup));
                ERRCHECK(result = eventgroup.getEvent("car", FMOD.EVENT_MODE.DEFAULT, ref car));

                ERRCHECK(result = eventsystem.getCategory("master", ref mastercategory));

                ERRCHECK(result = car.getParameter("load", ref load));
                ERRCHECK(result = load.getRange(ref load_min, ref load_max));
                ERRCHECK(result = load.setValue(load_max));

                ERRCHECK(result = car.getParameterByIndex(0, ref rpm));
                ERRCHECK(result = rpm.getRange(ref rpm_min, ref rpm_max));
                ERRCHECK(result = rpm.setValue(1000.0f));

                trackBarRPM.Minimum = (int)rpm_min;
                trackBarRPM.Maximum = (int)rpm_max;

                trackBarLoad.Minimum = (int)load_min;
                trackBarLoad.Maximum = (int)load_max;

                trackBarRPM.Value  = 1000;
                trackBarLoad.Value = (int)load_max;

                ERRCHECK(result = car.start());

                initialised = true;
            }


            /*
             *  "Main Loop"
             */
            if (trackbarscroll)
            {
                ERRCHECK(result = rpm.setValue((float)trackBarRPM.Value));
                ERRCHECK(result = load.setValue((float)trackBarLoad.Value));

                trackbarscroll = false;
            }

            float rpmvalue = 0.0f;

            ERRCHECK(result = rpm.getValue(ref rpmvalue));

            statusBar.Text = "RPM Value = " + rpmvalue;

            ERRCHECK(result = eventsystem.update());

            /*
             *  Clean up and exit
             */
            if (exit)
            {
                ERRCHECK(result = eventgroup.freeEventData());
                ERRCHECK(result = eventsystem.release());

                Application.Exit();
            }
        }