コード例 #1
0
ファイル: HelmSynthUI.cs プロジェクト: msp/virtual-gallery
        void LoadPatch(IAudioEffectPlugin plugin, string path)
        {
            string          patchText = File.ReadAllText(path);
            HelmPatchFormat patch     = JsonUtility.FromJson <HelmPatchFormat>(patchText);

            FieldInfo[] fields = typeof(HelmPatchSettings).GetFields();

            foreach (FieldInfo field in fields)
            {
                if (!field.FieldType.IsArray && !field.IsLiteral)
                {
                    float  val  = (float)field.GetValue(patch.settings);
                    string name = HelmPatchSettings.ConvertToPlugin(field.Name);
                    plugin.SetFloatParameter(name, val);
                }
            }

            for (int i = 0; i < HelmPatchSettings.kMaxModulations; ++i)
            {
                plugin.SetFloatParameter("mod" + i + "value", 0.0f);
            }

            int modulationIndex = 0;

            foreach (HelmModulationSetting modulation in patch.settings.modulations)
            {
                if (modulationIndex >= HelmPatchSettings.kMaxModulations)
                {
                    Debug.LogWarning("Only 16 modulations are currently supported in the Helm Unity plugin.");
                    break;
                }
                string prefix = "mod" + modulationIndex;

                float source = HelmPatchSettings.GetSourceIndex(modulation.source);
                plugin.SetFloatParameter(prefix + "source", source);
                float dest = HelmPatchSettings.GetDestinationIndex(modulation.destination);
                plugin.SetFloatParameter(prefix + "dest", dest);
                plugin.SetFloatParameter(prefix + "value", modulation.amount);

                modulationIndex++;
            }
        }
コード例 #2
0
ファイル: HelmPatch.cs プロジェクト: msp/virtual-gallery
        public void LoadPatchData(string filePath)
        {
            string patchText = File.ReadAllText(filePath);

            patchData = JsonUtility.FromJson <HelmPatchFormat>(patchText);
        }