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