/// <summary> /// /// </summary> /// <param name="tone"></param> protected override void ApplyTimbre(TimbreBase timbre) { YM3812Timbre tim = (YM3812Timbre)timbre; this.timbre = tim; this["General"].Target = tim; ((RegisterValue)this["General"]["ALG"]).Value = tim.ALG; ((RegisterValue)this["General"]["FB"]).Value = tim.FB; ((RegisterFlag)this["General"]["GlobalSettings.EN"]).Value = tim.GlobalSettings.Enable; ((RegisterValue)this["General"]["GlobalSettings.AMD"]).NullableValue = tim.GlobalSettings.AMD; ((RegisterValue)this["General"]["GlobalSettings.VIB"]).NullableValue = tim.GlobalSettings.VIB; for (int i = 0; i < 2; i++) { this["Operator " + (i + 1)].Target = tim.Ops[i]; ((RegisterValue)this["Operator " + (i + 1)]["AR"]).Value = tim.Ops[i].AR; ((RegisterValue)this["Operator " + (i + 1)]["DR"]).Value = tim.Ops[i].DR; ((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)]["SR"]).NullableValue = tim.Ops[i].SR; ((RegisterValue)this["Operator " + (i + 1)]["TL"]).Value = tim.Ops[i].TL; ((RegisterValue)this["Operator " + (i + 1)]["KSL"]).Value = tim.Ops[i].KSL; ((RegisterValue)this["Operator " + (i + 1)]["KSR"]).Value = tim.Ops[i].KSR; ((RegisterValue)this["Operator " + (i + 1)]["MFM"]).Value = tim.Ops[i].MFM; ((RegisterValue)this["Operator " + (i + 1)]["AM"]).Value = tim.Ops[i].AM; ((RegisterValue)this["Operator " + (i + 1)]["VR"]).Value = tim.Ops[i].VR; ((RegisterValue)this["Operator " + (i + 1)]["EG"]).Value = tim.Ops[i].EG; ((RegisterValue)this["Operator " + (i + 1)]["WS"]).Value = tim.Ops[i].WS; } }
/// <summary> /// /// </summary> public FormYM3812Editor(YM3812 inst, YM3812Timbre timbre, bool singleSelect) : base(inst, timbre, singleSelect) { this.timbre = timbre; InitializeComponent(); Size = Settings.Default.YM3812EdSize; AddControl(new YM3812GeneralContainer(inst, timbre, "General")); AddControl(new YM3812OperatorContainer(timbre.Ops[0], "Operator 1")); AddControl(new YM3812OperatorContainer(timbre.Ops[1], "Operator 2")); }
/// <summary> /// /// </summary> /// <param name="tone"></param> protected override void ApplyTone(TimbreBase timbre, Tone tone) { YM3812Timbre tim = (YM3812Timbre)timbre; bool native = false; if (tone.CNT == -1) { tim.ALG = (byte)tone.AL; } else { tim.ALG = (byte)tone.CNT; native = true; } tim.FB = (byte)tone.FB; tim.GlobalSettings.Enable = false; tim.GlobalSettings.AMD = null; tim.GlobalSettings.VIB = null; for (int i = 0; i < 2; i++) { if (!native) { tim.Ops[i].AR = (byte)(tone.aOp[i].AR / 2); tim.Ops[i].DR = (byte)(tone.aOp[i].DR / 2); tim.Ops[i].SR = (byte)(tone.aOp[i].SR / 2); tim.Ops[i].TL = (byte)(tone.aOp[i].TL / 2); } else { tim.Ops[i].AR = (byte)(tone.aOp[i].AR); tim.Ops[i].DR = (byte)(tone.aOp[i].DR); tim.Ops[i].SR = null; tim.Ops[i].TL = (byte)(tone.aOp[i].TL); } tim.Ops[i].RR = (byte)tone.aOp[i].RR; tim.Ops[i].SL = (byte)tone.aOp[i].SL; tim.Ops[i].KSL = (byte)tone.aOp[i].KS; tim.Ops[i].KSR = 0; tim.Ops[i].MFM = (byte)tone.aOp[i].ML; tim.Ops[i].AM = (byte)tone.aOp[i].AM; tim.Ops[i].VR = 0; tim.Ops[i].EG = 0; tim.Ops[i].WS = 0; } timbre.TimbreName = tone.Name; }
/// <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; YM3812Timbre tim = context.Instance as YM3812Timbre; YM3812Timbre[] tims = value as YM3812Timbre[]; if (tims != null) { tim = tims[0]; singleSel = false; } YM3812 inst = null; try { //InstrumentManager.ExclusiveLockObject.EnterReadLock(); inst = InstrumentManager.FindParentInstrument(InstrumentType.YM3812, tim) as YM3812; } finally { //InstrumentManager.ExclusiveLockObject.ExitReadLock(); } if (inst != null) { if (singleSel) { var mmlValueGeneral = SimpleSerializer.SerializeProps(tim, nameof(tim.ALG), nameof(tim.FB), "GlobalSettings.EN", "GlobalSettings.AMD", "GlobalSettings.VIB"); 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.AR), nameof(op.DR), nameof(op.RR), nameof(op.SL), nameof(op.SR), nameof(op.TL), nameof(op.KSL), nameof(op.KSR), nameof(op.MFM), nameof(op.AM), nameof(op.VR), nameof(op.EG), nameof(op.WS) )); } FormYM3812Editor ed = new FormYM3812Editor(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]; } else if (ed.DialogResult == DialogResult.Cancel) { tim.Detailed = mmlValueGeneral + "," + mmlValueOps[0] + "," + mmlValueOps[1]; } }; ed.Show(); ed.Activated += (s, e) => { tim.Detailed = ed.MmlValueGeneral + "," + ed.MmlValueOps[0] + "," + ed.MmlValueOps[1]; }; } } else { using (FormYM3812Editor ed = new FormYM3812Editor(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 <YM3812Timbre[]>(org)); } } } } return(value); // エディタ呼び出し直前の設定値をそのまま返す }