예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tone"></param>
        protected override void ApplyTimbre(TimbreBase timbre)
        {
            YM2414Timbre tim = (YM2414Timbre)timbre;

            this.timbre = tim;

            this["General"].Target = tim;
            ((RegisterValue)this["General"]["ALG"]).Value                          = tim.ALG;
            ((RegisterValue)this["General"]["FB"]).Value                           = tim.FB;
            ((RegisterValue)this["General"]["AMS"]).Value                          = tim.AMS;
            ((RegisterValue)this["General"]["PMS"]).Value                          = tim.PMS;
            ((RegisterValue)this["General"]["AMS2"]).Value                         = tim.AMS2;
            ((RegisterValue)this["General"]["PMS2"]).Value                         = tim.PMS2;
            ((RegisterFlag)this["General"]["GlobalSettings.EN"]).Value             = tim.GlobalSettings.Enable;
            ((RegisterValue)this["General"]["GlobalSettings.LFRQ"]).NullableValue  = tim.GlobalSettings.LFRQ;
            ((RegisterValue)this["General"]["GlobalSettings.LFRQ2"]).NullableValue = tim.GlobalSettings.LFRQ2;

            ((RegisterValue)this["General"]["GlobalSettings.LFOF"]).NullableValue  = tim.GlobalSettings.LFOF;
            ((RegisterValue)this["General"]["GlobalSettings.LFOD"]).NullableValue  = tim.GlobalSettings.LFOD;
            ((RegisterValue)this["General"]["GlobalSettings.LFOF2"]).NullableValue = tim.GlobalSettings.LFOF2;
            ((RegisterValue)this["General"]["GlobalSettings.LFOD2"]).NullableValue = tim.GlobalSettings.LFOD2;

            ((RegisterValue)this["General"]["GlobalSettings.LFD"]).NullableValue  = tim.GlobalSettings.LFD;
            ((RegisterValue)this["General"]["GlobalSettings.LFD2"]).NullableValue = tim.GlobalSettings.LFD2;

            ((RegisterValue)this["General"]["GlobalSettings.LFOW"]).NullableValue  = tim.GlobalSettings.LFOW;
            ((RegisterValue)this["General"]["GlobalSettings.LFOW2"]).NullableValue = tim.GlobalSettings.LFOW2;

            ((RegisterValue)this["General"]["GlobalSettings.SYNC"]).NullableValue  = tim.GlobalSettings.SYNC;
            ((RegisterValue)this["General"]["GlobalSettings.SYNC2"]).NullableValue = tim.GlobalSettings.SYNC2;

            for (int i = 0; i < 4; i++)
            {
                this["Operator " + (i + 1)].Target = tim.Ops[i];
                ((RegisterFlag)this["Operator " + (i + 1)]["EN"]).Value    = tim.Ops[i].Enable == 0 ? false : true;
                ((RegisterValue)this["Operator " + (i + 1)]["AR"]).Value   = tim.Ops[i].AR;
                ((RegisterValue)this["Operator " + (i + 1)]["D1R"]).Value  = tim.Ops[i].D1R;
                ((RegisterValue)this["Operator " + (i + 1)]["D2R"]).Value  = tim.Ops[i].D2R;
                ((RegisterValue)this["Operator " + (i + 1)]["RR"]).Value   = tim.Ops[i].RR;
                ((RegisterValue)this["Operator " + (i + 1)]["SL"]).Value   = tim.Ops[i].SL;
                ((RegisterValue)this["Operator " + (i + 1)]["TL"]).Value   = tim.Ops[i].TL;
                ((RegisterValue)this["Operator " + (i + 1)]["RS"]).Value   = tim.Ops[i].RS;
                ((RegisterValue)this["Operator " + (i + 1)]["MUL"]).Value  = tim.Ops[i].MUL;
                ((RegisterValue)this["Operator " + (i + 1)]["DT1"]).Value  = tim.Ops[i].DT1;
                ((RegisterValue)this["Operator " + (i + 1)]["AM"]).Value   = tim.Ops[i].AM;
                ((RegisterValue)this["Operator " + (i + 1)]["DT2"]).Value  = tim.Ops[i].DT2;
                ((RegisterValue)this["Operator " + (i + 1)]["FINE"]).Value = tim.Ops[i].FINE;
                ((RegisterValue)this["Operator " + (i + 1)]["FIX"]).Value  = tim.Ops[i].FIX;
                ((RegisterValue)this["Operator " + (i + 1)]["FIXR"]).Value = tim.Ops[i].FIXR;
                ((RegisterValue)this["Operator " + (i + 1)]["FIXF"]).Value = tim.Ops[i].FIXF;
                ((RegisterValue)this["Operator " + (i + 1)]["OSCW"]).Value = tim.Ops[i].OSCW;
                ((RegisterValue)this["Operator " + (i + 1)]["EGSF"]).Value = tim.Ops[i].EGSF;
                ((RegisterValue)this["Operator " + (i + 1)]["REV"]).Value  = tim.Ops[i].REV;
                ((RegisterValue)this["Operator " + (i + 1)]["LS"]).Value   = tim.Ops[i].LS;
                ((RegisterValue)this["Operator " + (i + 1)]["KVS"]).Value  = tim.Ops[i].KVS;
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        public FormYM2414Editor(YM2414 inst, YM2414Timbre timbre, bool singleSelect) : base(inst, timbre, singleSelect)
        {
            this.timbre = timbre;
            InitializeComponent();

            Size = Settings.Default.YM2414EdSize;

            AddControl(new YM2414GeneralContainer(inst, timbre, "General"));

            AddControl(new YM2414OperatorContainer(timbre.Ops[0], "Operator 1"));
            AddControl(new YM2414OperatorContainer(timbre.Ops[1], "Operator 2"));
            AddControl(new YM2414OperatorContainer(timbre.Ops[2], "Operator 3"));
            AddControl(new YM2414OperatorContainer(timbre.Ops[3], "Operator 4"));
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tone"></param>
        protected override void ApplyTone(TimbreBase timbre, Tone tone)
        {
            YM2414Timbre tim = (YM2414Timbre)timbre;

            tim.ALG  = (byte)tone.AL;
            tim.FB   = (byte)tone.FB;
            tim.AMS  = (byte)tone.AMS;
            tim.PMS  = (byte)tone.PMS;
            tim.AMS2 = (byte)tone.AMS2;
            tim.PMS2 = (byte)tone.PMS2;

            tim.GlobalSettings.NE   = (byte?)tone.NE;
            tim.GlobalSettings.NFRQ = (byte?)tone.NF;

            tim.GlobalSettings.LFRQ  = (byte?)tone.LFRQ;
            tim.GlobalSettings.LFRQ2 = (byte?)tone.LFRQ2;
            tim.GlobalSettings.LFOF  = (byte?)tone.LFOF;
            tim.GlobalSettings.LFOD  = (byte?)tone.LFOD;
            tim.GlobalSettings.LFOF2 = (byte?)tone.LFOF2;
            tim.GlobalSettings.LFOD2 = (byte?)tone.LFOD2;
            tim.GlobalSettings.LFOW  = (byte?)tone.LFOW;
            tim.GlobalSettings.LFOW2 = (byte?)tone.LFOW2;

            tim.GlobalSettings.LFD  = (byte?)tone.LFD;
            tim.GlobalSettings.LFD2 = (byte?)tone.LFD2;

            tim.GlobalSettings.SYNC  = (byte?)tone.SY;
            tim.GlobalSettings.SYNC2 = (byte?)tone.SY2;

            if (tim.GlobalSettings.NE > 0 ||
                tim.GlobalSettings.LFRQ > 0 ||
                tim.GlobalSettings.LFRQ2 > 0 ||
                tim.GlobalSettings.LFOW > 0 ||
                tim.GlobalSettings.LFOW2 > 0 ||
                tim.GlobalSettings.LFOD > 0 ||
                tim.GlobalSettings.LFOD2 > 0
                )
            {
                tim.GlobalSettings.Enable = true;
            }

            for (int i = 0; i < 4; i++)
            {
                tim.Ops[i].Enable = 1;
                tim.Ops[i].AR     = (byte)tone.aOp[i].AR;
                tim.Ops[i].D1R    = (byte)tone.aOp[i].DR;
                tim.Ops[i].D2R    = tone.aOp[i].SR < 0 ? (byte)0 : (byte)tone.aOp[i].SR;
                tim.Ops[i].RR     = (byte)tone.aOp[i].RR;
                tim.Ops[i].SL     = (byte)tone.aOp[i].SL;
                tim.Ops[i].TL     = (byte)tone.aOp[i].TL;
                tim.Ops[i].RS     = (byte)tone.aOp[i].KS;
                tim.Ops[i].MUL    = (byte)tone.aOp[i].ML;
                tim.Ops[i].DT1    = (byte)tone.aOp[i].DT;
                tim.Ops[i].AM     = (byte)tone.aOp[i].AM;
                tim.Ops[i].DT2    = (byte)tone.aOp[i].DT2;
                tim.Ops[i].FINE   = (byte)tone.aOp[i].FINE;
                tim.Ops[i].FIX    = (byte)tone.aOp[i].FIX;
                tim.Ops[i].FIXR   = (byte)tone.aOp[i].FIXR;
                tim.Ops[i].FIXF   = (byte)tone.aOp[i].FIXF;
                tim.Ops[i].OSCW   = (byte)tone.aOp[i].OSCW;
                tim.Ops[i].EGSF   = (byte)tone.aOp[i].EGSF;
                tim.Ops[i].REV    = (byte)tone.aOp[i].REV;
                tim.Ops[i].LS     = (byte)tone.aOp[i].LS;
                tim.Ops[i].KVS    = (byte)tone.aOp[i].KVS;
            }
            timbre.TimbreName = tone.Name;
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService = null;

            if (provider != null)
            {
                editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            }

            if (editorService == null)
            {
                return(value);
            }

            bool         singleSel = true;
            YM2414Timbre tim       = context.Instance as YM2414Timbre;

            YM2414Timbre[] tims = value as YM2414Timbre[];
            if (tims != null)
            {
                tim       = tims[0];
                singleSel = false;
            }

            YM2414 inst = null;

            try
            {
                //InstrumentManager.ExclusiveLockObject.EnterReadLock();

                inst = InstrumentManager.FindParentInstrument(InstrumentType.YM2414, tim) as YM2414;
            }
            finally
            {
                //InstrumentManager.ExclusiveLockObject.ExitReadLock();
            }

            if (inst != null)
            {
                if (singleSel)
                {
                    var mmlValueGeneral = SimpleSerializer.SerializeProps(tim,
                                                                          nameof(tim.ALG),
                                                                          nameof(tim.FB),
                                                                          nameof(tim.AMS),
                                                                          nameof(tim.PMS),
                                                                          nameof(tim.AMS2),
                                                                          nameof(tim.PMS2),

                                                                          "GlobalSettings.EN",
                                                                          "GlobalSettings.LFRQ",
                                                                          "GlobalSettings.LFRQ2",
                                                                          "GlobalSettings.LFOF",
                                                                          "GlobalSettings.LFOD",
                                                                          "GlobalSettings.LFOF2",
                                                                          "GlobalSettings.LFOD2",
                                                                          "GlobalSettings.LFOW",
                                                                          "GlobalSettings.LFOW2",
                                                                          "GlobalSettings.SYNC",
                                                                          "GlobalSettings.SYNC2",
                                                                          "GlobalSettings.NE",
                                                                          "GlobalSettings.NFRQ",
                                                                          "GlobalSettings.LFD",
                                                                          "GlobalSettings.LFD2"
                                                                          );

                    List <string> mmlValueOps = new List <string>();
                    for (int i = 0; i < tim.Ops.Length; i++)
                    {
                        var op = tim.Ops[i];
                        mmlValueOps.Add(SimpleSerializer.SerializeProps(op,
                                                                        nameof(op.EN),
                                                                        nameof(op.AR),
                                                                        nameof(op.D1R),
                                                                        nameof(op.D2R),
                                                                        nameof(op.RR),
                                                                        nameof(op.SL),
                                                                        nameof(op.TL),
                                                                        nameof(op.RS),
                                                                        nameof(op.MUL),
                                                                        nameof(op.DT1),
                                                                        nameof(op.AM),
                                                                        nameof(op.DT2),
                                                                        nameof(op.FINE),
                                                                        nameof(op.FIX),
                                                                        nameof(op.FIXR),
                                                                        nameof(op.FIXF),
                                                                        nameof(op.OSCW),
                                                                        nameof(op.EGSF),
                                                                        nameof(op.REV),
                                                                        nameof(op.LS),
                                                                        nameof(op.KVS)
                                                                        ));
                    }
                    FormYM2414Editor ed = new FormYM2414Editor(inst, tim, singleSel);
                    {
                        ed.MmlValueGeneral = mmlValueGeneral;

                        ed.FormClosed += (s, e) =>
                        {
                            if (ed.DialogResult == DialogResult.OK)
                            {
                                tim.Detailed = ed.MmlValueGeneral + "," + ed.MmlValueOps[0] + "," + ed.MmlValueOps[1] + "," + ed.MmlValueOps[2] + "," + ed.MmlValueOps[3];
                            }
                            else if (ed.DialogResult == DialogResult.Cancel)
                            {
                                tim.Detailed = mmlValueGeneral + "," + mmlValueOps[0] + "," + mmlValueOps[1] + "," + mmlValueOps[2] + "," + mmlValueOps[3];
                            }
                        };
                        ed.Show();
                        ed.Activated += (s, e) =>
                        {
                            tim.Detailed = ed.MmlValueGeneral + "," + ed.MmlValueOps[0] + "," + ed.MmlValueOps[1] + "," + ed.MmlValueOps[2] + "," + ed.MmlValueOps[3];
                        };
                    }
                }
                else
                {
                    using (FormYM2414Editor ed = new FormYM2414Editor(inst, tim, singleSel))
                    {
                        string       org = JsonConvert.SerializeObject(tims, Formatting.Indented);
                        DialogResult dr  = editorService.ShowDialog(ed);
                        if (dr == DialogResult.OK || dr == DialogResult.Abort)
                        {
                            return(value);
                        }
                        else
                        {
                            return(JsonConvert.DeserializeObject <YM2414Timbre[]>(org));
                        }
                    }
                }
            }

            return(value);                   // エディタ呼び出し直前の設定値をそのまま返す
        }