/// <summary> /// Loads a synthesizer patch at runtime. /// </summary> /// <param name="patch">Reference to the patch object.</param> public void LoadPatch(HelmPatch patch) { FieldInfo[] fields = typeof(HelmPatchSettings).GetFields(); Native.HelmClearModulations(channel); List <float> values = new List <float>(); values.Add(0.0f); int index = 1; foreach (FieldInfo field in fields) { if (!field.FieldType.IsArray && !field.IsLiteral) { float val = (float)field.GetValue(patch.patchData.settings); Native.HelmSetParameterValue(channel, index, val); values.Add(val); index++; } } for (int i = 0; i < synthParameters.Count; ++i) { SetParameterAtIndex(i, values[(int)synthParameters[i].parameter]); } int modulationIndex = 0; foreach (HelmModulationSetting modulation in patch.patchData.settings.modulations) { if (modulationIndex >= HelmPatchSettings.kMaxModulations) { Debug.LogWarning("Only " + HelmPatchSettings.kMaxModulations + " modulations are currently supported in the Helm Unity plugin."); break; } Native.HelmAddModulation(channel, modulationIndex, modulation.source, modulation.destination, modulation.amount); modulationIndex++; } }