Пример #1
0
 public void SetReverb(FmodReverb reverb)
 {
     if (m_reverb == null)
     {
         m_reverb = reverb;
     }
 }
Пример #2
0
    protected void loadReverbsFromFile(FmodEventAsset asset)
    {
        List <FmodReverb> reverbs = new List <FmodReverb>();

        FMOD.REVERB_PROPERTIES curReverb = new FMOD.REVERB_PROPERTIES();
        IntPtr curReverbName             = new IntPtr();
        string curReverbNameAsString;
        int    numReverbs = 0;

        FMOD.RESULT result    = FMOD.RESULT.OK;
        FmodReverb  newReverb = null;

        result = getEventSystem().getNumReverbPresets(ref numReverbs);
        ERRCHECK(result);
        if (result == FMOD.RESULT.OK)
        {
            for (int i = 0; i < numReverbs; i++)
            {
                result = getEventSystem().getReverbPresetByIndex(i, ref curReverb, ref curReverbName);
                ERRCHECK(result);
                if (result == FMOD.RESULT.OK)
                {
                    curReverbNameAsString = Marshal.PtrToStringAnsi(curReverbName);
                    newReverb             = ScriptableObject.CreateInstance(typeof(FmodReverb)) as FmodReverb;
                    newReverb.Initialize(curReverbNameAsString, curReverb);
                    reverbs.Add(newReverb);
                }
            }
        }
        asset.setReverbs(reverbs);
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        FmodEventSystemHandle handle = new FmodEventSystemHandle();
        ReverbSettings.FmodReverbPreset globalReverbSetting = FmodReverb.GLOBAL_REVERB;
        m_globalReverb = FmodReverb.CreateInstance(typeof(FmodReverb)) as FmodReverb;
        GameObject obj = GameObject.Instantiate(Resources.Load("FmodReverbZone")) as GameObject;
        m_globalReverbZone = obj.GetComponent<FmodReverbZone>();

        if (m_globalReverbZone == null) {
            Debug.LogError("Prefab for FmodReverbZone should have component FmodReverbZone !");
        }
        m_globalReverbZone.SetGlobal(true);
        m_globalReverbZone.name = "Global Reverb";
        m_globalReverb.Initialize(globalReverbSetting.Name, globalReverbSetting.Properties);
        m_globalReverbZone.SetReverb(m_globalReverb);
        m_globalReverbZone.Priority = 0;
        m_globalReverbZone.fadeTime = 0;
        m_currentZone = m_globalReverbZone;
        StackReverb (m_currentZone);
        handle.getEventSystem().setReverbImmediate(globalReverbSetting.Properties);
        handle.Dispose();
        m_startProperties = globalReverbSetting.Properties;
        m_curProperties = globalReverbSetting.Properties;
        m_endProperties = globalReverbSetting.Properties;
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        FmodEventSystemHandle handle = new FmodEventSystemHandle();

        ReverbSettings.FmodReverbPreset globalReverbSetting = FmodReverb.GLOBAL_REVERB;
        m_globalReverb = FmodReverb.CreateInstance(typeof(FmodReverb)) as FmodReverb;
        GameObject obj = GameObject.Instantiate(Resources.Load("FmodReverbZone")) as GameObject;

        m_globalReverbZone = obj.GetComponent <FmodReverbZone>();

        if (m_globalReverbZone == null)
        {
            Debug.LogError("Prefab for FmodReverbZone should have component FmodReverbZone !");
        }
        m_globalReverbZone.SetGlobal(true);
        m_globalReverbZone.name = "Global Reverb";
        m_globalReverb.Initialize(globalReverbSetting.Name, globalReverbSetting.Properties);
        m_globalReverbZone.SetReverb(m_globalReverb);
        m_globalReverbZone.Priority = 0;
        m_globalReverbZone.fadeTime = 0;
        m_currentZone = m_globalReverbZone;
        StackReverb(m_currentZone);
        handle.getEventSystem().setReverbImmediate(globalReverbSetting.Properties);
        handle.Dispose();
        m_startProperties = globalReverbSetting.Properties;
        m_curProperties   = globalReverbSetting.Properties;
        m_endProperties   = globalReverbSetting.Properties;
    }
Пример #5
0
    public void OnSceneGUI(SceneView sceneView)
    {
        if (m_ongoingDrag && Event.current.type != EventType.MouseMove)
        {
            if (Event.current.type == EventType.MouseUp || Event.current.type == EventType.MouseDown)
            {
                _clearDragAndDrop();
            }
            if (Event.current.type == EventType.DragUpdated)
            {
                DragAndDrop.AcceptDrag();
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                Vector2    mousePos = Event.current.mousePosition;
                Ray        ray      = HandleUtility.GUIPointToWorldRay(mousePos);
                RaycastHit hitInfo  = new RaycastHit();

                if (Physics.Raycast(ray, out hitInfo))
                {
                    EditorGUIUtility.PingObject(hitInfo.collider.gameObject);
                }
                // todo: preview of object creation ?
                Event.current.Use();
            }
            else if (Event.current.type == EventType.DragPerform)
            {
                Vector2    mousePos = Event.current.mousePosition;
                Vector3    worldPos = new Vector3();
                Ray        ray      = HandleUtility.GUIPointToWorldRay(mousePos);
                RaycastHit hitInfo  = new RaycastHit();

                if (Physics.Raycast(ray, out hitInfo))
                {
                    worldPos = hitInfo.point;
                }
                else
                {
                    worldPos = ray.origin + ray.direction.normalized * 10;
                }

                FmodEvent  srcEvent  = DragAndDrop.objectReferences[0] as FmodEvent;
                FmodReverb srcReverb = DragAndDrop.objectReferences[0] as FmodReverb;

                if (srcEvent != null)
                {
                    CreateEventInstance(srcEvent, worldPos, hitInfo);
                }
                else if (srcReverb)
                {
                    CreateReverbZone(srcReverb, worldPos, hitInfo);
                }

                _clearDragAndDrop();
                Event.current.Use();
            }
        }
    }
Пример #6
0
        public Attributes?Get3DAttributes()
        {
            VECTOR pos = new VECTOR();
            float  min = 0, max = 0;

            if (!FmodReverb.get3DAttributes(ref pos, ref min, ref max).Check(Suppressions()))
            {
                return(null);
            }

            return(new Attributes(pos.FromFmod(), min, max));
        }
Пример #7
0
    public FmodReverb getMatchingReverb(FmodReverb oldReverb)
    {
        List <FmodReverb> reverbs = getReverbs();

        foreach (FmodReverb r in reverbs)
        {
            if (r.getName() == oldReverb.getName())
            {
                return(r);
            }
        }
        return(null);
    }
Пример #8
0
    public void UpdateGlobalReverb()
    {
        if (m_currentZone == m_globalReverbZone && m_globalReverbZone != null && m_globalReverb != null) {
            FmodEventSystemHandle handle = new FmodEventSystemHandle();
            ReverbSettings.FmodReverbPreset globalReverbSetting = ReverbSettings.Get().CurPreset;

            m_globalReverb = m_globalReverbZone.GetReverb();
            m_globalReverb.Initialize(globalReverbSetting.Name, globalReverbSetting.Properties);
            m_curProperties = m_globalReverb.getProperties();
            m_endProperties = m_curProperties;
            handle.getEventSystem().setReverbImmediate(m_curProperties);
            handle.Dispose();
        }
    }
Пример #9
0
    public void UpdateGlobalReverb()
    {
        if (m_currentZone == m_globalReverbZone && m_globalReverbZone != null && m_globalReverb != null)
        {
            FmodEventSystemHandle           handle = new FmodEventSystemHandle();
            ReverbSettings.FmodReverbPreset globalReverbSetting = ReverbSettings.Get().CurPreset;

            m_globalReverb = m_globalReverbZone.GetReverb();
            m_globalReverb.Initialize(globalReverbSetting.Name, globalReverbSetting.Properties);
            m_curProperties = m_globalReverb.getProperties();
            m_endProperties = m_curProperties;
            handle.getEventSystem().setReverbImmediate(m_curProperties);
            handle.Dispose();
        }
    }
Пример #10
0
    protected void CreateReverbZone(FmodReverb srcReverb, Vector3 worldPos, RaycastHit hitInfo)
    {
        GameObject     obj        = GameObject.Instantiate(Resources.Load("FmodReverbZone"), worldPos, Quaternion.identity) as GameObject;
        FmodReverbZone reverbZone = obj.GetComponent <FmodReverbZone>();

        if (reverbZone == null)
        {
            Debug.LogError("Prefab for FmodReverbZone should have component FmodReverbZone !");
        }
        else
        {
            reverbZone.SetReverb(srcReverb);
            obj.name = "FmodReverbZone (" + srcReverb.name + ")";
        }
    }
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        if (m_isInTransition)
        {
            FmodEventSystemHandle handle = new FmodEventSystemHandle();

            m_curTransitionTime += Time.deltaTime;
            if (m_curTransitionTime >= m_curTransitionDuration)
            {
                m_curTransitionTime = m_curTransitionDuration;
                m_isInTransition    = false;
            }
            m_curProperties = FmodReverb.getLerpedProperties(m_startProperties, m_endProperties, m_curTransitionTime / m_curTransitionDuration);
            handle.getEventSystem().setReverbImmediate(m_curProperties);
            handle.Dispose();
        }
    }
Пример #12
0
    private void _SetupDragAndDrop(FmodEventAsset asset)
    {
        Event e = Event.current;

        if (e.type == EventType.MouseUp || e.type == EventType.MouseDown)
        {
            _clearDragAndDrop();
        }
        if (e.type == EventType.MouseDrag)
        {
            FmodEvent  fmodEvent = _getHoveredEvent();
            FmodReverb reverb    = _getHoveredReverb();

            if (fmodEvent != null)
            {
                DragAndDrop.PrepareStartDrag();
                DragAndDrop.paths            = new string[0];
                DragAndDrop.objectReferences = new Object[1] {
                    fmodEvent
                };
                DragAndDrop.SetGenericData(ONGOING_DRAG_KEY, true);
                DragAndDrop.SetGenericData(SOURCE_ASSET_KEY, asset);
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                DragAndDrop.StartDrag("Creating sound from event '" + fmodEvent.getName() + "'");
                m_ongoingDrag = true;
                e.Use();
            }
            else if (reverb != null)
            {
                DragAndDrop.PrepareStartDrag();
                DragAndDrop.paths            = new string[0];
                DragAndDrop.objectReferences = new Object[1] {
                    reverb
                };
                DragAndDrop.SetGenericData(ONGOING_DRAG_KEY, true);
                DragAndDrop.SetGenericData(SOURCE_ASSET_KEY, asset);
                DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                DragAndDrop.StartDrag("Creating reverb zone from reverb '" + reverb.getName() + "'");
                m_ongoingDrag = true;
                e.Use();
            }
        }
    }
    static void UpdateEventAsset(FmodEventAsset oldAsset, FmodEventAsset newAsset)
    {
        FmodEventAudioSource[] allSources     = Resources.FindObjectsOfTypeAll(typeof(FmodEventAudioSource)) as FmodEventAudioSource[];
        FmodReverbZone[]       allReverbZones = Resources.FindObjectsOfTypeAll(typeof(FmodReverbZone)) as FmodReverbZone[];

        foreach (FmodEventAudioSource source in allSources)
        {
            source.CheckForOldFormat();
            if (source.getSource() != null)
            {
                FmodEvent oldEvent = source.getSource();
                FmodEvent newEvent = newAsset.getMatchingEvent(oldEvent);

                if (newEvent == null)
                {
                    source.SetSourceEvent(null);
                }
                else
                {
                    source.UpdateExistingEvent(newEvent);
                }
            }
        }
        foreach (FmodReverbZone zone in allReverbZones)
        {
            if (zone.GetReverb() != null)
            {
                FmodReverb oldReverb = zone.GetReverb();
                FmodReverb newReverb = newAsset.getMatchingReverb(oldReverb);

                if (newReverb == null)
                {
                    zone.ResetReverb();
                }
                else
                {
                    zone.ResetReverb();
                    zone.SetReverb(newReverb);
                }
            }
        }
    }
Пример #14
0
        public bool Set3DAttributes(Attributes attr)
        {
            var pos = attr.Position.ToFmod();

            return(FmodReverb.set3DAttributes(ref pos, attr.Min, attr.Max).Check(Suppressions()));
        }
Пример #15
0
 public void SetReverb(FmodReverb reverb)
 {
     if (m_reverb == null) {
         m_reverb = reverb;
     }
 }
Пример #16
0
 public void ResetReverb()
 {
     m_reverb = null;
 }
Пример #17
0
 public void ResetReverb()
 {
     m_reverb = null;
 }
Пример #18
0
    public FmodReverb getMatchingReverb(FmodReverb oldReverb)
    {
        List<FmodReverb> reverbs = getReverbs();

        foreach (FmodReverb r in reverbs) {
            if (r.getName() == oldReverb.getName()) {
                return (r);
            }
        }
        return (null);
    }
Пример #19
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        if (serializedObject != null && serializedObject.targetObject != null)
        {
            FmodReverbZone     zone         = serializedObject.targetObject as FmodReverbZone;
            FmodReverb         reverb       = zone.GetReverb();
            SerializedProperty fadeTimeProp = serializedObject.FindProperty("fadeTime");
            SerializedProperty priorityProp = serializedObject.FindProperty("m_priority");
            bool isGlobal = zone.IsGlobal();

            if (reverb != null)
            {
                EditorGUILayout.LabelField("Name", reverb.getName() + (isGlobal ? " (global reverb)" : ""));
                if (isGlobal)
                {
                    GUI.enabled = false;
                }
                EditorGUILayout.Slider(fadeTimeProp, 0, 100, "Fade Time");
                EditorGUILayout.Slider(priorityProp, 0, 10000, "Priority");
                if (isGlobal)
                {
                    GUI.enabled = true;
                }
                EditorGUILayout.Separator();
                EditorGUILayout.PrefixLabel("Parameters");
                EditorGUI.indentLevel += 1;
                GUI.enabled            = false;
                EditorGUILayout.IntSlider("Master level", (int)((float)reverb.Room / 100), -100, 0);
                EditorGUILayout.IntSlider("Decay Time", (int)(reverb.DecayTime * 1000), 100, 20000);
                EditorGUILayout.Slider("HF Decay Ratio", reverb.DecayHFRatio, 0.1f, 2);
                EditorGUILayout.IntSlider("Pre Delay", (int)(reverb.ReflectionsDelay * 1000), 0, 300);
                EditorGUILayout.IntSlider("Late Delay", (int)(reverb.ReverbDelay * 1000), 0, 100);
                EditorGUILayout.Slider("Early Reflections", ((float)reverb.Reflections / 100), -100, 10);
                EditorGUILayout.Slider("Late Reflections", ((float)reverb.Reverb / 100), -100, 20);
                EditorGUILayout.IntSlider("Diffusion", (int)reverb.Diffusion, 0, 100);
                EditorGUILayout.IntSlider("Density", (int)reverb.Density, 0, 100);
                EditorGUILayout.Slider("HF Gain", ((float)reverb.RoomHF / 100), -100, 0);
                EditorGUILayout.Slider("LF Gain", ((float)reverb.RoomLF / 100), -100, 0);
                EditorGUILayout.IntSlider("HF Crossover", (int)reverb.HFReference, 20, 20000);
                EditorGUILayout.IntSlider("LF Crossover", (int)reverb.LFReference, 20, 1000);
                GUI.enabled            = true;
                EditorGUI.indentLevel -= 1;

                serializedObject.ApplyModifiedProperties();
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Name");
                EditorGUILayout.HelpBox("No Reverb is set", MessageType.Error);
                EditorGUILayout.EndHorizontal();
                GUI.enabled = false;
                EditorGUILayout.FloatField("Fade Time", 3);
                GUI.enabled = true;
                EditorGUILayout.Separator();
                EditorGUILayout.PrefixLabel("Parameters");
                GUI.enabled            = false;
                EditorGUI.indentLevel += 1;
                EditorGUILayout.IntSlider("Master level", 0, -100, 0);
                EditorGUILayout.IntSlider("Decay Time", 100, 100, 20000);
                EditorGUILayout.Slider("HF Decay Ratio", 0.1f, 0.1f, 2);
                EditorGUILayout.IntSlider("Pre Delay", 0, 0, 300);
                EditorGUILayout.IntSlider("Late Delay", 0, 0, 100);
                EditorGUILayout.Slider("Early Reflections", -100, -100, 10);
                EditorGUILayout.Slider("Late Reflections", -100, -100, 20);
                EditorGUILayout.IntSlider("Diffusion", 0, 0, 100);
                EditorGUILayout.IntSlider("Density", 0, 0, 100);
                EditorGUILayout.Slider("HF Gain", -100, -100, 0);
                EditorGUILayout.Slider("LF Gain", -100, -100, 0);
                EditorGUILayout.IntSlider("HF Crossover", 20, 20, 20000);
                EditorGUILayout.IntSlider("LF Crossover", 20, 20, 1000);
                EditorGUI.indentLevel -= 1;
                GUI.enabled            = true;
            }
        }
    }
Пример #20
0
 protected void CreateReverbZone(FmodReverb srcReverb, Vector3 worldPos, RaycastHit hitInfo)
 {
     GameObject obj = GameObject.Instantiate(Resources.Load("FmodReverbZone"), worldPos, Quaternion.identity) as GameObject;
     FmodReverbZone reverbZone = obj.GetComponent<FmodReverbZone>();
     if (reverbZone == null) {
         Debug.LogError("Prefab for FmodReverbZone should have component FmodReverbZone !");
     } else {
         reverbZone.SetReverb(srcReverb);
         obj.name = "FmodReverbZone (" + srcReverb.name + ")";
     }
 }