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

            this.timbre = tim;

            tim.ToneType = ToneType.FM;

            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"]["FMS"]).Value = tim.FMS;
            ((RegisterFlag)this["General"]["GlobalSettings.EN"]).Value             = tim.GlobalSettings.Enable;
            ((RegisterValue)this["General"]["GlobalSettings.LFOEN"]).NullableValue = tim.GlobalSettings.LFOEN;
            ((RegisterValue)this["General"]["GlobalSettings.LFRQ"]).NullableValue  = tim.GlobalSettings.LFRQ;

            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)]["SSG"]).Value = tim.Ops[i].SSG;
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tone"></param>
        protected override void ApplyTone(TimbreBase timbre, Tone tone)
        {
            YM2610BTimbre tim = (YM2610BTimbre)timbre;

            tim.ToneType = ToneType.FM;

            tim.ALG = (byte)tone.AL;
            tim.FB  = (byte)tone.FB;
            tim.AMS = (byte)tone.AMS;
            tim.FMS = (byte)tone.PMS;
            tim.GlobalSettings.Enable = false;
            tim.GlobalSettings.LFRQ   = null;
            tim.GlobalSettings.LFOEN  = null;

            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].SSG    = (byte)tone.aOp[i].SSG;
            }
            timbre.TimbreName = tone.Name;
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        public FormYM2610BEditor(YM2610B inst, YM2610BTimbre timbre, bool singleSelect) : base(inst, timbre, singleSelect)
        {
            this.timbre = timbre;
            InitializeComponent();

            Size = Settings.Default.YM2610BEdSize;

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

            AddControl(new YM2610BOperatorContainer(timbre.Ops[0], "Operator 1"));
            AddControl(new YM2610BOperatorContainer(timbre.Ops[1], "Operator 2"));
            AddControl(new YM2610BOperatorContainer(timbre.Ops[2], "Operator 3"));
            AddControl(new YM2610BOperatorContainer(timbre.Ops[3], "Operator 4"));
        }
예제 #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;
            YM2610BTimbre tim       = context.Instance as YM2610BTimbre;

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

            YM2610B inst = null;

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

                inst = InstrumentManager.FindParentInstrument(InstrumentType.YM2610B, tim) as YM2610B;
            }
            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.FMS),
                                                                          "GlobalSettings.EN",
                                                                          "GlobalSettings.LFOEN",
                                                                          "GlobalSettings.LFRQ"
                                                                          );
                    var lastTone = tim.ToneType;
                    tim.ToneType = ToneType.FM;

                    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.SSG)
                                                                        ));
                    }
                    FormYM2610BEditor ed = new FormYM2610BEditor(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.ToneType = lastTone;
                                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 (FormYM2610BEditor ed = new FormYM2610BEditor(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 <YM2610BTimbre[]>(org));
                        }
                    }
                }
            }

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