Example #1
0
        protected virtual void SetRest(outDatum od, int ch, int cc)
        {
            if (ch >= notecmd.Length)
            {
                return;
            }
            if (!(od.args[0] is Core.Rest))
            {
                return;
            }

            Core.Rest rs = (Core.Rest)od.args[0];
            notecmd[ch] = "r";
            length[ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / rs.length, rs.length);
        }
Example #2
0
        public override void SetParameter(outDatum od, int cc)
        {
            if (isTrace)
            {
                TraceInfo[od.linePos.ch].Enqueue(od);
            }

            int    n;
            string s;

            switch (od.type)
            {
            case enmMMLType.Instrument:
                if ((char)od.args[0] == 'E')
                {
                    envelope[od.linePos.ch] = (int)od.args[1];
                }
                else
                {
                    inst[od.linePos.ch] = od.args[1].ToString();
                }
                break;

            case enmMMLType.Volume:
                if (od.linePos != null)
                {
                    vol[od.linePos.ch] = (int)od.args[0];
                }
                break;

            case enmMMLType.Pan:
                pan[od.linePos.ch] = string.Format("{0}", (int)od.args[0]);
                break;

            case enmMMLType.Octave:
                octave[od.linePos.ch] = (int)od.args[0];
                break;

            case enmMMLType.OctaveDown:
                octave[od.linePos.ch]--;
                break;

            case enmMMLType.OctaveUp:
                octave[od.linePos.ch]++;
                break;

            case enmMMLType.Note:
                if (od.args != null && od.args.Count > 0)
                {
                    Core.Note nt    = (Core.Note)od.args[0];
                    int       shift = nt.shift;
                    string    f     = Math.Sign(shift) >= 0 ? string.Concat(Enumerable.Repeat("+", shift)) : string.Concat(Enumerable.Repeat("-", -shift));
                    notecmd[od.linePos.ch] = string.Format("o{0}{1}{2}", octave[od.linePos.ch], nt.cmd, f);
                    length[od.linePos.ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / nt.length, nt.length);

                    if (!beforeTie[od.linePos.ch])
                    {
                        if (vol[od.linePos.ch] != null)
                        {
                            keyOnMeter[od.linePos.ch] = (int)(256.0 / 128.0 * vol[od.linePos.ch]);
                        }
                    }
                    beforeTie[od.linePos.ch] = nt.tieSw;
                }
                break;

            case enmMMLType.Rest:
                Core.Rest rs = (Core.Rest)od.args[0];
                notecmd[od.linePos.ch] = "r";
                length[od.linePos.ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / rs.length, rs.length);
                break;

            case enmMMLType.Envelope:
                s = (string)od.args[0];
                envSw[od.linePos.ch] = s == "EON" ? "ON " : "OFF";
                break;

            case enmMMLType.LfoSwitch:
                s = (string)od.args[2];
                lfoSw[od.linePos.ch] = s;
                break;

            case enmMMLType.Detune:
                n = (int)od.args[0];
                detune[od.linePos.ch] = n;
                break;

            case enmMMLType.KeyShift:
                n = (int)od.args[0];
                keyShift[od.linePos.ch] = n;
                break;
            }
        }
Example #3
0
        public override void SetParameter(outDatum od, int cc)
        {
            int    n;
            string s;

            try
            {
                int ch = isMub ? GetChNumFromMucChNum(od.linePos.ch) : od.linePos.ch;

                if (isTrace)
                {
                    TraceInfo[ch].Enqueue(od);
                }

                switch (od.type)
                {
                case enmMMLType.ClockCounter:
                    if (od == null || od.args == null || od.args.Count < 1)
                    {
                        break;
                    }
                    clockCounter[ch] = (int)od.args[0];
                    break;

                case enmMMLType.Instrument:
                    if (od.linePos.part == "SSG")
                    {
                        envelope[ch] = (int)od.args[1];
                    }
                    else
                    {
                        inst[ch] = od.args[1].ToString();
                    }
                    break;

                //case enmMMLType.Envelope:
                //envelope[od.linePos.ch] = (int)od.args[1];
                //break;
                case enmMMLType.Volume:
                    if (od.linePos != null)
                    {
                        vol[ch] = (int)od.args[0];
                    }
                    break;

                case enmMMLType.Pan:
                    n = (int)od.args[0];
                    if (od.linePos.part == "SSG")
                    {
                        pan[ch] = "-";
                    }
                    else
                    {
                        pan[ch] = n == 0 ? "-" : (n == 1 ? "Right" : (n == 2 ? "Left" : (n == 3 ? "Center" : n.ToString())));
                    }
                    break;

                case enmMMLType.Octave:
                    octave[ch] = (int)od.args[0];
                    break;

                case enmMMLType.OctaveDown:
                    octave[ch]--;
                    break;

                case enmMMLType.OctaveUp:
                    octave[ch]++;
                    break;

                case enmMMLType.Note:
                    if (!isMub)
                    {
                        if (od.args == null || od.args.Count <= 0)
                        {
                            break;
                        }

                        Core.Note nt    = (Core.Note)od.args[0];
                        int       shift = nt.shift;
                        string    f     = Math.Sign(shift) >= 0 ? string.Concat(Enumerable.Repeat("+", shift)) : string.Concat(Enumerable.Repeat("-", -shift));
                        notecmd[ch] = string.Format("o{0}{1}{2}", octave[ch], nt.cmd, f);
                        length[ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / nt.length, nt.length);

                        if (!beforeTie[ch])
                        {
                            if (vol[ch] != null)
                            {
                                keyOnMeter[ch] = (int)(256.0 / (
                                                           od.linePos.part == "FMOPN" ? 128 : (
                                                               od.linePos.part == "FMOPNex" ? 128 : (
                                                                   od.linePos.part == "SSG" ? 16 : (
                                                                       od.linePos.part == "RHYTHM" ? 32 : 256
                                                                       )))) * vol[ch]);
                            }
                        }
                        beforeTie[ch] = nt.tieSw;
                    }
                    else
                    {
                        if (od.args == null || od.args.Count <= 0)
                        {
                            break;
                        }
                        octave[ch]  = ((int)od.args[0] >> 4);
                        notecmd[ch] = string.Format("o{0}{1}", octave[ch], noteStrTbl[((int)od.args[0] & 0xf)]);
                        length[ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * clockCounter[ch] / (int)od.args[1], (int)od.args[1]);
                        if (vol[ch] != null)
                        {
                            keyOnMeter[ch] = (int)(256.0 / (
                                                       od.linePos.part == "FM" ? 15 : (
                                                           od.linePos.part == "SSG" ? 15 : (
                                                               od.linePos.part == "RHYTHM" ? 63 : 255
                                                               ))) * vol[ch]);
                        }
                    }
                    break;

                case enmMMLType.Rest:
                    if (!isMub)
                    {
                        if (od.args != null)
                        {
                            Core.Rest rs = (Core.Rest)od.args[0];
                            notecmd[ch] = "r";
                            length[ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / rs.length, rs.length);
                        }
                    }
                    else
                    {
                        if (od.args != null)
                        {
                            notecmd[ch] = "r";
                            length[ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * clockCounter[ch] / (int)od.args[0], (int)od.args[0]);
                        }
                    }
                    break;

                case enmMMLType.Envelope:
                    s         = (string)od.args[0];
                    envSw[ch] = s == "EON" ? "ON " : "OFF";
                    break;

                case enmMMLType.LfoSwitch:
                    s         = (string)od.args[2];
                    lfoSw[ch] = s;
                    break;

                case enmMMLType.Detune:
                    n          = (int)od.args[0];
                    detune[ch] = n;
                    break;

                case enmMMLType.KeyShift:
                    n            = (int)od.args[0];
                    keyShift[ch] = n;
                    break;
                }
            }
            catch
            {
                ;//握りつぶす
            }
        }
Example #4
0
        public override void SetParameter(outDatum od, int cc)
        {
            if (isTrace)
            {
                TraceInfo[od.linePos.ch].Enqueue(od);
            }

            int    n;
            string s;

            switch (od.type)
            {
            case enmMMLType.Instrument:
                if (od.linePos.part == "SSG")
                {
                    envelope[od.linePos.ch] = (int)od.args[1];
                }
                else
                {
                    inst[od.linePos.ch] = od.args[1] != null ? od.args[1].ToString() : "(null)";
                }
                break;

            //case enmMMLType.Envelope:
            //envelope[od.linePos.ch] = (int)od.args[1];
            //break;
            case enmMMLType.Volume:
                if (od.linePos != null)
                {
                    vol[od.linePos.ch] = (int)od.args[0];
                }
                break;

            case enmMMLType.Pan:
                if (od.args.Count == 1)
                {
                    n = (int)od.args[0];
                    pan[od.linePos.ch] = n == 0 ? "-" : (n == 1 ? "Right" : (n == 2 ? "Left" : "Center"));
                }
                else
                {
                    pan[od.linePos.ch] = string.Format("L{0} R{1}", (int)od.args[0], (int)od.args[1]);
                }
                break;

            case enmMMLType.Octave:
                if (od.args != null && od.args.Count > 0)
                {
                    octave[od.linePos.ch] = (int)od.args[0];
                }
                break;

            case enmMMLType.OctaveDown:
                octave[od.linePos.ch]--;
                break;

            case enmMMLType.OctaveUp:
                octave[od.linePos.ch]++;
                break;

            case enmMMLType.Note:
                if (od.args != null && od.args.Count > 0)
                {
                    Core.Note nt    = (Core.Note)od.args[0];
                    int       shift = nt.shift;
                    string    f     = Math.Sign(shift) >= 0 ? string.Concat(Enumerable.Repeat("+", shift)) : string.Concat(Enumerable.Repeat("-", -shift));
                    notecmd[od.linePos.ch] = string.Format("o{0}{1}{2}", octave[od.linePos.ch], nt.cmd, f);
                    length[od.linePos.ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / nt.length, nt.length);

                    if (!beforeTie[od.linePos.ch])
                    {
                        if (vol[od.linePos.ch] != null)
                        {
                            keyOnMeter[od.linePos.ch] = (int)(256.0 / (
                                                                  od.linePos.part == "FMOPN" ? 128 : (
                                                                      od.linePos.part == "FMOPNex" ? 128 : (
                                                                          od.linePos.part == "SSG" ? 16 : (
                                                                              od.linePos.part == "RHYTHM" ? 32 : 256
                                                                              )))) * vol[od.linePos.ch]);
                        }
                    }
                    beforeTie[od.linePos.ch] = nt.tieSw;
                }
                break;

            case enmMMLType.Rest:
                Core.Rest rs = (Core.Rest)od.args[0];
                notecmd[od.linePos.ch] = "r";
                length[od.linePos.ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / rs.length, rs.length);
                break;

            case enmMMLType.Envelope:
                s = (string)od.args[0];
                envSw[od.linePos.ch] = s == "EON" ? "ON " : "OFF";
                break;

            case enmMMLType.LfoSwitch:
                s = (string)od.args[2];
                lfoSw[od.linePos.ch] = s;
                break;

            case enmMMLType.Detune:
                n = (int)od.args[0];
                detune[od.linePos.ch] = n;
                break;

            case enmMMLType.KeyShift:
                n = (int)od.args[0];
                keyShift[od.linePos.ch] = n;
                break;
            }
        }
Example #5
0
        public override void SetParameter(outDatum od, int cc)
        {
            if (isTrace)
            {
                TraceInfo[od.linePos.ch].Enqueue(od);
            }


            switch (od.type)
            {
            case enmMMLType.Instrument:
                break;

            case enmMMLType.Octave:
                break;

            case enmMMLType.OctaveDown:
                break;

            case enmMMLType.OctaveUp:
                break;

            case enmMMLType.Note:
                if (od.args != null && od.args.Count > 0)
                {
                    Core.Note nt    = (Core.Note)od.args[0];
                    int       shift = nt.shift;
                    string    f     = Math.Sign(shift) >= 0 ? string.Concat(Enumerable.Repeat("+", shift)) : string.Concat(Enumerable.Repeat("-", -shift));
                    notecmd[od.linePos.ch] = string.Format("o{0}{1}{2}", octave[od.linePos.ch], nt.cmd, f);
                    length[od.linePos.ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / nt.length, nt.length);

                    if (!beforeTie[od.linePos.ch])
                    {
                        if (vol[od.linePos.ch] != null)
                        {
                            keyOnMeter[od.linePos.ch] = (int)(256.0 / 16.0 * vol[od.linePos.ch]);
                        }
                    }
                    beforeTie[od.linePos.ch] = nt.tieSw;
                }
                break;

            case enmMMLType.Rest:
                Core.Rest rs = (Core.Rest)od.args[0];
                notecmd[od.linePos.ch] = "r";
                length[od.linePos.ch]  = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / rs.length, rs.length);
                break;

            case enmMMLType.Lyric:
                int ls = (int)od.args[1];
                notecmd[od.linePos.ch]    = "lyric";
                length[od.linePos.ch]     = string.Format("{0:0.##}(#{1:d})", 1.0 * cc / ls, ls);
                keyOnMeter[od.linePos.ch] = (int)(255.0);
                break;

            case enmMMLType.Volume:
                break;

            case enmMMLType.Pan:
                break;

            case enmMMLType.Envelope:
                break;

            case enmMMLType.LfoSwitch:
                break;

            case enmMMLType.Detune:
                break;

            case enmMMLType.KeyShift:
                break;
            }
        }