public void SetParameterRawValue(MssParameterID paramId, double rawValue)
        {
            if (ALL_PARAMS_ID_LIST.Contains(paramId) == false)
            {
                //paramDict should always contain every possible MssParameterID
                Debug.Assert(false);
                return;
            }

            bool   triggerValueChangedEvent = false;
            double newValue = -1;

            RunFuncOnParamInfo(paramId,
                               paramInfo =>
            {
                double previousValue = paramInfo.GetValue();
                paramInfo.RawValue   = rawValue;
                newValue             = paramInfo.GetValue();

                if (previousValue != newValue)
                {
                    triggerValueChangedEvent = true;
                }
            });

            if (triggerValueChangedEvent && ParameterValueChanged != null)
            {
                ParameterValueChanged(paramId, newValue);
            }
        }
        public void SetParameterMaxValue(MssParameterID paramId, int maxValue)
        {
            if (ALL_PARAMS_ID_LIST.Contains(paramId) == false)
            {
                //paramDict should always contain every possible MssParameterID
                Debug.Assert(false);
                return;
            }

            bool triggerMaxValueChangedEvent = false;

            RunFuncOnParamInfo(paramId,
                               paramInfo =>
            {
                if (paramInfo.MaxValue != maxValue)
                {
                    paramInfo.MaxValue          = maxValue;
                    triggerMaxValueChangedEvent = true;
                }
            });

            if (triggerMaxValueChangedEvent && ParameterMaxValueChanged != null)
            {
                ParameterMaxValueChanged(paramId, maxValue);
            }
        }
        public MssParamInfo GetParameterInfoCopy(MssParameterID parameterId)
        {
            MssParamInfo paramInfoClone = null;

            RunFuncOnParamInfo(parameterId, paramInfo => paramInfoClone = paramInfo.Clone());

            return(paramInfoClone);
        }
Пример #4
0
        /// <summary>
        ///     Listens to changes made from the MSS namespace to the name of a parameter and modifies
        ///     the associated VstParameterManager to reflect the change.
        /// </summary>
        /// <param name="paramId">ID of the changed parameter.</param>
        /// <param name="name">New name of the changed parameter.</param>
        private void MssParameters_NameChanged(MssParameterID paramId, string name)
        {
            VstParameterManager paramMgr;

            //Looks up the VstParameterManager associated with the changed parameter
            VstParameterManagerDict.TryGetRightByLeft(paramId, out paramMgr);
            if (paramMgr.ActiveParameter.Info.Name != name)
            {
                paramMgr.ActiveParameter.Info.Name = GetParamNameFromString(name);
            }
        }
Пример #5
0
 public IReturnStatus <MssParamInfo> GetCopyOfVariableParamInfo(MssParameterID variableParamId)
 {
     lock (this.memberLock)
     {
         bool variableParamIdIsValid = this.variableParamDict.ContainsKey(variableParamId);
         if (variableParamIdIsValid)
         {
             return(new ReturnStatus <MssParamInfo>(this.variableParamDict[variableParamId].Clone()));
         }
         else
         {
             return(new ReturnStatus <MssParamInfo>());
         }
     }
 }
 public IReturnStatus<MssParamInfo> GetCopyOfVariableParamInfo(MssParameterID variableParamId)
 {
     lock (this.memberLock)
     {
         bool variableParamIdIsValid = this.variableParamDict.ContainsKey(variableParamId);
         if (variableParamIdIsValid)
         {
             return new ReturnStatus<MssParamInfo>(this.variableParamDict[variableParamId].Clone());
         }
         else
         {
             return new ReturnStatus<MssParamInfo>();
         }
     }
 }
Пример #7
0
 public void SetVariableParamInfo(MssParamInfo varParamInfo, MssParameterID variableParamId)
 {
     lock (this.memberLock)
     {
         bool variableParamIdIsValid = this.variableParamDict.ContainsKey(variableParamId);
         if (variableParamIdIsValid)
         {
             variableParamDict[variableParamId] = varParamInfo.Clone();
         }
         else
         {
             //variableParamId does not refer to a valid variable parameter id.
             Debug.Assert(false);
             return;
         }
     }
 }
Пример #8
0
 public bool RunFuncOnParamInfo(MssParameterID variableParamId, ParamInfoAccessor variableParamAccessor)
 {
     lock (this.memberLock)
     {
         //TODO: impliment This.
         bool variableParamIdIsValid = this.variableParamDict.ContainsKey(variableParamId);
         if (variableParamIdIsValid)
         {
             variableParamAccessor(this.variableParamDict[variableParamId]);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
 public bool RunFuncOnParamInfo(MssParameterID variableParamId, ParamInfoAccessor variableParamAccessor)
 {
     lock (this.memberLock)
     {
         //TODO: impliment This.
         bool variableParamIdIsValid = this.variableParamDict.ContainsKey(variableParamId);
         if (variableParamIdIsValid)
         {
             variableParamAccessor(this.variableParamDict[variableParamId]);
             return true;
         }
         else
         {
             return false;
         }
     }
 }
        public void SetParamInfo(MssParameterID paramId, MssParamInfo paramInfo)
        {
            MssParamInfo prevParamInfo = GetParameterInfoCopy(paramId);

            if (VARIABLE_PARAM_ID_LIST.Contains(paramId))
            {
                this.variableParamMgr.SetVariableParamInfo(paramInfo, paramId);
            }
            else if (PRESET_PARAM_ID_LIST.Contains(paramId))
            {
                this.activeMappingInfo.GetActiveGraphableEntryManager().RunFuncOnMappingEntry(this.activeMappingInfo.ActiveGraphableEntryId,
                                                                                              (mappingEntry) => mappingEntry.CurveShapeInfo.ParamInfoList[PRESET_PARAM_ID_LIST.IndexOf(paramId)] = paramInfo.Clone());
            }
            else
            {
                //every possible MssParameterID should either be contained in VARIABLE_PARAM_ID_LIST or PRESET_PARAM_ID_LIST.
                Debug.Assert(false);
                return;
            }

            bool paramTypeChanged = (prevParamInfo.paramType != paramInfo.paramType);

            if (prevParamInfo.Name != paramInfo.Name && ParameterNameChanged != null)
            {
                ParameterNameChanged(paramId, paramInfo.Name);
            }

            //We need to check of the param type has changed here because the same raw value
            //can be displayed differently for different param types.
            if ((paramTypeChanged || prevParamInfo.RawValue != paramInfo.RawValue) &&
                ParameterValueChanged != null)
            {
                ParameterValueChanged(paramId, paramInfo.RawValue);
            }

            if (prevParamInfo.MaxValue != paramInfo.MaxValue && ParameterMaxValueChanged != null)
            {
                ParameterMaxValueChanged(paramId, paramInfo.MaxValue);
            }

            if (prevParamInfo.MinValue != paramInfo.MinValue && ParameterMinValueChanged != null)
            {
                ParameterMinValueChanged(paramId, paramInfo.MinValue);
            }
        }
Пример #11
0
 protected void OnProgramActivated()
 {
     //Send the info for each parameter from MssParameters to the host.
     foreach (MssParameterID paramId in MssParameterID.GetValues(typeof(MssParameterID)))
     {
         if (MssParameters.PRESET_PARAM_ID_LIST.Contains(paramId) && mssParameters.GetActiveMappingExists() == false)
         {
             MssParameters_ValueChanged(paramId, 0);
             MssParameters_NameChanged(paramId, MssParameters.GetDefaultPresetName(paramId));
         }
         else
         {
             MssParamInfo mssParamInfo = this.mssParameters.GetParameterInfoCopy(paramId);
             MssParameters_ValueChanged(paramId, mssParamInfo.GetValue());
             MssParameters_NameChanged(paramId, mssParamInfo.Name);
         }
     }
 }
Пример #12
0
        /// <summary>
        ///     Listens to changes made from the MSS namespace to the value of a parameter and modifies
        ///     the associated VstParameterManager to reflect the change.
        /// </summary>
        /// <param name="paramId">ID of the changed parameter.</param>
        /// <param name="value">New value of the changed parameter.</param>
        private void MssParameters_ValueChanged(MssParameterID paramId, double value)
        {
            VstParameterManager paramMgr;

            //Looks up the VstParameterManager associated with the changed parameter
            VstParameterManagerDict.TryGetRightByLeft(paramId, out paramMgr);
            if (paramMgr.ActiveParameter != null)
            {
                if (paramMgr.ActiveParameter.Value != value)
                {
                    if (this.parametersBeingModified.Contains(paramId) == false)
                    {
                        this.parametersBeingModified.Add(paramId);
                        paramMgr.ActiveParameter.Value = (float)this.mssParameters.GetRelativeParamValue(paramId);
                        this.parametersBeingModified.Remove(paramId);
                    }
                }
            }
        }
Пример #13
0
        /// <summary>
        ///     Initialized VstParameterManagerDict by createing a VstParameterManager for each MSS
        ///     parameter.
        /// </summary>
        protected void InitializeVstParams()
        {
            // all parameter definitions are added to a central list.
            VstParameterInfoCollection parameterInfos = this.pluginPrograms.ParameterInfos;

            //itterate over each MssParameterID
            foreach (MssParameterID paramId in MssParameterID.GetValues(typeof(MssParameterID)))
            {
                VstParameterInfo paramInfo = MssToVstParameterInfo(paramId);

                parameterInfos.Add(paramInfo);

                VstParameterManager paramMgr = new VstParameterManager(paramInfo);

                //Adds listener to changes made to a parameter from the host
                paramMgr.PropertyChanged +=
                    new PropertyChangedEventHandler(VstParameterManager_PropertyChanged);
                VstParameterManagerDict.Add(paramId, paramMgr);
            }
        }
        public void SetParameterRelativeValue(MssParameterID paramId, double relValue)
        {
            if (ALL_PARAMS_ID_LIST.Contains(paramId) == false)
            {
                //paramDict should always contain every possible MssParameterID
                Debug.Assert(false);
                return;
            }

            if (relValue < 0 || relValue > 1)
            {
                //relValue should be in the range [0, 1]
                Debug.Assert(false);
                return;
            }

            MssParamInfo paramInfo = GetParameterInfoCopy(paramId);
            double       rawValue  = paramInfo.MinValue + (relValue * (paramInfo.MaxValue - paramInfo.MinValue));

            SetParameterRawValue(paramId, rawValue);
        }
        public override bool SetData1RangeFromField(out string errorMsg)
        {
            int SelectedIndex = ((ComboBox)EntryField1).SelectedIndex;

            if (SelectedIndex < 0)
            {
                //I don't think this should ever occur as the first parameter should be selected
                //by default....but just to be safe.
                errorMsg = "You must select a parameter.";
                return(false);
            }
            else
            {
                MssParameterID paramId = MssParameters.ALL_PARAMS_ID_LIST[SelectedIndex];
                this.msgRange.Data1RangeBottom = (int)paramId;
                this.msgRange.Data1RangeTop    = (int)paramId;

                errorMsg = "";
                return(true);
            }
        }
        protected void ParameterValueChanged(MssParameterID paramId, double newValue)
        {
            lock (MssComponentHub.criticalSectioinLock)
            {
                if (this.hostInfoOutput.SampleRateIsInitialized == false)
                {
                    return;
                }

                long watchOffestAtParamChanged = this.stopwatch.Elapsed.Ticks;

                MssParamInfo paramInfo = this.mssParameters.GetParameterInfoCopy(paramId);
                double       relValue  = CustomMathUtils.AbsToRelVal(paramInfo.MinValue, paramInfo.MaxValue, newValue);

                MssMsg paramMsg = new MssMsg(MssMsgType.Parameter,
                                             (int)paramId,
                                             MssMsgUtil.UNUSED_MSS_MSG_DATA,
                                             relValue);
                MssEvent paramEvent = new MssEvent();

                paramEvent.mssMsg = paramMsg;

                long   ticksSinceCycleEnd   = watchOffestAtParamChanged - this.watchOffestAtLastCycleEnd;
                double secondsSinceCycleEnd = ticksSinceCycleEnd / (double)TimeSpan.TicksPerSecond;
                long   samplesSinceCycleEnd = (long)Math.Round(secondsSinceCycleEnd * this.hostInfoOutput.SampleRate);

                //Sometimes the stopwatch may not be accurate enough to notice the difference
                //between the end of the last cycle and now. Setting samplesSinceCycleEnd to
                //1 will cause this event to happen at the very start of this processing cycle.
                if (samplesSinceCycleEnd == 0)
                {
                    samplesSinceCycleEnd = 1;
                }

                paramEvent.sampleTime = this.sampleTimeAtLastCycleEnd + samplesSinceCycleEnd;

                this.dryEventInput.ReceiveDryMssEvent(paramEvent);
            }
        }
Пример #17
0
        /// <summary>
        ///     Generates an instance of VstParameterInfo using information about an MSS parameter.
        /// </summary>
        /// <param name="paramId">Specifies the MSS parameter to get information from</param>
        /// <returns></returns>
        protected VstParameterInfo MssToVstParameterInfo(MssParameterID paramId)
        {
            // retrieve the category for all variable parameters.
            VstParameterCategory paramCategory =
                this.pluginPrograms.GetParameterCategory(DEFAULT_PARAMETER_CATEGORY_NAME);

            // Variable parameter
            VstParameterInfo paramInfo = new VstParameterInfo();

            paramInfo.Category       = paramCategory;
            paramInfo.CanBeAutomated = true;

            if (MssParameters.PRESET_PARAM_ID_LIST.Contains(paramId))
            {
                paramInfo.Name         = MssParameters.GetDefaultPresetName(paramId);
                paramInfo.DefaultValue = 0;
            }
            else if (MssParameters.VARIABLE_PARAM_ID_LIST.Contains(paramId))
            {
                MssParamInfo mssParamInfo = this.mssParameters.GetParameterInfoCopy(paramId);
                paramInfo.Name         = GetParamNameFromString(mssParamInfo.Name);
                paramInfo.DefaultValue = (float)this.mssParameters.GetRelativeParamValue(paramId);
            }
            else
            {
                Debug.Assert(false);
            }

            paramInfo.Label          = "";
            paramInfo.ShortLabel     = "";
            paramInfo.MinInteger     = VST_PARAM_MIN_VALUE;
            paramInfo.MaxInteger     = VST_PARAM_MAX_VALUE;
            paramInfo.LargeStepFloat = ((float)(VST_PARAM_MAX_VALUE - VST_PARAM_MIN_VALUE)) / 8;
            paramInfo.SmallStepFloat = ((float)(VST_PARAM_MAX_VALUE - VST_PARAM_MIN_VALUE)) / 128;
            paramInfo.StepFloat      = 0.03125f;
            VstParameterNormalizationInfo.AttachTo(paramInfo);

            return(paramInfo);
        }
        protected void ParameterValueChanged(MssParameterID paramId, double newValue)
        {
            lock (MssComponentHub.criticalSectioinLock)
            {
                if (this.hostInfoOutput.SampleRateIsInitialized == false)
                {
                    return;
                }

                long watchOffestAtParamChanged = this.stopwatch.Elapsed.Ticks;

                MssParamInfo paramInfo = this.mssParameters.GetParameterInfoCopy(paramId);
                double relValue = CustomMathUtils.AbsToRelVal(paramInfo.MinValue, paramInfo.MaxValue, newValue);

                MssMsg paramMsg = new MssMsg(MssMsgType.Parameter,
                                             (int)paramId,
                                             MssMsgUtil.UNUSED_MSS_MSG_DATA,
                                             relValue);
                MssEvent paramEvent = new MssEvent();

                paramEvent.mssMsg = paramMsg;

                long ticksSinceCycleEnd = watchOffestAtParamChanged - this.watchOffestAtLastCycleEnd;
                double secondsSinceCycleEnd = ticksSinceCycleEnd / (double)TimeSpan.TicksPerSecond;
                long samplesSinceCycleEnd = (long)Math.Round(secondsSinceCycleEnd * this.hostInfoOutput.SampleRate);

                //Sometimes the stopwatch may not be accurate enough to notice the difference
                //between the end of the last cycle and now. Setting samplesSinceCycleEnd to
                //1 will cause this event to happen at the very start of this processing cycle.
                if (samplesSinceCycleEnd == 0)
                {
                    samplesSinceCycleEnd = 1;
                }

                paramEvent.sampleTime = this.sampleTimeAtLastCycleEnd + samplesSinceCycleEnd;

                this.dryEventInput.ReceiveDryMssEvent(paramEvent);
            }
        }
 protected bool RunFuncOnParamInfo(MssParameterID paramId, ParamInfoAccessor paramAccessor)
 {
     if (VARIABLE_PARAM_ID_LIST.Contains(paramId))
     {
         return(this.variableParamMgr.RunFuncOnParamInfo(paramId, paramInfo => paramAccessor(paramInfo)));
     }
     else if (PRESET_PARAM_ID_LIST.Contains(paramId))
     {
         return(this.activeMappingInfo.GetActiveGraphableEntryManager().RunFuncOnMappingEntry(this.activeMappingInfo.ActiveGraphableEntryId,
                                                                                              (mappingEntry) => {
             int paramIndex = PRESET_PARAM_ID_LIST.IndexOf(paramId);
             MssParamInfo paramInfo = mappingEntry.CurveShapeInfo.ParamInfoList[paramIndex];
             paramAccessor(paramInfo);
         }));
     }
     else
     {
         //every possible MssParameterID should either be contained in VARIABLE_PARAM_ID_LIST or PRESET_PARAM_ID_LIST.
         Debug.Assert(false);
         return(false);
     }
 }
        public static string GetDefaultPresetName(MssParameterID presetId)
        {
            switch (presetId)
            {
            case MssParameterID.Preset1:
                return("P1");

            case MssParameterID.Preset2:
                return("P2");

            case MssParameterID.Preset3:
                return("P3");

            case MssParameterID.Preset4:
                return("P4");

            case MssParameterID.Preset5:
                return("P5");

            default:
                Debug.Assert(false);
                return("");
            }
        }
        protected override void SetMappingDlgEntryFieldCustomProperties()
        {
            this.EntryField1Lbl.Visible = true;
            this.EntryField1Lbl.Text    = "Parameter Name:";
            this.EntryField1.Visible    = true;

            for (int i = 0; i < MssParameters.ALL_PARAMS_ID_LIST.Count; i++)
            {
                MssParameterID curId = MssParameters.ALL_PARAMS_ID_LIST[i];

                if (MssParameters.PRESET_PARAM_ID_LIST.Contains(curId) &&
                    this.mappingDlg.UseMappingEntryForDefaultValues == false)
                {
                    ((ComboBox)EntryField1).Items.Add(MssParameters.GetDefaultPresetName(curId));
                }
                else
                {
                    MssParamInfo curParamInfo = this.parameterViewer.GetParameterInfoCopy(curId);
                    ((ComboBox)EntryField1).Items.Add(curParamInfo.Name);
                }
            }

            ((ComboBox)EntryField1).SelectedIndex = 0;
        }
Пример #22
0
 /// <summary>
 ///     Listens to changes made from the MSS namespace to the value of a parameter and modifies 
 ///     the associated VstParameterManager to reflect the change.
 /// </summary>
 /// <param name="paramId">ID of the changed parameter.</param>
 /// <param name="value">New value of the changed parameter.</param>
 private void MssParameters_ValueChanged(MssParameterID paramId, double value)
 {
     VstParameterManager paramMgr;
     //Looks up the VstParameterManager associated with the changed parameter
     VstParameterManagerDict.TryGetRightByLeft(paramId, out paramMgr);
     if (paramMgr.ActiveParameter != null)
     {
         if (paramMgr.ActiveParameter.Value != value)
         {
             if (this.parametersBeingModified.Contains(paramId) == false)
             {
                 this.parametersBeingModified.Add(paramId);
                 paramMgr.ActiveParameter.Value = (float)this.mssParameters.GetRelativeParamValue(paramId);
                 this.parametersBeingModified.Remove(paramId);
             }
         }
     }
 }
Пример #23
0
 /// <summary>
 ///     Listens to changes made from the MSS namespace to the name of a parameter and modifies 
 ///     the associated VstParameterManager to reflect the change.
 /// </summary>
 /// <param name="paramId">ID of the changed parameter.</param>
 /// <param name="name">New name of the changed parameter.</param>
 private void MssParameters_NameChanged(MssParameterID paramId, string name)
 {
     VstParameterManager paramMgr;
     //Looks up the VstParameterManager associated with the changed parameter
     VstParameterManagerDict.TryGetRightByLeft(paramId, out paramMgr);
     if (paramMgr.ActiveParameter.Info.Name != name)
     {
         paramMgr.ActiveParameter.Info.Name = GetParamNameFromString(name);
     }
 }
Пример #24
0
        /// <summary>
        ///     Generates an instance of VstParameterInfo using information about an MSS parameter.
        /// </summary>
        /// <param name="paramId">Specifies the MSS parameter to get information from</param>
        /// <returns></returns>
        protected VstParameterInfo MssToVstParameterInfo(MssParameterID paramId)
        {
            // retrieve the category for all variable parameters.
            VstParameterCategory paramCategory =
                this.pluginPrograms.GetParameterCategory(DEFAULT_PARAMETER_CATEGORY_NAME);

            // Variable parameter
            VstParameterInfo paramInfo = new VstParameterInfo();
            paramInfo.Category = paramCategory;
            paramInfo.CanBeAutomated = true;

            if (MssParameters.PRESET_PARAM_ID_LIST.Contains(paramId))
            {
                paramInfo.Name = MssParameters.GetDefaultPresetName(paramId);
                paramInfo.DefaultValue = 0;
            }
            else if (MssParameters.VARIABLE_PARAM_ID_LIST.Contains(paramId))
            {
                MssParamInfo mssParamInfo = this.mssParameters.GetParameterInfoCopy(paramId);
                paramInfo.Name = GetParamNameFromString(mssParamInfo.Name);
                paramInfo.DefaultValue = (float)this.mssParameters.GetRelativeParamValue(paramId);
            }
            else {
                Debug.Assert(false);
            }

            paramInfo.Label = "";
            paramInfo.ShortLabel = "";
            paramInfo.MinInteger = VST_PARAM_MIN_VALUE;
            paramInfo.MaxInteger = VST_PARAM_MAX_VALUE;
            paramInfo.LargeStepFloat = ((float)(VST_PARAM_MAX_VALUE - VST_PARAM_MIN_VALUE)) / 8;
            paramInfo.SmallStepFloat = ((float)(VST_PARAM_MAX_VALUE - VST_PARAM_MIN_VALUE)) / 128;
            paramInfo.StepFloat = 0.03125f;
            VstParameterNormalizationInfo.AttachTo(paramInfo);

            return paramInfo;
        }
Пример #25
0
        public void SetParamInfo(MssParameterID paramId, MssParamInfo paramInfo)
        {
            MssParamInfo prevParamInfo = GetParameterInfoCopy(paramId);

            if (VARIABLE_PARAM_ID_LIST.Contains(paramId))
            {
                this.variableParamMgr.SetVariableParamInfo(paramInfo, paramId);
            }
            else if (PRESET_PARAM_ID_LIST.Contains(paramId))
            {
                this.activeMappingInfo.GetActiveGraphableEntryManager().RunFuncOnMappingEntry(this.activeMappingInfo.ActiveGraphableEntryId,
                    (mappingEntry) => mappingEntry.CurveShapeInfo.ParamInfoList[PRESET_PARAM_ID_LIST.IndexOf(paramId)] = paramInfo.Clone());
            }
            else
            {
                //every possible MssParameterID should either be contained in VARIABLE_PARAM_ID_LIST or PRESET_PARAM_ID_LIST.
                Debug.Assert(false);
                return;
            }

            bool paramTypeChanged = (prevParamInfo.paramType != paramInfo.paramType);

            if (prevParamInfo.Name != paramInfo.Name && ParameterNameChanged != null)
            {
                ParameterNameChanged(paramId, paramInfo.Name);
            }

            //We need to check of the param type has changed here because the same raw value
            //can be displayed differently for different param types.
            if ((paramTypeChanged || prevParamInfo.RawValue != paramInfo.RawValue) &&
                ParameterValueChanged != null)
            {
                ParameterValueChanged(paramId, paramInfo.RawValue);
            }

            if (prevParamInfo.MaxValue != paramInfo.MaxValue && ParameterMaxValueChanged != null)
            {
                ParameterMaxValueChanged(paramId, paramInfo.MaxValue);
            }

            if (prevParamInfo.MinValue != paramInfo.MinValue && ParameterMinValueChanged != null)
            {
                ParameterMinValueChanged(paramId, paramInfo.MinValue);
            }
        }
Пример #26
0
        public void SetParameterName(MssParameterID paramId, string name)
        {
            if (ALL_PARAMS_ID_LIST.Contains(paramId) == false)
            {
                //paramDict should always contain every possible MssParameterID
                Debug.Assert(false);
                return;
            }

            bool triggerNameChangedEvent = false;

            RunFuncOnParamInfo(paramId,
                paramInfo =>
                {
                    if (paramInfo.Name != name)
                    {
                        paramInfo.Name = name;
                        triggerNameChangedEvent = true;
                    }
                });

            if (triggerNameChangedEvent && ParameterNameChanged != null) {
                ParameterNameChanged(paramId, name);
            }
        }
Пример #27
0
        public void SetParameterRawValue(MssParameterID paramId, double rawValue)
        {
            if (ALL_PARAMS_ID_LIST.Contains(paramId) == false)
            {
                //paramDict should always contain every possible MssParameterID
                Debug.Assert(false);
                return;
            }

            bool triggerValueChangedEvent = false;
            double newValue = -1;

            RunFuncOnParamInfo(paramId,
                paramInfo =>
                {
                    double previousValue = paramInfo.GetValue();
                    paramInfo.RawValue = rawValue;
                    newValue = paramInfo.GetValue();

                    if (previousValue != newValue)
                    {
                        triggerValueChangedEvent = true;
                    }
                });

            if (triggerValueChangedEvent && ParameterValueChanged != null)
            {
                ParameterValueChanged(paramId, newValue);
            }
        }
        public double GetRelativeParamValue(MssParameterID paramId)
        {
            MssParamInfo paramInfo = GetParameterInfoCopy(paramId);

            return((paramInfo.RawValue - paramInfo.MinValue) / (paramInfo.MaxValue - paramInfo.MinValue));
        }
Пример #29
0
        public void SetParameterRelativeValue(MssParameterID paramId, double relValue)
        {
            if (ALL_PARAMS_ID_LIST.Contains(paramId) == false)
            {
                //paramDict should always contain every possible MssParameterID
                Debug.Assert(false);
                return;
            }

            if (relValue < 0 || relValue > 1)
            {
                //relValue should be in the range [0, 1]
                Debug.Assert(false);
                return;
            }

            MssParamInfo paramInfo = GetParameterInfoCopy(paramId);
            double rawValue = paramInfo.MinValue + (relValue * (paramInfo.MaxValue - paramInfo.MinValue));
            SetParameterRawValue(paramId, rawValue);
        }
Пример #30
0
        public MssParamInfo GetParameterInfoCopy(MssParameterID parameterId)
        {
            MssParamInfo paramInfoClone = null;
            RunFuncOnParamInfo(parameterId, paramInfo => paramInfoClone = paramInfo.Clone());

            return paramInfoClone;
        }
Пример #31
0
 public static string GetDefaultPresetName(MssParameterID presetId)
 {
     switch (presetId) {
         case MssParameterID.Preset1:
             return "P1";
         case MssParameterID.Preset2:
             return "P2";
         case MssParameterID.Preset3:
             return "P3";
         case MssParameterID.Preset4:
             return "P4";
         case MssParameterID.Preset5:
             return "P5";
         default:
             Debug.Assert(false);
             return "";
     }
 }
Пример #32
0
 public double GetRelativeParamValue(MssParameterID paramId)
 {
     MssParamInfo paramInfo = GetParameterInfoCopy(paramId);
     return (paramInfo.RawValue - paramInfo.MinValue) / (paramInfo.MaxValue - paramInfo.MinValue);
 }
Пример #33
0
 protected bool RunFuncOnParamInfo(MssParameterID paramId, ParamInfoAccessor paramAccessor)
 {
     if (VARIABLE_PARAM_ID_LIST.Contains(paramId))
     {
         return this.variableParamMgr.RunFuncOnParamInfo(paramId, paramInfo => paramAccessor(paramInfo));
     }
     else if (PRESET_PARAM_ID_LIST.Contains(paramId))
     {
         return this.activeMappingInfo.GetActiveGraphableEntryManager().RunFuncOnMappingEntry(this.activeMappingInfo.ActiveGraphableEntryId,
             (mappingEntry) => {
                 int paramIndex = PRESET_PARAM_ID_LIST.IndexOf(paramId);
                 MssParamInfo paramInfo = mappingEntry.CurveShapeInfo.ParamInfoList[paramIndex];
                 paramAccessor(paramInfo);
             });
     }
     else
     {
         //every possible MssParameterID should either be contained in VARIABLE_PARAM_ID_LIST or PRESET_PARAM_ID_LIST.
         Debug.Assert(false);
         return false;
     }
 }
 public void SetVariableParamInfo(MssParamInfo varParamInfo, MssParameterID variableParamId)
 {
     lock (this.memberLock)
     {
         bool variableParamIdIsValid = this.variableParamDict.ContainsKey(variableParamId);
         if (variableParamIdIsValid)
         {
             variableParamDict[variableParamId] = varParamInfo.Clone();
         }
         else
         {
             //variableParamId does not refer to a valid variable parameter id.
             Debug.Assert(false);
             return;
         }
     }
 }