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)); } }
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(); } }