コード例 #1
0
 private static void CollectSoundDescriptions()
 {
     Bank[] array = null;
     RuntimeManager.StudioSystem.getBankList(out array);
     Bank[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         Bank bank = array2[i];
         bank.getEventList(out EventDescription[] array3);
         for (int j = 0; j < array3.Length; j++)
         {
             EventDescription eventDescription = array3[j];
             eventDescription.getPath(out string path);
             HashedString     key   = path;
             SoundDescription value = default(SoundDescription);
             value.path = path;
             float distance = 0f;
             eventDescription.getMaximumDistance(out distance);
             if (distance == 0f)
             {
                 distance = 60f;
             }
             value.falloffDistanceSq = distance * distance;
             List <OneShotSoundParameterUpdater> list = new List <OneShotSoundParameterUpdater>();
             int count = 0;
             eventDescription.getParameterCount(out count);
             SoundDescription.Parameter[] array4 = new SoundDescription.Parameter[count];
             for (int k = 0; k < count; k++)
             {
                 eventDescription.getParameterByIndex(k, out PARAMETER_DESCRIPTION parameter);
                 string text = parameter.name;
                 array4[k] = new SoundDescription.Parameter
                 {
                     name = new HashedString(text),
                     idx  = k
                 };
                 OneShotSoundParameterUpdater value2 = null;
                 if (parameterUpdaters.TryGetValue(text, out value2))
                 {
                     list.Add(value2);
                 }
             }
             value.parameters = array4;
             value.oneShotParameterUpdaters = list.ToArray();
             soundDescriptions[key]         = value;
         }
     }
 }
コード例 #2
0
ファイル: FMODCommon.cs プロジェクト: DevZhav/The-Forest
    public static int FindParameterIndex(EventDescription eventDescription, string parameterName)
    {
        int num = 0;

        UnityUtil.ERRCHECK(eventDescription.getParameterCount(out num));
        for (int i = 0; i < num; i++)
        {
            PARAMETER_DESCRIPTION parameter_DESCRIPTION;
            UnityUtil.ERRCHECK(eventDescription.getParameterByIndex(i, out parameter_DESCRIPTION));
            if (parameter_DESCRIPTION.name == parameterName)
            {
                return(i);
            }
        }
        return(-1);
    }
コード例 #3
0
ファイル: FMODCommon.cs プロジェクト: DevZhav/The-Forest
    private static int GetParameterIndex(string eventPath, string parameterName)
    {
        EventDescription eventDescription = FMOD_StudioSystem.instance.GetEventDescription(eventPath, true);

        if (eventDescription != null)
        {
            int num;
            UnityUtil.ERRCHECK(eventDescription.getParameterCount(out num));
            for (int i = 0; i < num; i++)
            {
                PARAMETER_DESCRIPTION parameter_DESCRIPTION;
                UnityUtil.ERRCHECK(eventDescription.getParameterByIndex(i, out parameter_DESCRIPTION));
                if (parameter_DESCRIPTION.name == parameterName)
                {
                    return(i);
                }
            }
        }
        return(-1);
    }
コード例 #4
0
ファイル: OuiSoundTest.cs プロジェクト: szbrain/Everest
        private void UpdateSelectedPath()
        {
            selectedBankPath = "";
            selectedPath     = "";
            musicParamMenu.Clear();
            musicParams.Clear();

            patch_Audio.System.getBankList(out Bank[] banks);
            int bankI = 0;

            for (int i = 0; i <= 1; i++)
            {
                bankI += digits[i] * (int)Math.Pow(0x10, (2 - 1) - i);
            }
            if (bankI >= banks.Length || !(banks[bankI]?.isValid() ?? false))
            {
                return;
            }

            Bank bank = banks[bankI];

            selectedBankPath = patch_Audio.GetBankName(bank);

            bank.getEventList(out EventDescription[] events);
            List <string> paths = events.Where(e => e?.isValid() ?? false).Select(e => patch_Audio.GetEventName(e)).ToList();

            paths.Sort();

            int eventI = 0;

            for (int i = 2; i < digits.Length; i++)
            {
                eventI += digits[i] * (int)Math.Pow(0x10, (digits.Length - 1) - i);
            }
            if (eventI >= paths.Count)
            {
                return;
            }

            selectedPath = paths[eventI];

            EventDescription eventDescription = Audio.GetEventDescription(selectedPath);

            if (eventDescription != null)
            {
                eventDescription.getParameterCount(out int parameterCount);
                List <string> paramNames = new List <string>();
                for (int i = 0; i < parameterCount; i++)
                {
                    eventDescription.getParameterByIndex(i, out PARAMETER_DESCRIPTION param);
                    paramNames.Add(param.name);
                }
                paramNames.Sort();

                foreach (string paramName in paramNames)
                {
                    eventDescription.getParameter(paramName, out PARAMETER_DESCRIPTION param);

                    if (param.maximum == param.minimum)
                    {
                        continue;
                    }

                    if (musicParamMenu.GetItems().Count == 0)
                    {
                        musicParamMenu.Add(new TextMenu.SubHeader(Dialog.Clean("SOUNDTEST_AUDIOPARAMS")));
                    }

                    if (param.maximum - param.minimum < 3)
                    {
                        // have a 0.1 step
                        musicParamMenu.Add(new TextMenu.Slider(param.name, index => (index / 10f).ToString(), (int)(param.minimum * 10), (int)(param.maximum * 10), (int)(getParamValueOrDefault(param) * 10))
                                           .Change(value => {
                            float newValue          = value / 10f;
                            musicParams[param.name] = newValue;

                            if (playingPath == selectedPath)
                            {
                                playing.setParameterValue(param.name, newValue);
                            }
                        }));
                    }
                    else
                    {
                        // have a 1 step and use an IntSlider.
                        musicParamMenu.Add(new TextMenuExt.IntSlider(param.name, (int)param.minimum, (int)param.maximum, (int)getParamValueOrDefault(param))
                                           .Change(value => {
                            musicParams[param.name] = value;

                            if (playingPath == selectedPath)
                            {
                                playing.setParameterValue(param.name, value);
                            }
                        }));
                    }
                }
            }
        }