Пример #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);
        }
        public void ReLink()
        {
            int      v      = EffectType.Value;
            XGEffect effect = XGEffect.GetEffectByTypeValue(v & 0x7f | v << 1 & 0x7f00);

            if (effect == null)
            {
                return;
            }

            this.effect_ = effect;


            if (this.BlockType >= XGEffectBlockType.Insertion1)
            {
                for (int i = 0; i < 10; i++)
                {
                    efctParams[i].Address = effect.ExDataUsed ? BaseAddress + 0x30 + i * 2 : BaseAddress + 0x02 + i * 1;
                    efctParams[i].Count   = effect.ExDataUsed ? 2 : 1;
                }
            }

            XGEffect.XGEffectParam dummy = new XGEffect.XGEffectParam("---", 0, 0, 0, "", "---");
            for (int i = 0; i < 16; i++)
            {
                XGEffect.XGEffectParam param = effect.ParameterTypes[i] ?? dummy;
                efctParams[i].Name              = this.Name + " " + param.Name;
                efctParams[i].Description       = param.Description;
                efctParams[i].MinValue          = param.MinValue;
                efctParams[i].MaxValue          = param.MaxValue;
                efctParams[i].ToStringConverter = param.Conveter;
                efctParams[i].CenterValue       = param.MinValue;
            }
        }
        public void WriteEffect(XGEffect effect)
        {
            int v = effect.EffectValue;

            EffectType.WriteValue(v & 0x7f | v >> 1 & 0x3f80);
            ReLink();
            for (int i = 0; i < 16; i++)
            {
                efctParams[i].WriteValue(effect.InitialValues[i]);
            }
        }
        public void SetEffect(XGEffect effect)
        {
            int v = effect.EffectValue;

            EffectType.Value = v & 0x7f | v >> 1 & 0x3f80;
            ReLink();
            for (int i = 0; i < 16; i++)
            {
                efctParams[i].Value = effect.InitialValues[i];
            }
        }
Пример #5
0
 void OnBulkDumpChain(int address)
 {
     // Insertion Effect
     if ((address & 0xFFFCFF) == 0x030000)
     {
         int      v  = ParameterMemoryData.Read2(address);
         XGEffect fx = XGEffect.GetEffectByTypeValue(v & 0x7f | v << 1 & 0x7f00);
         if (fx != null && fx.ExDataUsed)
         {
             SendXGBulkDumpRequest(address + 0x30);
         }
     }
 }
Пример #6
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);
        }
        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();
        }
Пример #8
0
 void DecideEffect(XGEffectBlockType type, XGEffect efct)
 {
     new XGEffectParams(Device, type).SetEffect(efct);
     ReCreateScreen();
 }
Пример #9
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++, "---", "---");
                }
            }
        }