コード例 #1
0
        public XGDrumParams(XGMidiIODevice host, int setup, int note)
            : base(host, "DRUM SETUP S" + (setup + 1) + "N" + note, 0x300000 | setup << 16 | note << 8)
        {
            this.SetupNumber = setup;
            this.NoteNumber  = note;

            PitchCoarse = AddParameter("PitchCoarse", 0x00, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            PitchFine   = AddParameter("PitchFine", 0x01, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            Volume      = AddParameter("Volume", 0x02, 0x00, 0x7f, 0x00);
            AltGroup    = AddParameter("AltGroup", 0x03, 0x00, 0x7f, 0x00);
            Pan         = AddParameter("Pan", 0x04, 0x00, 0x7f, 0x40, XGMidiParameter.PanpotPM);
            Reverb      = AddParameter("Reverb", 0x05, 0x00, 0x7f, 0x00);
            Chorus      = AddParameter("Chorus", 0x06, 0x00, 0x7f, 0x00);
            Variation   = AddParameter("Variation", 0x07, 0x00, 0x7f, 0x00);
            KeyAssign   = AddParameter("KeyAssign", 0x08, 0x00, 0x7f, 0x00);
            RcvNoteOff  = AddParameter("RcvNoteOff", 0x09, 0x00, 0x01, 0x00, XGMidiParameter.OnOff);
            RcvNoteOn   = AddParameter("RcvNoteOn", 0x0A, 0x00, 0x01, 0x00, XGMidiParameter.OnOff);

            LPFCutoffFreq = AddParameter("LPFCutoffFreq", 0x0B, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            LPFResonance  = AddParameter("LPFResonance", 0x0C, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            EGAttackRate  = AddParameter("EGAttackRate", 0x0D, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            EGDecay1Rate  = AddParameter("EGDecay1Rate", 0x0E, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            EGDecay2Rate  = AddParameter("EGDecay2Rate", 0x0F, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);

            EQBassGain   = AddParameter("EQBassGain", 0x20, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            EQTrebleGain = AddParameter("EQTrebleGain", 0x21, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            EQBassFreq   = AddParameter("EQBassFreq", 0x24, 0x04, 0x28, 0x04, XGMidiParameter.FreqToString);
            EQTrebleFreq = AddParameter("EQTrebleFreq", 0x25, 0x1C, 0x3A, 0x1C, XGMidiParameter.FreqToString);

            HPFCutoffFreq = AddParameter("HPFCutoffFreq", 0x50, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);

            VelocitySensePitch     = AddParameter("VelocitySensePitch", 0x60, 0x30, 0x50, 0x40, XGMidiParameter.CenterPM);
            VelocitySenseLPFCutoff = AddParameter("VelocitySenseLPFCutoff", 0x61, 0x30, 0x50, 0x40, XGMidiParameter.CenterPM);
        }
コード例 #2
0
        protected XGMidiParameter AddParameter(string name, int offset, int min, int max, int center, ToStringDelegate valStringConverter)
        {
            XGMidiParameter p = AddParameter(name, offset, min, max, center);

            p.ToStringConverter = valStringConverter;
            return(p);
        }
コード例 #3
0
        protected XGMidiParameter AddParameter(string name, int offset, int min, int max, int center)
        {
            XGMidiParameter p = new XGMidiParameter(Host, this.Name + " " + name, BaseAddress + offset, 1, min, max, center);

            Parameters.Add(p);
            return(p);
        }
コード例 #4
0
 public BandParameter(XGMidiParameter gain, XGMidiParameter freq, XGMidiParameter q, XGMidiParameter lowerShape, XGMidiParameter higherShape)
 {
     Debug.Assert(!(this.LowerShape != null && this.HigherShape != null)); // 両方が!nullであってはならぬ。
     this.Gain        = gain;
     this.Frequency   = freq;
     this.Q           = q;
     this.LowerShape  = lowerShape;
     this.HigherShape = higherShape;
     this.Shape       = this.LowerShape ?? this.HigherShape;
 }
コード例 #5
0
 public XGPControlCell AddControlCell(XGMidiParameter target, int x, int y, int w, Color c)
 {
     y += 2;
     XGPControlCell ctrl = new XGPControlCell()
     {
         Location = new Point(CellW * x + 6, CellH * y + 6),
         Size = new Size(CellW * w, CellH),
         BaseColor = c,
         TargetParameter = target,
     };
     XGControls.Add(ctrl);
     return ctrl;
 }
コード例 #6
0
        public XGPartParams(XGMidiIODevice host, int channel)
            : base(host, "Part[" + (channel + 1) + "]", 0x080000 | channel << 8)
        {
            Channel = channel;

            PartMode      = AddParameter("PartMode", 0x07, 0x00, 0x05, 0x00, XGMidiParameter.MakeTableToStringFunc("N", "D", "D1", "D2", "D3", "D4"));
            ProgramMSB    = AddParameter("ProgramMSB", 0x01, 0x00, 0x7f, 0x00);
            ProgramLSB    = AddParameter("ProgramLSB", 0x02, 0x00, 0x7f, 0x00);
            ProgramNumber = AddParameter("ProgramNumber", 0x03, 0x00, 0x7f, 0x00, XGMidiParameter.ProgramNumber);

            Pan       = AddParameter("Pan", 0x0E, 0x00, 0x7f, 0x40, XGMidiParameter.PanpotPM);
            Volume    = AddParameter("Volume", 0x0B, 0x00, 0x7f, 0x00);
            Reverb    = AddParameter("Reverb", 0x13, 0x00, 0x7f, 0x00);
            Chorus    = AddParameter("Chorus", 0x12, 0x00, 0x7f, 0x00);
            Variation = AddParameter("Variation", 0x14, 0x00, 0x7f, 0x00);
            DryLevel  = AddParameter("DryLevel", 0x11, 0x00, 0x7f, 0x00);

            LPFCutoffFreq  = AddParameter("LPFCutoffFreq", 0x18, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            LPFResonance   = AddParameter("LPFResonance", 0x19, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            HPFCutoffFreq  = AddParameter("HPFCutoffFreq", 0x020020, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            RcvNoteMessage = AddParameter("RcvNoteMessage", 0x35, 0x00, 0x01, 0x00, XGMidiParameter.OnOff);

            EGAttack  = AddParameter("EGAttack", 0x1A, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            EGDecay   = AddParameter("EGDecay", 0x1B, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            EGRelease = AddParameter("EGRelease", 0x1C, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);

            VibRate  = AddParameter("VibRate", 0x15, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            VibDepth = AddParameter("VibDepth", 0x16, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            VibDelay = AddParameter("VibDelay", 0x17, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);

            EQBassFreq   = AddParameter("EQBassFreq", 0x76, 0x04, 0x28, 0x0C, XGMidiParameter.FreqToString);
            EQBassGain   = AddParameter("EQBassGain", 0x72, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            EQTrebleFreq = AddParameter("EQTrebleFreq", 0x77, 0x1C, 0x3A, 0x36, XGMidiParameter.FreqToString);
            EQTrebleGain = AddParameter("EQTrebleGain", 0x73, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);

            MWPitchControl = AddParameter("MWPitchControl", 0x1D, 0x28, 0x58, 0x40, XGMidiParameter.CenterPM);
            MWLPFControl   = AddParameter("MWLPFControl", 0x1E, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            MWAmpControl   = AddParameter("MWAmpControl", 0x1F, 0x00, 0x7f, 0x40, XGMidiParameter.CenterPM);
            MWLFOPModDepth = AddParameter("MWLFOPModDepth", 0x20, 0x00, 0x7f, 0x00);
            MWLFOFModDepth = AddParameter("MWLFOFModDepth", 0x21, 0x00, 0x7f, 0x00);
            MWLFOAModDepth = AddParameter("MWLFOAModDepth", 0x22, 0x00, 0x7f, 0x00);
        }
コード例 #7
0
        public XGMultiEQParams(XGMidiIODevice host)
            : base(host, "MULTI EQ", 0x024000)
        {
            bandParams = new BandParameter[5];

            ToStringDelegate dBStringFunc = XGMidiParameter.MakePlusMinusToStringFunc("-", "dB", "+0dB", "+", "dB", null);
            ToStringDelegate QStringFunc  = v => (v * 0.1).ToString("0.0");

            Type          = AddParameter("Type", 0, 0, 4, 0, XGMidiParameter.MakeTableToStringFunc("FLAT", "JAZZ", "POPS", "ROCK", "CLASSIC"));
            Gain1         = AddParameter("Gain1", 1, 0x34, 0x4C, 0x40, dBStringFunc);
            Freq1         = AddParameter("Freq1", 2, 0x04, 0x28, 0x04, XGMidiParameter.FreqToString);
            Q1            = AddParameter("Q1", 3, 0x01, 0x78, 0x07, QStringFunc);
            Shape1        = AddParameter("Shape1", 4, 0, 1, 0, XGMidiParameter.MakeTableToStringFunc("SHELVING", "PEAKING"));
            bandParams[0] = new BandParameter(Gain1, Freq1, Q1, Shape1, null);

            Gain2         = AddParameter("Gain2", 5, 0x34, 0x4C, 0x40, dBStringFunc);
            Freq2         = AddParameter("Freq2", 6, 0x0E, 0x36, 0x0E, XGMidiParameter.FreqToString);
            Q2            = AddParameter("Q2", 7, 0x01, 0x78, 0x07, QStringFunc);
            bandParams[1] = new BandParameter(Gain2, Freq2, Q2, null, null);

            Gain3         = AddParameter("Gain3", 9, 0x34, 0x4C, 0x40, dBStringFunc);
            Freq3         = AddParameter("Freq3", 10, 0x0E, 0x36, 0x0E, XGMidiParameter.FreqToString);
            Q3            = AddParameter("Q3", 11, 0x01, 0x78, 0x07, QStringFunc);
            bandParams[2] = new BandParameter(Gain3, Freq3, Q3, null, null);

            Gain4         = AddParameter("Gain4", 13, 0x34, 0x4C, 0x40, dBStringFunc);
            Freq4         = AddParameter("Freq4", 14, 0x0E, 0x36, 0x0E, XGMidiParameter.FreqToString);
            Q4            = AddParameter("Q4", 15, 0x01, 0x78, 0x07, QStringFunc);
            bandParams[3] = new BandParameter(Gain4, Freq4, Q4, null, null);

            Gain5         = AddParameter("Gain5", 17, 0x34, 0x4C, 0x40, dBStringFunc);
            Freq5         = AddParameter("Freq5", 18, 0x1C, 0x3A, 0x1C, XGMidiParameter.FreqToString);
            Q5            = AddParameter("Q5", 19, 0x01, 0x78, 0x07, QStringFunc);
            Shape5        = AddParameter("Shape5", 20, 0, 1, 0, XGMidiParameter.MakeTableToStringFunc("SHELVING", "PEAKING"));
            bandParams[4] = new BandParameter(Gain5, Freq5, Q5, null, Shape5);

            Bands = new ReadOnlyCollection <BandParameter>(bandParams);
        }
コード例 #8
0
 XGPControlCell AddControl(int x, int y, string label, XGMidiParameter param)
 {
     Parameters.Add(param);
     AddLabelCell(label, x, y, 4, labelColor);
     return AddControlCell(param, x + 4, y, 3, valueColor);
 }
コード例 #9
0
 public BandParameter(XGMidiParameter gain, XGMidiParameter freq, XGMidiParameter q, XGMidiParameter lowerShape, XGMidiParameter higherShape)
 {
     Debug.Assert(!(this.LowerShape != null && this.HigherShape != null)); // 両方が!nullであってはならぬ。
     this.Gain = gain;
     this.Frequency = freq;
     this.Q = q;
     this.LowerShape = lowerShape;
     this.HigherShape = higherShape;
     this.Shape = this.LowerShape ?? this.HigherShape;
 }
コード例 #10
0
 protected XGMidiParameter AddParameter(string name, int offset, int min, int max, int center)
 {
     XGMidiParameter p = new XGMidiParameter(Host, this.Name + " " + name, BaseAddress + offset, 1, min, max, center);
     Parameters.Add(p);
     return p;
 }
コード例 #11
0
        void CreateXGPControls()
        {
            masterVolume_ = new XGMidiParameter(Device, "XGMasterVolume", 0x000004, 1, 0, 127, 0);
            masterAttn_ = new XGMidiParameter(Device, "XGMasterVolume", 0x000005, 1, 0, 127, 127);
            masterTranspose_ = new XGMidiParameter(Device, "Transpose", 0x000006, 1, 0x28, 0x58, 64);
            masterTranspose_.ToStringConverter = XGMidiParameter.CenterPM;
            masterTune_ = new XGMidiParameter(Device, "MasterTune", 0x000000, 4, 0, 0x7FF, 0x400);
            masterTune_.ReadValueEncoding = v => v & 0xF | v >> 3 & 0xF0 | v >> 6 & 0xF00;
            masterTune_.WriteValueEncoding = v => v & 0xF | (v & 0xF0) << 3 | (v & 0xF00) << 6;
            masterTune_.ToStringConverter = v => ((v - 1024) / 10).ToString("+000;-000") + "." + ((v - 1024) % 10).ToString();

            int w = 5;
            int x = 7;
            int y = -2;
            xgpGrid1.AddTriggerCell("[CONNECTION TEST]", x, y, w, Color.Gray, () =>
            {
                Device.WriteXGParam(0x10000, 4, 0);
                Device.WriteXGParam(0x10004, 4, 0);
                Device.WriteXGParam(0x10008, 4, 0);
                Device.WriteXGParam(0x1000C, 4, 0);

                Device.SendXGBulkDumpRequest(0x010000);
                while (!Device.AllDumpRequestHasDone) { Application.DoEvents(); }
                byte[] information = new byte[16];
                for (int i = 0; i < information.Length; i++) { information[i] = (byte)Device.ReadXGParam(0x10000 + i, 1); }
                if (information[0] != 0)
                {
                    int len = Array.IndexOf(information, 0);
                    string modelName = System.Text.Encoding.ASCII.GetString(information, 0, len >= 0 && len < 14 ? len : 14);
                    MessageBox.Show("Connection OK. \nReplied from " + modelName, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Reqest timed out.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }).GetDescriptionFunc = () => "DblClick: Request DeviceName";
            y++;

            xgpGrid1.AddTriggerCell("[XG SYSTEM ON]", x, y, w, Color.Red, () =>
            {
                if (MessageBox.Show("Send XG SYSTEM ON?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    Device.SendXGParameterByValue(0x00007E, 0, 1);
                    xgpGrid1.RedrawOnRequestComplete();
                }
            }).GetDescriptionFunc = () => "DblClick: Send XG SYSTEM ON.";
            y++;

            xgpGrid1.AddTriggerCell("[RESET All]", x, y, w, Color.Maroon, () =>
            {
                if (MessageBox.Show("Reset all parameters?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    Device.ResetXG();
                    xgpGrid1.RedrawOnRequestComplete();
                }
            }).GetDescriptionFunc = () => "DblClick: Reset all parameters.";
            y++;

            xgpGrid1.AddTriggerCell("[AllDump]", x, y, w, Color.Black, () =>
            {
                if (MessageBox.Show("Dump ALL XG Parameters?\n Including A1-A16 parts, drum S1-S4, Sys/INS effects settings.", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
                {
                    return;
                }

                lock (Device)
                {
                    Device.SendXGBulkDumpRequest(0x000000);
                    Device.SendXGBulkDumpRequest(0x010000);
                    Device.SendXGBulkDumpRequest(0x020100);
                    Device.SendXGBulkDumpRequest(0x020110);
                    Device.SendXGBulkDumpRequest(0x020120);
                    Device.SendXGBulkDumpRequest(0x020130);
                    Device.SendXGBulkDumpRequest(0x020140);
                    Device.SendXGBulkDumpRequest(0x020170);
                    Device.SendXGBulkDumpRequest(0x024000);
                    Device.SendXGBulkDumpRequest(0x030000);
                    Device.SendXGBulkDumpRequest(0x030020);
                    Device.SendXGBulkDumpRequest(0x030100);
                    Device.SendXGBulkDumpRequest(0x030120);
                    Device.SendXGBulkDumpRequest(0x030200);
                    Device.SendXGBulkDumpRequest(0x030220);
                    Device.SendXGBulkDumpRequest(0x030300);
                    Device.SendXGBulkDumpRequest(0x030320);
                    Device.SendXGBulkDumpRequest(0x030300);
                    Device.SendXGBulkDumpRequest(0x030320);

                    for (int i = 0; i < 16; i++)
                    {
                        Device.SendXGBulkDumpRequest(0x080000 | i << 8);
                        Device.SendXGBulkDumpRequest(0x080030 | i << 8);
                        Device.SendXGBulkDumpRequest(0x080070 | i << 8);
                        Device.SendXGBulkDumpRequest(0x080074 | i << 8);
                        Device.SendXGBulkDumpRequest(0x0A0020 | i << 8);
                    }

                    for (int i = 0; i < 4; i++)
                    {
                        for (int j = 0x0d; j <= 0x5B; j++)
                        {
                            Device.SendXGBulkDumpRequest(0x300000 | i << 16 | j << 8);
                            Device.SendXGBulkDumpRequest(0x300020 | i << 16 | j << 8);
                            Device.SendXGBulkDumpRequest(0x300050 | i << 16 | j << 8);
                            Device.SendXGBulkDumpRequest(0x300060 | i << 16 | j << 8);
                        }
                    }
                    progressBar1.Style = ProgressBarStyle.Marquee;
                }

                xgpGrid1.RedrawOnRequestComplete();
            }).GetDescriptionFunc = () => "DblClick: Request Dump all XG Params.";

            y++;

            x = 0;
            y = -2;
            w = 6;
            xgpGrid1.AddTriggerCell("[Dump]", x, y, w, Color.Black, () =>
            {
                masterVolume_.Pick();
                masterAttn_.Pick();
                masterTune_.Pick();
                masterTranspose_.Pick();
                xgpGrid1.RedrawOnRequestComplete();
            }).GetDescriptionFunc = () => "DblClick: Request Dump parameters.";
            y++;

            xgpGrid1.AddLabelCell("MasterVolume", x, y, w - 2, Color.Green);
            xgpGrid1.AddControlCell(masterVolume_, x + w - 2, y, 2, Color.Lime);
            y++;
            xgpGrid1.AddLabelCell("MasterAttn", x, y, w - 2, Color.Navy);
            xgpGrid1.AddControlCell(masterAttn_, x + w - 2, y, 2, Color.Blue);
            y++;
            xgpGrid1.AddLabelCell("Transpose", x, y, w - 2, Color.Olive);
            xgpGrid1.AddControlCell(masterTranspose_, x + w - 2, y, 2, Color.Yellow);
            y++;
            xgpGrid1.AddLabelCell("MasterTune", x, y, w - 2, Color.Purple);
            xgpGrid1.AddControlCell(masterTune_, x + w - 2, y, 2, Color.Magenta);
            y++;
            xgpGrid1.SetDevice(Device);
        }