/// <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++; } }
/// <summary> /// Changes a Helm synthesizer parameter value. /// e.g. Lower the pitch of the oscillator by setting the transpose to -12 semitones. /// </summary> /// <param name="parameter">The parameter to be changed.</param> /// <param name="newValue">The value to change the parameter to.</param> public void SetParameterValue(CommonParam parameter, float newValue) { Native.HelmSetParameterValue(channel, (int)parameter, newValue); }