Пример #1
0
 public MidiCom()
 {
     this.context          = SynchronizationContext.Current;
     this.builder          = new ChannelMessageBuilder();
     this.m_Timer          = new System.Timers.Timer(1000.0);
     this.m_Timer.Elapsed += (ElapsedEventHandler)((sender, e) => MidiCom.MyElapsedMethod(sender, e, this));
     this.m_Timer.Enabled  = true;
 }
Пример #2
0
 private static void MyElapsedMethod(object sender, ElapsedEventArgs e, MidiCom Reference)
 {
     Reference.context.Post((SendOrPostCallback)(dummy => Reference.TimerTick()), (object)null);
 }
        public Form1()
        {
            Logger.CreateLogSpace();
            Logger.Log("Starting Code Editor");
            Form1.CurrentForm1 = this;
            this.InitializeComponent();
            this.tooltip             = new ToolTip();
            this.ClientSize          = new Size(1264, 728);
            this.FormBorderStyle     = FormBorderStyle.FixedSingle;
            this.MaximizeBox         = false;
            this.m_DraggingKnobIndex = -1;
            this.m_PushingButton     = -1;
            Form1.MidiEnabled        = false;
            this.AllowDrop           = true;
            this.DragEnter          += new DragEventHandler(this.Form1_DragEnter);
            this.DragDrop           += new DragEventHandler(this.Form1_DragDrop);
            this.Text                            = "CODE Patch Editor";
            this.DoubleBuffered                  = true;
            this.Paint                          += new PaintEventHandler(this.Form1_Paint);
            Form1.m_CurrentPatch                 = new Patch();
            this.openFileDialog1.Title           = "Browse MCE Files";
            this.openFileDialog1.DefaultExt      = "mce";
            this.openFileDialog1.CheckFileExists = true;
            this.openFileDialog1.CheckPathExists = true;
            this.openFileDialog1.Filter          = "MCE files (*.mce)|*.mce|All files (*.*)|*.*";
            this.saveFileDialog1.Title           = "Save MCE File";
            this.saveFileDialog1.DefaultExt      = "mce";
            this.saveFileDialog1.Filter          = "MCE files (*.mce)|*.mce|All files (*.*)|*.*";
            this.m_OnOffButtons                  = new OnOffButton[7];
            for (int index = 0; index < 7; ++index)
            {
                this.m_OnOffButtons[index] = new OnOffButton();
            }
            this.m_AllKnobs = new ButtonControl[23];
            for (int index = 0; index < 23; ++index)
            {
                this.m_AllKnobs[index] = new ButtonControl();
            }
            this.m_BitmapButtons = new BitmapButton[13];
            for (int index = 0; index < 13; ++index)
            {
                this.m_BitmapButtons[index] = new BitmapButton();
            }
            this.m_TextSelectors = new TextSelector[11];
            for (int index = 0; index < 11; ++index)
            {
                this.m_TextSelectors[index] = new TextSelector();
            }
            this.m_ImageSelectors = new ImageSelector[3];
            for (int index = 0; index < 3; ++index)
            {
                this.m_ImageSelectors[index] = new ImageSelector();
            }
            this.m_OnOffButtons[0].Initialize(new Ref <bool>((Func <bool>)(() => Form1.m_CurrentPatch.m_OnOffValues[0]), (Action <bool>)(v => Form1.m_CurrentPatch.m_OnOffValues[0] = v)), 443, 143);
            this.m_OnOffButtons[1].Initialize(new Ref <bool>((Func <bool>)(() => Form1.m_CurrentPatch.m_OnOffValues[1]), (Action <bool>)(v => Form1.m_CurrentPatch.m_OnOffValues[1] = v)), 64, 321);
            this.m_OnOffButtons[2].Initialize(new Ref <bool>((Func <bool>)(() => Form1.m_CurrentPatch.m_OnOffValues[2]), (Action <bool>)(v => Form1.m_CurrentPatch.m_OnOffValues[2] = v)), 65, 502);
            this.m_OnOffButtons[3].Initialize(new Ref <bool>((Func <bool>)(() => Form1.m_CurrentPatch.m_OnOffValues[3]), (Action <bool>)(v => Form1.m_CurrentPatch.m_OnOffValues[3] = v)), 844, 144);
            this.m_OnOffButtons[4].Initialize(new Ref <bool>((Func <bool>)(() => Form1.m_CurrentPatch.m_OnOffValues[4]), (Action <bool>)(v => Form1.m_CurrentPatch.m_OnOffValues[4] = v)), 844, 324);
            this.m_OnOffButtons[5].Initialize(new Ref <bool>((Func <bool>)(() => Form1.m_CurrentPatch.m_OnOffValues[5]), (Action <bool>)(v => Form1.m_CurrentPatch.m_OnOffValues[5] = v)), 840, 517);
            this.m_OnOffButtons[6].Initialize(new Ref <bool>((Func <bool>)(() => Form1.m_CurrentPatch.m_OnOffValues[6]), (Action <bool>)(v => Form1.m_CurrentPatch.m_OnOffValues[6] = v)), 556, 505);
            Ref <bool> ref1         = Form1.m_CurrentPatch.GetRef(Form1.OnOff.PREAMP);
            Ref <bool> ref2         = Form1.m_CurrentPatch.GetRef(Form1.OnOff.PREFX);
            Ref <bool> ref3         = Form1.m_CurrentPatch.GetRef(Form1.OnOff.MOD);
            Ref <bool> ref4         = Form1.m_CurrentPatch.GetRef(Form1.OnOff.DELAY);
            Ref <bool> ref5         = Form1.m_CurrentPatch.GetRef(Form1.OnOff.REV);
            Ref <bool> ref6         = Form1.m_CurrentPatch.GetRef(Form1.OnOff.POWER);
            Ref <bool> _OnOffButton = Form1.m_CurrentPatch.GetRef(Form1.OnOff.CAB);

            this.m_AllKnobs[0].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREAMP_GAIN), 378, 358, "GAIN", ref1);
            this.m_AllKnobs[1].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREAMP_VOLUME), 450, 358, "VOLUME", ref1);
            this.m_AllKnobs[2].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREAMP_THRESHOLD), 540, 358, "THRESHOLD", ref1);
            this.m_AllKnobs[3].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREAMP_BASS), 628, 358, "BASS", ref1);
            this.m_AllKnobs[4].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREAMP_MIDDLE), 700, 358, "MIDDLE", ref1);
            this.m_AllKnobs[5].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREAMP_TREBLE), 772, 358, "TREBLE", ref1);
            this.m_AllKnobs[6].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREFX_PARAM1), 577, 177, "MODE", ref2);
            this.m_AllKnobs[7].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREFX_PARAM2), 644, 177, "DRIVE", ref2);
            this.m_AllKnobs[8].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREFX_PARAM3), 711, 177, "TONE", ref2);
            this.m_AllKnobs[9].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.PREFX_PARAM4), 777, 177, "LEVEL", ref2);
            this.m_AllKnobs[10].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.MOD_SPEED), 1045, 177, "SPEED", ref3);
            this.m_AllKnobs[11].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.MOD_DEPTH), 1112, 177, "DEPTH", ref3);
            this.m_AllKnobs[12].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.MOD_TONE), 1178, 177, "TONE", ref3);
            this.m_AllKnobs[13].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.DEL_TIME), 978, 366, "TIME", ref4);
            this.m_AllKnobs[14].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.DEL_FEEDBACK), 1045, 366, "FEEDBACK", ref4);
            this.m_AllKnobs[15].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.DEL_AGE), 1112, 366, "AGE", ref4);
            this.m_AllKnobs[16].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.DEL_LEVEL), 1178, 366, "LEVEL", ref4);
            this.m_AllKnobs[17].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.REV_DECAY), 977, 558, "DECAY", ref5);
            this.m_AllKnobs[18].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.REV_PREDELAY), 1044, 558, "PRE-DELAY", ref5);
            this.m_AllKnobs[19].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.REV_TONE), 1111, 558, "TONE", ref5);
            this.m_AllKnobs[20].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.REV_LEVEL), 1177, 558, "LEVEL", ref5);
            this.m_AllKnobs[21].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.POWER_PRESENCE), 373, 546, "PRESENCE", ref6);
            this.m_AllKnobs[22].Initialize(Form1.m_CurrentPatch.GetRef(Form1.Knobs.POWER_RESONANCE), 455, 546, "RESONANCE", ref6);
            this.m_AllKnobs[6].EraseIfNotActive  = true;
            this.m_AllKnobs[6].EraseRect         = new Rectangle(545, 143, 66, 133);
            this.m_AllKnobs[13].m_bFloat         = false;
            this.m_AllKnobs[13].m_RangeMul       = 1f;
            this.m_AllKnobs[13].MaxValue         = 4000f;
            this.m_AllKnobs[13].m_FontSize       = 15;
            this.m_AllKnobs[13].m_TextOffset     = 3;
            this.m_AllKnobs[15].EraseIfNotActive = true;
            this.m_AllKnobs[15].EraseRect        = new Rectangle(1112, 366, 66, 133);
            this.m_AllKnobs[15].EraseIfNotActive = true;
            this.m_AllKnobs[15].EraseRect        = new Rectangle(1081, 332, 66, 133);
            this.m_BitmapButtons[0].Initialize(140, 210, 76, 65, BitmapList.Import);
            this.m_BitmapButtons[1].Initialize(217, 210, 76, 65, BitmapList.Export);
            this.m_BitmapButtons[2].Initialize(188, (int)sbyte.MaxValue, 30, 30, BitmapList.Prev);
            this.m_BitmapButtons[3].Initialize(228, (int)sbyte.MaxValue, 30, 30, BitmapList.Next);
            this.m_BitmapButtons[4].Initialize(369, 143, 44, 34, BitmapList.ButtonOff);
            this.m_BitmapButtons[5].Initialize(369, 203, 44, 34, BitmapList.ButtonOff);
            this.m_BitmapButtons[6].Initialize(1180, 30, 25, 25, BitmapList.Help);
            this.m_BitmapButtons[6].m_EraseBack = false;
            this.m_BitmapButtons[7].Initialize(899, 124, 13, 19, BitmapList.ImportSmall);
            this.m_BitmapButtons[8].Initialize(498, 123, 13, 19, BitmapList.ImportSmall);
            this.m_BitmapButtons[9].Initialize(895, 507, 13, 19, BitmapList.ImportSmall);
            this.m_BitmapButtons[10].Initialize(74, 371, 13, 19, BitmapList.ImportSmall);
            this.m_BitmapButtons[11].Initialize(899, 314, 13, 19, BitmapList.ImportSmall);
            this.m_BitmapButtons[12].Initialize(75, 552, 13, 19, BitmapList.ImportSmall);
            this.m_BitmapButtons[0].m_TooltipText  = "Imports patch from amplifier from selected patch number";
            this.m_BitmapButtons[1].m_TooltipText  = "Exports patch to amplifier to selected patch number";
            this.m_BitmapButtons[2].m_TooltipText  = "Previous patch";
            this.m_BitmapButtons[3].m_TooltipText  = "Next patch";
            this.m_BitmapButtons[7].m_TooltipText  = "Imports MOD settings from saved file";
            this.m_BitmapButtons[8].m_TooltipText  = "Imports Pre-FX settings from saved file";
            this.m_BitmapButtons[9].m_TooltipText  = "Imports Reverb settings from saved file";
            this.m_BitmapButtons[10].m_TooltipText = "Imports Preamp settings from saved file";
            this.m_BitmapButtons[11].m_TooltipText = "Imports Delay settings from saved file";
            this.m_BitmapButtons[12].m_TooltipText = "Imports Power Amp settings from saved file";
            Bitmap[] BitmapArray1 = new Bitmap[15]
            {
                BitmapList.jtm45,
                BitmapList.dsl,
                BitmapList.american,
                BitmapList.jvm,
                BitmapList.acoustic,
                BitmapList.bluesbreaker,
                BitmapList.plexi,
                BitmapList.american,
                BitmapList.jcm800,
                BitmapList.english,
                BitmapList.jvm,
                BitmapList.dsl,
                BitmapList.american,
                BitmapList.jubilee,
                BitmapList.natural
            };
            string[] NameArray1 = new string[15]
            {
                "Clean JTM45",
                "Clean DSL",
                "Clean American",
                "Clean JVM",
                "Acoustic Simulator",
                "Bluesbreaker",
                "Plexi",
                "Crunch American",
                "JCM800",
                "'50s British",
                "OD JVM",
                "OD DSL",
                "OD American",
                "OD Silver Jubilee",
                "Natural (No FX)"
            };
            this.m_ImageSelectors[0].Initialize(ref BitmapArray1, ref NameArray1, new Rectangle((int)sbyte.MaxValue, 312, 200, 150), Form1.m_CurrentPatch.GetRef(Form1.ImgSelectorList.Preamp), ref1);
            Bitmap[] BitmapArray2 = new Bitmap[8]
            {
                BitmapList.cab_1960,
                BitmapList.cab_1960,
                BitmapList.cab_1960,
                BitmapList.cab_1960,
                BitmapList.cab_1936,
                BitmapList.cab_1936,
                BitmapList.cab_1912,
                BitmapList.cab_1974
            };
            string[] NameArray2 = new string[8]
            {
                "1960",
                "1960V",
                "1960AX",
                "1960HW",
                "1936",
                "1936V",
                "1912",
                "1974CX"
            };
            this.m_ImageSelectors[1].Initialize(ref BitmapArray2, ref NameArray2, new Rectangle(620, 488, 170, 170), Form1.m_CurrentPatch.GetRef(Form1.ImgSelectorList.Cab), _OnOffButton);
            this.m_ImageSelectors[1].m_TextOffset = 60;
            this.m_ImageSelectors[1].m_FontSize   = 24;
            Bitmap[] BitmapArray3 = new Bitmap[4]
            {
                BitmapList.pow_jcm,
                BitmapList.pow_30w,
                BitmapList.pow_english,
                BitmapList.pow_american
            };
            string[] NameArray3 = new string[4]
            {
                "Classic 100w",
                "Vintage 30 watts",
                "British Class A",
                "American Class A/B"
            };
            this.m_ImageSelectors[2].Initialize(ref BitmapArray3, ref NameArray3, new Rectangle(121, 498, 175, 140), Form1.m_CurrentPatch.GetRef(Form1.ImgSelectorList.Power), ref6);
            this.m_ImageSelectors[2].m_TextOffset = 30;
            this.m_ImageSelectors[2].m_FontSize   = 14;
            string[] NameArray4 = new string[4]
            {
                "Compressor",
                "Distortion",
                "Auto Wah",
                "Pitch Shifter"
            };
            this.m_TextSelectors[0].Initialize(ref NameArray4, new Rectangle(440, 190, 86, 86), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.PreFX), ref2);
            string[] NameArray5 = new string[4]
            {
                "Chorus",
                "Flanger",
                "Phaser",
                "Tremolo"
            };
            this.m_TextSelectors[3].Initialize(ref NameArray5, new Rectangle(840, 190, 86, 86), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.Mod), ref3);
            string[] NameArray6 = new string[4]
            {
                "Studio",
                "Vintage",
                "Multi",
                "Reverse"
            };
            this.m_TextSelectors[8].Initialize(ref NameArray6, new Rectangle(840, 375, 86, 86), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.DelayType), ref4);
            string[] NameArray7 = new string[4]
            {
                "Room",
                "Hall",
                "Spring",
                "Stadium"
            };
            this.m_TextSelectors[9].Initialize(ref NameArray7, new Rectangle(840, 566, 86, 86), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.ReverbType), ref5);
            string[] NameArray8 = new string[4]
            {
                "1 tap",
                "2 taps",
                "3 taps",
                "4 taps"
            };
            this.m_TextSelectors[10].Initialize(ref NameArray8, new Rectangle(1089, 340, 50, 88), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.MultitapType), ref4);
            this.m_TextSelectors[10].Active = false;
            string[] NameArray9 = new string[3]
            {
                "GUV",
                "ODR",
                "DIST"
            };
            this.m_TextSelectors[1].Initialize(ref NameArray9, new Rectangle(545, 180, 60, 66), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.DistortionType), ref2);
            this.m_TextSelectors[1].Active = false;
            string[] NameArray10 = new string[2] {
                "ENV", "LFO"
            };
            this.m_TextSelectors[2].Initialize(ref NameArray10, new Rectangle(545, 180, 60, 66), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.WahType), ref2);
            this.m_TextSelectors[2].Active       = false;
            this.m_TextSelectors[2].m_TextOffset = 10;
            string[] NameArray11 = new string[2] {
                "CLS", "VIB"
            };
            this.m_TextSelectors[4].Initialize(ref NameArray11, new Rectangle(945, 180, 60, 66), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.ChorusType), ref3);
            this.m_TextSelectors[4].Active       = false;
            this.m_TextSelectors[4].m_TextOffset = 10;
            string[] NameArray12 = new string[2] {
                "JET", "MET"
            };
            this.m_TextSelectors[5].Initialize(ref NameArray12, new Rectangle(945, 180, 60, 66), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.FlangerType), ref3);
            this.m_TextSelectors[5].Active       = false;
            this.m_TextSelectors[5].m_TextOffset = 10;
            string[] NameArray13 = new string[2] {
                "CLS", "VBE"
            };
            this.m_TextSelectors[6].Initialize(ref NameArray13, new Rectangle(945, 180, 60, 66), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.PhaserType), ref3);
            this.m_TextSelectors[6].Active       = false;
            this.m_TextSelectors[6].m_TextOffset = 10;
            string[] NameArray14 = new string[2] {
                "VLV", "SQR"
            };
            this.m_TextSelectors[7].Initialize(ref NameArray14, new Rectangle(945, 180, 60, 66), Form1.m_CurrentPatch.GetRef(Form1.TextSelectorList.TremoloType), ref3);
            this.m_TextSelectors[7].Active       = false;
            this.m_TextSelectors[7].m_TextOffset = 10;
            Form1.m_CurrentPatch.m_PatchNumber   = 0;
            Form1.m_CurrentPatch.m_PatchName     = "-- no name --";
            for (int i = 0; i < 11; ++i)
            {
                this.UpdateSelectorLists(i);
            }
            this.m_NameLCD = new LcdEdit(18, (Action <Rectangle>)(v => this.Invalidate(v)), (Action <string>)(v =>
            {
                Form1.m_CurrentPatch.m_PatchName = v;
                Form1.m_CurrentPatch.SaveCurrent();
            }), "-- no name --", (Func <char, bool>)(v => v >= ' ' && v <= '~'), ' ', (Func <string, int, char, string>)((str, siz, p) => str.PadRight(siz, p)));
            this.m_NameLCD.SetText(Form1.m_CurrentPatch.m_PatchName);
            Form1.m_CurrentPatch.m_PatchName = this.m_NameLCD.GetText();
            this.m_NameLCD.Initialize((int)sbyte.MaxValue, 171, 201, 20);
            this.m_PatchNumLCD = new LcdEdit(2, (Action <Rectangle>)(v => this.Invalidate(v)), (Action <string>)(v =>
            {
                int num = int.Parse(v);
                Form1.m_CurrentPatch.m_PatchNumber = num;
                Form1.m_CurrentPatch.SaveCurrent();
            }), "00", (Func <char, bool>)(v => v >= '0' && v <= '9'), '0', (Func <string, int, char, string>)((str, siz, p) => str.PadLeft(siz, p)));
            this.m_PatchNumLCD.InsertionMode = false;
            this.m_PatchNumLCD.SetText(Form1.m_CurrentPatch.m_PatchNumber.ToString());
            this.m_PatchNumLCD.Initialize(137, 134, 27, 20);
            this.KeyPreview = true;
            this.KeyPress  += new KeyPressEventHandler(this.Form1_KeyPress);
            this.m_Midi     = new MidiCom();
            this.m_Midi.Connect();
            Form1.m_CurrentPatch.FillPatchFromEdit();
            byte[] msg = new byte[75]
            {
                (byte)240,
                (byte)0,
                (byte)33,
                (byte)21,
                (byte)48,
                (byte)16,
                (byte)0,
                (byte)114,
                (byte)3,
                (byte)0,
                (byte)80,
                (byte)108,
                (byte)101,
                (byte)120,
                (byte)105,
                (byte)32,
                (byte)82,
                (byte)111,
                (byte)99,
                (byte)107,
                (byte)32,
                (byte)32,
                (byte)32,
                (byte)32,
                (byte)32,
                (byte)32,
                (byte)32,
                (byte)32,
                (byte)0,
                (byte)70,
                (byte)40,
                (byte)50,
                (byte)70,
                (byte)50,
                (byte)0,
                (byte)0,
                (byte)0,
                (byte)0,
                (byte)0,
                (byte)0,
                (byte)1,
                (byte)6,
                (byte)30,
                (byte)0,
                (byte)0,
                (byte)0,
                (byte)0,
                (byte)0,
                (byte)0,
                (byte)1,
                (byte)0,
                (byte)3,
                (byte)66,
                (byte)10,
                (byte)10,
                (byte)40,
                (byte)1,
                (byte)0,
                (byte)20,
                (byte)20,
                (byte)50,
                (byte)50,
                (byte)1,
                (byte)0,
                (byte)1,
                (byte)1,
                (byte)50,
                (byte)40,
                (byte)12,
                (byte)13,
                (byte)26,
                (byte)27,
                (byte)28,
                (byte)29,
                (byte)247
            };
            Form1.m_CurrentPatch.m_GETRequestWaiting = true;
            Form1.m_CurrentPatch.DecodeSysexData(ref msg);
            Form1.m_CurrentPatch.LoadCurrent();
            this.m_PatchNumLCD.SetText(Form1.m_CurrentPatch.m_PatchNumber.ToString());
            if (Registry.CurrentUser.OpenSubKey("SOFTWARE\\CodePatchEditor") != null)
            {
                return;
            }
            Registry.CurrentUser.CreateSubKey("SOFTWARE\\CodePatchEditor");
            this.About();
        }