/// <summary> /// /// </summary> public FormYM2413Editor(YM2413 inst, YM2413Timbre timbre, bool singleSelect) : base(inst, timbre, singleSelect) { this.timbre = timbre; InitializeComponent(); Size = Settings.Default.YM2413EdSize; AddControl(new YM2413GeneralContainer(inst, timbre, "General")); AddControl(new YM2413OperatorContainer(timbre.Modulator, "Modulator")); AddControl(new YM2413OperatorContainer(timbre.Career, "Career")); }
/// <summary> /// /// </summary> /// <param name="tone"></param> protected override void ApplyTimbre(TimbreBase timbre) { YM2413Timbre tim = (YM2413Timbre)timbre; this.timbre = tim; this["General"].Target = tim; ((RegisterValue)this["General"]["FB"]).Value = tim.FB; ((RegisterValue)this["General"]["SUS"]).Value = tim.SUS; this["Modulator"].Target = tim.Modulator; ((RegisterValue)this["Modulator"]["AR"]).Value = tim.Modulator.AR; ((RegisterValue)this["Modulator"]["DR"]).Value = tim.Modulator.DR; ((RegisterValue)this["Modulator"]["RR"]).Value = tim.Modulator.RR; ((RegisterValue)this["Modulator"]["SL"]).Value = tim.Modulator.SL; ((RegisterValue)this["Modulator"]["SR"]).NullableValue = tim.Modulator.SR; ((RegisterValue)this["Modulator"]["TL"]).Value = tim.Modulator.TL; ((RegisterValue)this["Modulator"]["KSL"]).Value = tim.Modulator.KSL; ((RegisterValue)this["Modulator"]["KSR"]).Value = tim.Modulator.KSR; ((RegisterValue)this["Modulator"]["MUL"]).Value = tim.Modulator.MUL; ((RegisterValue)this["Modulator"]["AM"]).Value = tim.Modulator.AM; ((RegisterValue)this["Modulator"]["VIB"]).Value = tim.Modulator.VIB; ((RegisterValue)this["Modulator"]["EG"]).Value = tim.Modulator.EG; ((RegisterValue)this["Modulator"]["DIST"]).Value = tim.Modulator.DIST; this["Career"].Target = tim.Career; ((RegisterValue)this["Career"]["AR"]).Value = tim.Career.AR; ((RegisterValue)this["Career"]["DR"]).Value = tim.Career.DR; ((RegisterValue)this["Career"]["RR"]).Value = tim.Career.RR; ((RegisterValue)this["Career"]["SL"]).Value = tim.Career.SL; ((RegisterValue)this["Career"]["SR"]).NullableValue = tim.Career.SR; ((RegisterValue)this["Career"]["KSL"]).Value = tim.Career.KSL; ((RegisterValue)this["Career"]["KSR"]).Value = tim.Career.KSR; ((RegisterValue)this["Career"]["MUL"]).Value = tim.Career.MUL; ((RegisterValue)this["Career"]["AM"]).Value = tim.Career.AM; ((RegisterValue)this["Career"]["VIB"]).Value = tim.Career.VIB; ((RegisterValue)this["Career"]["EG"]).Value = tim.Career.EG; ((RegisterValue)this["Career"]["DIST"]).Value = tim.Career.DIST; }
/// <summary> /// /// </summary> /// <param name="tone"></param> protected override void ApplyTone(TimbreBase timbre, Tone tone) { YM2413Timbre tim = (YM2413Timbre)timbre; tim.FB = (byte)tone.FB; tim.SUS = 0; tim.Modulator.AR = (byte)(tone.aOp[0].AR / 2); tim.Modulator.DR = (byte)(tone.aOp[0].DR / 2); tim.Modulator.RR = (byte)(tone.aOp[0].RR); tim.Modulator.SL = (byte)(tone.aOp[0].SL); tim.Modulator.SR = (byte)(tone.aOp[0].SR / 2); tim.Modulator.TL = (byte)(tone.aOp[0].TL / 2); tim.Modulator.KSL = (byte)(tone.aOp[0].KS); tim.Modulator.KSR = (byte)(0); tim.Modulator.MUL = (byte)(tone.aOp[0].ML); tim.Modulator.AM = (byte)(tone.aOp[0].AM); tim.Modulator.VIB = (byte)(0); tim.Modulator.EG = (byte)(0); tim.Modulator.DIST = (byte)(0); tim.Career.AR = (byte)(tone.aOp[1].AR / 2); tim.Career.DR = (byte)(tone.aOp[1].DR / 2); tim.Career.RR = (byte)(tone.aOp[1].RR); tim.Career.SL = (byte)(tone.aOp[1].SL); tim.Career.SR = (byte)(tone.aOp[1].SR / 2); tim.Career.KSL = (byte)(tone.aOp[1].KS); tim.Career.KSR = (byte)(0); tim.Career.MUL = (byte)(tone.aOp[1].ML); tim.Career.AM = (byte)(tone.aOp[1].AM); tim.Career.VIB = (byte)(0); tim.Career.EG = (byte)(0); tim.Career.DIST = (byte)(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; YM2413Timbre tim = context.Instance as YM2413Timbre; YM2413Timbre[] tims = value as YM2413Timbre[]; if (tims != null) { tim = tims[0]; singleSel = false; } YM2413 inst = null; try { //InstrumentManager.ExclusiveLockObject.EnterReadLock(); inst = InstrumentManager.FindParentInstrument(InstrumentType.YM2413, tim) as YM2413; } finally { //InstrumentManager.ExclusiveLockObject.ExitReadLock(); } if (inst != null) { if (singleSel) { var mmlValueGeneral = SimpleSerializer.SerializeProps(tim, nameof(tim.FB), nameof(tim.SUS)); var tt = tim.ToneType; tim.ToneType = ToneType.Custom; List <string> mmlValueOps = new List <string>(); var mod = tim.Modulator; mmlValueOps.Add(SimpleSerializer.SerializeProps(mod, nameof(mod.AR), nameof(mod.DR), nameof(mod.RR), nameof(mod.SL), nameof(mod.SR), nameof(mod.TL), nameof(mod.KSL), nameof(mod.KSR), nameof(mod.MUL), nameof(mod.AM), nameof(mod.VIB), nameof(mod.EG), nameof(mod.DIST) )); var ca = tim.Career; mmlValueOps.Add(SimpleSerializer.SerializeProps(ca, nameof(ca.AR), nameof(ca.DR), nameof(ca.RR), nameof(ca.SL), nameof(ca.SR), nameof(ca.KSL), nameof(ca.KSR), nameof(ca.MUL), nameof(ca.AM), nameof(ca.VIB), nameof(ca.EG), nameof(ca.DIST) )); FormYM2413Editor ed = new FormYM2413Editor(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.ToneType = tt; 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 (FormYM2413Editor ed = new FormYM2413Editor(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 <YM2413Timbre[]>(org)); } } } } return(value); // エディタ呼び出し直前の設定値をそのまま返す }