コード例 #1
0
        ContextMenuStrip CreateMenu(XGEffectBlockType type)
        {
            ContextMenuStrip   strip     = new ContextMenuStrip();
            EffectSelectorMenu container = new EffectSelectorMenu();

            strip.Items.Add(container);

            for (int i = 0; i < XGEffect.AllEffects.Count; i++)
            {
                XGEffect efct = XGEffect.AllEffects[i];
                if (type >= XGEffectBlockType.Variation ||
                    (type == XGEffectBlockType.Reverb && efct.SelectableForReverb) ||
                    (type == XGEffectBlockType.Chorus && efct.SelectableForChorus))
                {
                    container.AddButton(XGEffect.AllEffects[i].Name,
                                        XGEffect.AllEffects[i].Description,
                                        () => { strip.Close(); DecideEffect(type, efct); },
                                        efct.SelectableForReverb & efct.SelectableForChorus ? Color.DarkGray :
                                        efct.SelectableForReverb?Color.Maroon:
                                        efct.SelectableForChorus ? Color.Teal :
                                        Color.Navy
                                        );
                }
            }
            strip.LayoutStyle = ToolStripLayoutStyle.Flow;

            return(strip);
        }
コード例 #2
0
        void ResetEffect(XGEffectBlockType blockType, string effectName)
        {
            Action <XGMidiParameter, int> writeValue = (p, v) => { if (p != null)
                                                                   {
                                                                       p.WriteValue(v);
                                                                   }
            };

            var eff = new XGEffectParams(this, blockType);

            eff.WriteEffect(XGEffect.GetEffectByName(effectName));
            writeValue(eff.SendToChorus, 0);
            writeValue(eff.SendToReverb, 0);
            writeValue(eff.Return, 0x40);
            writeValue(eff.Pan, 0x40);
            writeValue(eff.VariationConnect, 0);
            writeValue(eff.PartNumber, 0x7F);
        }
コード例 #3
0
        public static int GetEffectBlockAddress(XGEffectBlockType type)
        {
            switch (type)
            {
            case XGEffectBlockType.Reverb: return(0x020100);

            case XGEffectBlockType.Chorus: return(0x020120);

            case XGEffectBlockType.Variation: return(0x020140);

            case XGEffectBlockType.Insertion1: return(0x030000);

            case XGEffectBlockType.Insertion2: return(0x030100);

            case XGEffectBlockType.Insertion3: return(0x030200);

            case XGEffectBlockType.Insertion4: return(0x030300);
            }
            throw new ArgumentOutOfRangeException();
        }
コード例 #4
0
        void ResetEffect(XGEffectBlockType blockType, string effectName)
        {
            Action<XGMidiParameter, int> writeValue = (p, v) => { if (p != null) { p.WriteValue(v); } };

            var eff = new XGEffectParams(this, blockType);
            eff.WriteEffect(XGEffect.GetEffectByName(effectName));
            writeValue(eff.SendToChorus, 0);
            writeValue(eff.SendToReverb, 0);
            writeValue(eff.Return, 0x40);
            writeValue(eff.Pan, 0x40);
            writeValue(eff.VariationConnect, 0);
            writeValue(eff.PartNumber, 0x7F);
        }
コード例 #5
0
 void PopMenu(XGEffectBlockType type)
 {
     effectSelectors[(int)type].Show(MousePosition);
 }
コード例 #6
0
 void DecideEffect(XGEffectBlockType type, XGEffect efct)
 {
     new XGEffectParams(Device, type).SetEffect(efct);
     ReCreateScreen();
 }
コード例 #7
0
        ContextMenuStrip CreateMenu(XGEffectBlockType type)
        {
            ContextMenuStrip strip = new ContextMenuStrip();
            EffectSelectorMenu container = new EffectSelectorMenu();
            strip.Items.Add(container);

            for (int i = 0; i < XGEffect.AllEffects.Count; i++)
            {
                XGEffect efct = XGEffect.AllEffects[i];
                if (type >= XGEffectBlockType.Variation
                    || (type == XGEffectBlockType.Reverb && efct.SelectableForReverb)
                    || (type == XGEffectBlockType.Chorus && efct.SelectableForChorus))
                {
                    container.AddButton(XGEffect.AllEffects[i].Name,
                        XGEffect.AllEffects[i].Description,
                        () => { strip.Close(); DecideEffect(type, efct); },
                        efct.SelectableForReverb & efct.SelectableForChorus ? Color.DarkGray :
                        efct.SelectableForReverb ? Color.Maroon :
                        efct.SelectableForChorus ? Color.Teal :
                        Color.Navy
                        );
                }
            }
            strip.LayoutStyle = ToolStripLayoutStyle.Flow;

            return strip;
        }
コード例 #8
0
        public XGEffectParams(XGMidiIODevice host, XGEffectBlockType type)
            : base(host, "Effect[" + type + "]", GetEffectBlockAddress(type))
        {
            BlockType  = type;
            efctParams = new XGMidiParameter[16];

            int address = 0;

            EffectType = AddParameter("EffectType", address++, 0x00, 0x00, 0x00);
            EffectType.ToStringConverter = v => XGEffect.GetEffectByTypeValue(v << 1 & 0x7F00 | v & 0x7F).Name;
            EffectType.Count             = 2;
            address++;

            bool isSystemEffect = type <= XGEffectBlockType.Variation;
            bool isInsEffect    = type >= XGEffectBlockType.Variation;
            bool hasSendToRev   = type == XGEffectBlockType.Chorus || type == XGEffectBlockType.Variation;
            bool hasSendToCho   = type == XGEffectBlockType.Variation;
            bool hasVarConnect  = type == XGEffectBlockType.Variation;

            for (int i = 0; i < 10; i++)
            {
                if (type != XGEffectBlockType.Variation)
                {
                    efctParams[i] = AddParameter("Parameter " + i, address, 0, 127, 0);
                    address      += 1;
                }
                else
                {
                    efctParams[i]       = AddParameter("Parameter " + i, address, 0, 16384, 0);
                    efctParams[i].Count = 2;
                    address            += 2;
                }
            }

            Return           = isSystemEffect ? AddParameter("Return", address++, 0x00, 0x7f, 0x00) : null;
            Pan              = isSystemEffect ? AddParameter("Pan", address++, 0x00, 0x7f, 0x40, XGMidiParameter.PanpotPM) : null;
            SendToReverb     = hasSendToRev ? AddParameter("SendToReverb", address++, 0x00, 0x7f, 0x00) : null;
            SendToChorus     = hasSendToCho ? AddParameter("SendToChorus", address++, 0x00, 0x7f, 0x00) : null;
            VariationConnect = hasVarConnect ? AddParameter("VariationConnect", address++, 0x00, 0x01, 0x00, v => v == 0 ? "Insertion" : v == 1 ? "System" : "? " + v) : null;
            if (isInsEffect)
            {
                PartNumber = AddParameter("PartNumber", address++, 0, 66, 0);
                PartNumber.ToStringConverter  = v => v == 66 ? "OFF" : v < 64 ? (v + 1).ToString() : v == 64 ? "AD1" : v == 65 ? "AD2" : "? " + v;
                PartNumber.ReadValueEncoding  = v => v != 127 ? v : 66;
                PartNumber.WriteValueEncoding = v => v != 66 ? v : 127;
            }

            for (int i = 0; i < 6; i++)
            {
                int subBlock =
                    type == XGEffectBlockType.Reverb ? 0x10 :
                    type == XGEffectBlockType.Chorus ? 0x10 :
                    type == XGEffectBlockType.Variation ? 0x30 :
                    type >= XGEffectBlockType.Insertion1 ? 0x20 :
                    0;

                efctParams[10 + i] = AddParameter("---", subBlock + i, 0, 127, 0);
                address           += 1;
            }

            EffectParameters = new ReadOnlyCollection <XGMidiParameter>(efctParams);

            ReLink();
        }
コード例 #9
0
 public static int GetEffectBlockAddress(XGEffectBlockType type)
 {
     switch (type)
     {
         case XGEffectBlockType.Reverb: return 0x020100;
         case XGEffectBlockType.Chorus: return 0x020120;
         case XGEffectBlockType.Variation: return 0x020140;
         case XGEffectBlockType.Insertion1: return 0x030000;
         case XGEffectBlockType.Insertion2: return 0x030100;
         case XGEffectBlockType.Insertion3: return 0x030200;
         case XGEffectBlockType.Insertion4: return 0x030300;
     }
     throw new ArgumentOutOfRangeException();
 }
コード例 #10
0
        public XGEffectParams(XGMidiIODevice host, XGEffectBlockType type)
            : base(host, "Effect[" + type + "]", GetEffectBlockAddress(type))
        {
            BlockType = type;
            efctParams = new XGMidiParameter[16];

            int address = 0;
            EffectType = AddParameter("EffectType", address++, 0x00, 0x00, 0x00);
            EffectType.ToStringConverter = v => XGEffect.GetEffectByTypeValue(v << 1 & 0x7F00 | v & 0x7F).Name;
            EffectType.Count = 2;
            address++;

            bool isSystemEffect = type <= XGEffectBlockType.Variation;
            bool isInsEffect = type >= XGEffectBlockType.Variation;
            bool hasSendToRev = type == XGEffectBlockType.Chorus || type == XGEffectBlockType.Variation;
            bool hasSendToCho = type == XGEffectBlockType.Variation;
            bool hasVarConnect = type == XGEffectBlockType.Variation;

            for (int i = 0; i < 10; i++)
            {
                if (type != XGEffectBlockType.Variation)
                {
                    efctParams[i] = AddParameter("Parameter " + i, address, 0, 127, 0);
                    address += 1;
                }
                else
                {
                    efctParams[i] = AddParameter("Parameter " + i, address, 0, 16384, 0);
                    efctParams[i].Count = 2;
                    address += 2;
                }
            }

            Return = isSystemEffect ? AddParameter("Return", address++, 0x00, 0x7f, 0x00) : null;
            Pan = isSystemEffect ? AddParameter("Pan", address++, 0x00, 0x7f, 0x40, XGMidiParameter.PanpotPM) : null;
            SendToReverb = hasSendToRev ? AddParameter("SendToReverb", address++, 0x00, 0x7f, 0x00) : null;
            SendToChorus = hasSendToCho ? AddParameter("SendToChorus", address++, 0x00, 0x7f, 0x00) : null;
            VariationConnect = hasVarConnect ? AddParameter("VariationConnect", address++, 0x00, 0x01, 0x00, v => v == 0 ? "Insertion" : v == 1 ? "System" : "? " + v) : null;
            if (isInsEffect)
            {
                PartNumber = AddParameter("PartNumber", address++, 0, 66, 0);
                PartNumber.ToStringConverter = v => v == 66 ? "OFF" : v < 64 ? (v + 1).ToString() : v == 64 ? "AD1" : v == 65 ? "AD2" : "? " + v;
                PartNumber.ReadValueEncoding = v => v != 127 ? v : 66;
                PartNumber.WriteValueEncoding = v => v != 66 ? v : 127;
            }

            for (int i = 0; i < 6; i++)
            {
                int subBlock =
                    type == XGEffectBlockType.Reverb ? 0x10 :
                    type == XGEffectBlockType.Chorus ? 0x10 :
                    type == XGEffectBlockType.Variation ? 0x30 :
                    type >= XGEffectBlockType.Insertion1 ? 0x20 :
                    0;

                efctParams[10 + i] = AddParameter("---", subBlock + i, 0, 127, 0);
                address += 1;
            }

            EffectParameters = new ReadOnlyCollection<XGMidiParameter>(efctParams);

            ReLink();
        }
コード例 #11
0
 void PopMenu(XGEffectBlockType type)
 {
     effectSelectors[(int)type].Show(MousePosition);
 }
コード例 #12
0
 void DecideEffect(XGEffectBlockType type, XGEffect efct)
 {
     new XGEffectParams(Device, type).SetEffect(efct);
     ReCreateScreen();
 }
コード例 #13
0
        void CreateEffectRack(int x, XGEffectParams efctParam)
        {
            XGEffectBlockType efctBlock = efctParam.BlockType;

            efctParam.ReLink();
            XGEffect efctDef = efctParam.Effect ?? XGEffect.AllEffects[0];

            switch (efctBlock)
            {
            case XGEffectBlockType.Reverb: valueColor = Color.Red; labelColor = Color.Maroon; break;

            case XGEffectBlockType.Chorus: valueColor = Color.Cyan; labelColor = Color.Teal; break;

            case XGEffectBlockType.Variation: valueColor = Color.Blue; labelColor = Color.Navy; break;

            case XGEffectBlockType.Insertion1: valueColor = Color.Lime; labelColor = Color.Green; break;

            case XGEffectBlockType.Insertion2: valueColor = Color.Yellow; labelColor = Color.FromArgb(0xFF, 0x8B, 0x8B, 0x00); break;

            case XGEffectBlockType.Insertion3: valueColor = Color.Magenta; labelColor = Color.Purple; break;

            case XGEffectBlockType.Insertion4: valueColor = Color.LightGray; labelColor = Color.Gray; break;
            }
            Parameters.Add(efctParam.EffectType);

            int y = 0;

            AddLabelCell("---- " + efctBlock.ToString(), x, 0, 5, labelColor);
            y++;
            XGPControlCell selectedEffectCell = AddTriggerCell(efctDef.Name, x, y, 7, valueColor, () => { });

            selectedEffectCell.Offset             = (v) => PopMenu(efctBlock);
            selectedEffectCell.GetDescriptionFunc = () => "Click to Change Effect " + efctBlock;

            y++;
            AddTriggerCell("[ReSend]", x, y, 2, valueColor, () => efctParam.ReSendAll()).GetDescriptionFunc = () => "DblClick to ReSend All " + efctParam.Name + "s.";
            AddTriggerCell("[Dump]", x + 2, y, 2, valueColor, () => { efctParam.RequestDump(); DoFunc(() => Device.AllDumpRequestHasDone, ReCreateScreen); }).GetDescriptionFunc = () => "DblClick to Request Dump All " + efctParam.Name + "s. ";
            AddTriggerCell(" ", x + 4, y, 3, labelColor, () => { });

            y++;

            bool insertionConnect = efctBlock >= XGEffectBlockType.Insertion1 ||
                                    efctBlock == XGEffectBlockType.Variation && efctParam.VariationConnect.Value == 0;

            switch (efctBlock)
            {
            case XGEffectBlockType.Reverb:
                AddDisabledControl(x, y++, "Connect", "System");
                AddControl(x, y++, "Return", efctParam.Return);
                AddControl(x, y++, "Pan", efctParam.Pan);
                AddDisabledControl(x, y++, "---", "---");
                AddDisabledControl(x, y++, "---", "---");
                //AddDisabledControl(x, y++, "Part", "---");
                break;

            case XGEffectBlockType.Chorus:
                AddDisabledControl(x, y++, "Connect", "System");
                AddControl(x, y++, "Return", efctParam.Return);
                AddControl(x, y++, "Pan", efctParam.Pan);
                AddControl(x, y++, "Reverb", efctParam.SendToReverb);
                AddDisabledControl(x, y++, "---", "---");
                break;

            case XGEffectBlockType.Variation:
                AddControl(x, y++, "Connect", efctParam.VariationConnect).Offset += v => { efctParam.ReLink(); ReCreateScreen(); };
                if (insertionConnect)
                {
                    AddControl(x, y++, "Part", efctParam.PartNumber);
                    AddDisabledControl(x, y++, "---", "---");
                    AddDisabledControl(x, y++, "---", "---");
                    AddDisabledControl(x, y++, "---", "---");
                }
                else
                {
                    //AddDisabledControl(x, y++, "Part", "---");
                    AddControl(x, y++, "Return", efctParam.Return);
                    AddControl(x, y++, "Pan", efctParam.Pan);
                    AddControl(x, y++, "Reverb", efctParam.SendToReverb);
                    AddControl(x, y++, "Chorus", efctParam.SendToChorus);
                }
                break;

            case XGEffectBlockType.Insertion1:
            case XGEffectBlockType.Insertion2:
            case XGEffectBlockType.Insertion3:
            case XGEffectBlockType.Insertion4:
                AddDisabledControl(x, y++, "Connect", "Insertion");
                //AddDisabledControl(x, y++, "Return", "---");
                //AddDisabledControl(x, y++, "Pan", "---");
                //AddDisabledControl(x, y++, "Reverb", "---");
                //AddDisabledControl(x, y++, "Chorus", "---");
                AddControl(x, y++, "Part", efctParam.PartNumber);
                AddDisabledControl(x, y++, "---", "---");
                AddDisabledControl(x, y++, "---", "---");
                AddDisabledControl(x, y++, "---", "---");
                break;
            }

            AddControl(x, y++, "---- Params ----", "---------");

            for (int i = 0; i < 16; i++)
            {
                XGEffect.XGEffectParam p = efctDef.ParameterTypes[i];

                // If "ENS DETUNE" is selected in Chorus Block, some parameters are not available.
                bool notAvailable = (efctBlock == XGEffectBlockType.Chorus && efctDef.EffectValue == 0x5700 && (i >= 10));

                if (p != null)
                {
                    if ((p.InsertionOnly && !insertionConnect) || (notAvailable))
                    {
                        AddDisabledControl(x, y++, p.Name, "---");
                    }
                    else
                    {
                        AddControl(x, y++, p.Name, efctParam.EffectParameters[i]);
                    }
                }
                else
                {
                    AddDisabledControl(x, y++, "---", "---");
                }
            }
        }