Exemplo n.º 1
0
        public override void CmdInstrument(partWork pw, MML mml)
        {
            char type = (char)mml.args[0];
            int  n    = 0;

            if (mml.args[1].GetType() == typeof(int))
            {
                n = (int)mml.args[1];
            }
            else
            {
            }

            if (type == 'N')
            {
                if (pw.ch == 6 && pw.Type == enmChannelType.FMPCM)
                {
                    pw.instrument = n;
                    if (!parent.instPCM.ContainsKey(n))
                    {
                        msgBox.setErrMsg(string.Format(msg.get("E20002"), n), pw.getSrcFn(), pw.getLineNumber());
                    }
                    else
                    {
                        if (parent.instPCM[n].chip != enmChipType.YM2612)
                        {
                            msgBox.setErrMsg(string.Format(msg.get("E20003"), n), pw.getSrcFn(), pw.getLineNumber());
                        }
                    }
                    return;
                }
            }

            base.CmdInstrument(pw, mml);
        }
Exemplo n.º 2
0
        public void OutFmSetInstrument(partWork pw, int n, int vol)
        {
            if (!parent.instFM.ContainsKey(n))
            {
                msgBox.setWrnMsg(string.Format(msg.get("E11001"), n), pw.getSrcFn(), pw.getLineNumber());
                return;
            }

            int m = 3;

            if (pw.ch >= m + 3 && pw.ch < m + 6)
            {
                msgBox.setWrnMsg(msg.get("E11002"), pw.getSrcFn(), pw.getLineNumber());
                return;
            }

            if (parent.instFM[n].type == 0)
            {
                for (int ope = 0; ope < 4; ope++)
                {
                    ((ClsOPN)pw.chip).OutFmSetDtMl(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 8 + 2], parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 7 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetKsAr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 6 + 2], parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 0 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetAmDr(pw, ope, 1, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 1 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetSr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 2 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetSlRr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 4 + 2], parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 3 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetSSGEG(pw, ope, 0);
                    ((ClsOPN)pw.chip).OutFmSetTl(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]);
                }
                pw.op1ml  = parent.instFM[n].data[0 * Const.INSTRUMENT_OPERATOR_SIZE + 7];
                pw.op2ml  = parent.instFM[n].data[1 * Const.INSTRUMENT_OPERATOR_SIZE + 7];
                pw.op3ml  = parent.instFM[n].data[2 * Const.INSTRUMENT_OPERATOR_SIZE + 7];
                pw.op4ml  = parent.instFM[n].data[3 * Const.INSTRUMENT_OPERATOR_SIZE + 7];
                pw.op1dt2 = 0;
                pw.op2dt2 = 0;
                pw.op3dt2 = 0;
                pw.op4dt2 = 0;

                ((ClsOPN)pw.chip).OutFmSetFeedbackAlgorithm(pw, parent.instFM[n].data[0], parent.instFM[n].data[1]);
            }
            else
            {
                int  vch  = pw.ch;
                byte port = vch > 2 ? pw.port1 : pw.port0;
                vch = (byte)(vch > 2 ? vch - 3 : vch);
                for (int ope = 0; ope < 4; ope++)
                {
                    parent.OutData(port, (byte)(0x30 + vch + ope * 4), parent.instFM[n].data[ope]);                     //DT/ML
                    parent.OutData(port, (byte)(0x40 + vch + ope * 4), parent.instFM[n].data[ope + 4]);                 //TL
                    parent.OutData(port, (byte)(0x50 + vch + ope * 4), parent.instFM[n].data[ope + 8]);                 //KS/AR
                    parent.OutData(port, (byte)(0x60 + vch + ope * 4), (byte)(parent.instFM[n].data[ope + 12] | 0x80)); //AMON/DR
                    parent.OutData(port, (byte)(0x70 + vch + ope * 4), parent.instFM[n].data[ope + 16]);                //SR
                    parent.OutData(port, (byte)(0x80 + vch + ope * 4), parent.instFM[n].data[ope + 20]);                //SL/RR
                }
                parent.OutData(port, (byte)(0xb0 + vch), parent.instFM[n].data[24]);                                    //FB/AL
            }

            OutFmSetVolume(pw, vol, n);
            //SetFmVolume(pw);
        }
Exemplo n.º 3
0
        public void OutSetInstrument(partWork pw, int n, int vol)
        {
            if (!parent.instFM.ContainsKey(n))
            {
                msgBox.setWrnMsg(string.Format("未定義の音色(@{0})を指定しています。", n), pw.getSrcFn(), pw.getLineNumber());
                return;
            }

            for (int ope = 0; ope < 4; ope++)
            {
                OutSetDtMl(pw, ope, parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 9], parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 8]);
                OutSetKsAr(pw, ope, parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 7], parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 1]);
                OutSetAmDr(pw, ope, parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 11], parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 2]);
                OutSetDt2Sr(pw, ope, parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 10], parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 3]);
                OutSetSlRr(pw, ope, parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 5], parent.instFM[n][ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 4]);
            }
            pw.op1ml  = parent.instFM[n][0 * Const.INSTRUMENT_M_OPERATOR_SIZE + 8];
            pw.op2ml  = parent.instFM[n][1 * Const.INSTRUMENT_M_OPERATOR_SIZE + 8];
            pw.op3ml  = parent.instFM[n][2 * Const.INSTRUMENT_M_OPERATOR_SIZE + 8];
            pw.op4ml  = parent.instFM[n][3 * Const.INSTRUMENT_M_OPERATOR_SIZE + 8];
            pw.op1dt2 = parent.instFM[n][0 * Const.INSTRUMENT_M_OPERATOR_SIZE + 10];
            pw.op2dt2 = parent.instFM[n][1 * Const.INSTRUMENT_M_OPERATOR_SIZE + 10];
            pw.op3dt2 = parent.instFM[n][2 * Const.INSTRUMENT_M_OPERATOR_SIZE + 10];
            pw.op4dt2 = parent.instFM[n][3 * Const.INSTRUMENT_M_OPERATOR_SIZE + 10];

            OutSetPanFeedbackAlgorithm(pw, (int)pw.pan.val, parent.instFM[n][46], parent.instFM[n][45]);
            ((YM2151)pw.chip).OutSetVolume(pw, vol, n);
        }
Exemplo n.º 4
0
        public override void CmdInstrument(partWork pw, MML mml)
        {
            char type = (char)mml.args[0];
            int  n    = 0;

            if (mml.args[1].GetType() == typeof(int))
            {
                n = (int)mml.args[1];
            }
            else
            {
                string name = (string)mml.args[1];
                foreach (KeyValuePair <int, mucomVoice> voi in parent.instFM)
                {
                    if (voi.Value.Name == name)
                    {
                        n = voi.Value.No;
                    }
                }
            }

            if (type == 'I')
            {
                msgBox.setErrMsg(msg.get("E11003"), pw.getSrcFn(), pw.getLineNumber());
                return;
            }

            if (type == 'T')
            {
                n = Common.CheckRange(n, 0, 255);
                pw.toneDoubler = n;
                return;
            }

            if (type == 'E')
            {
                SetEnvelopParamFromInstrument(pw, n, mml);
                return;
            }

            if (pw.Type == enmChannelType.SSG)
            {
                SetEnvelopParamFromInstrument(pw, n, mml);
                return;
            }

            n             = Common.CheckRange(n, 0, 255);
            pw.instrument = n;
            //if (pw.beforeInstrument == pw.instrument) return;
            pw.beforeInstrument = n;
            ((ClsOPN)pw.chip).OutFmSetInstrument(pw, n, pw.volume);
        }
Exemplo n.º 5
0
        public void outYM2413SetInstrument(partWork pw, int n)
        {
            pw.instrument = n;

            if (!parent.instFM.ContainsKey(n))
            {
                msgBox.setWrnMsg(string.Format("未定義の音色(@{0})を指定しています。", n), pw.getSrcFn(), pw.getLineNumber());
                return;
            }

            for (byte ope = 0; ope < 2; ope++)
            {
                outYM2413SetAdr00_01(pw, ope
                                     , parent.instFM[n][ope * 11 + 7] != 0  //AM
                                     , parent.instFM[n][ope * 11 + 8] != 0  //VIB
                                     , parent.instFM[n][ope * 11 + 9] != 0  //EG
                                     , parent.instFM[n][ope * 11 + 10] != 0 //KS
                                     , parent.instFM[n][ope * 11 + 6] & 0xf //MT
                                     );
                parent.OutData(pw.port0, (byte)(0x4 + ope), (byte)((
                                                                       (parent.instFM[n][ope * 11 + 1] & 0xf) << 4) //AR
                                                                   | (parent.instFM[n][ope * 11 + 2] & 0xf)         // DR
                                                                   ));
                parent.OutData(pw.port0, (byte)(0x6 + ope), (byte)((
                                                                       (parent.instFM[n][ope * 11 + 3] & 0xf) << 4) //SL
                                                                   | (parent.instFM[n][ope * 11 + 4] & 0xf)         // RR
                                                                   ));
            }
            parent.OutData(pw.port0, (byte)(0x2), (byte)((
                                                             (parent.instFM[n][0 * 11 + 5] & 0x3) << 6) //KL(M)
                                                         | (parent.instFM[n][23] & 0x3f)                //TL
                                                         ));
            parent.OutData(pw.port0, (byte)(0x3), (byte)((
                                                             (parent.instFM[n][1 * 11 + 5] & 0x3) << 6)    //KL(C)
                                                         | (parent.instFM[n][0 * 11 + 11] != 0 ? 0x08 : 0) // DT(M)
                                                         | (parent.instFM[n][1 * 11 + 11] != 0 ? 0x10 : 0) // DT(C)
                                                         | (parent.instFM[n][24] & 0x07)                   //FB
                                                         ));

            pw.op1ml  = parent.instFM[n][0 * 11 + 5];
            pw.op2ml  = parent.instFM[n][1 * 11 + 5];
            pw.op1dt2 = 0;
            pw.op2dt2 = 0;
        }
Exemplo n.º 6
0
        public void OutSetInstrument(partWork pw, int n, int vol, int modeBeforeSend)
        {
            if (!parent.instFM.ContainsKey(n))
            {
                msgBox.setWrnMsg(string.Format(msg.get("E16001"), n));//, mml.line.Lp);
                return;
            }

            switch (modeBeforeSend)
            {
            case 0:     // N)one
                break;

            case 1:     // R)R only
                for (int ope = 0; ope < 4; ope++)
                {
                    OutSetSlRr(pw, ope, 0, 15);
                }
                break;

            case 2:     // A)ll
                for (int ope = 0; ope < 4; ope++)
                {
                    OutSetDtMl(pw, ope, 0, 0);
                    OutSetKsAr(pw, ope, 3, 31);
                    OutSetAmDr(pw, ope, 1, 31);
                    OutSetDt2Sr(pw, ope, 0, 31);
                    OutSetSlRr(pw, ope, 0, 15);
                }
                OutSetPanFeedbackAlgorithm(pw, pw.ipan, 7, 7);
                break;
            }

            int alg = 0;

            int[] op = null;
            switch (parent.instFM[n].type)
            {
            case 0:    // @
                for (int ope = 0; ope < 4; ope++)
                {
                    ((ClsOPN)pw.chip).OutFmSetSlRr(pw, ope, 0, 15);
                }

                for (int ope = 0; ope < 4; ope++)
                {
                    OutSetDtMl(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 8 + 2], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 7 + 2]);
                    OutSetKsAr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 6 + 2], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 0 + 2]);
                    OutSetAmDr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 9 + 2], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 1 + 2]);
                    OutSetDt2Sr(pw, ope, 0, parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 2 + 2]);
                    OutSetSlRr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_OPERATOR_SIZE + 4 + 2], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 3 + 2]);
                }

                pw.op1ml  = parent.instFM[n].data[0 * Const.INSTRUMENT_OPERATOR_SIZE + 7 + 2];
                pw.op2ml  = parent.instFM[n].data[1 * Const.INSTRUMENT_OPERATOR_SIZE + 7 + 2];
                pw.op3ml  = parent.instFM[n].data[2 * Const.INSTRUMENT_OPERATOR_SIZE + 7 + 2];
                pw.op4ml  = parent.instFM[n].data[3 * Const.INSTRUMENT_OPERATOR_SIZE + 7 + 2];
                pw.op1dt2 = 0;
                pw.op2dt2 = 0;
                pw.op3dt2 = 0;
                pw.op4dt2 = 0;

                ((ClsOPN)pw.chip).OutFmSetFeedbackAlgorithm(pw, parent.instFM[n].data[0], parent.instFM[n].data[1]);
                break;

            case 1:     // @%
                int  vch  = pw.ch;
                byte port = pw.port0;

                for (int ope = 0; ope < 4; ope++)
                {
                    OutSetSlRr(pw, ope, 0, 15);
                }

                for (int ope = 0; ope < 4; ope++)
                {
                    int ops = ope;
                    if (ope == 1)
                    {
                        ops = 2;
                    }
                    else if (ope == 2)
                    {
                        ops = 1;
                    }
                    OutSetDtMl(pw, ope, (parent.instFM[n].data[ops] & 0x70) >> 4, parent.instFM[n].data[ops] & 0x0f);
                    OutSetKsAr(pw, ope, (parent.instFM[n].data[ops + 8] & 0xc0) >> 6, parent.instFM[n].data[ops + 8] & 0x1f);
                    OutSetAmDr(pw, ope, 1, parent.instFM[n].data[ops + 12] & 0x1f);
                    OutSetDt2Sr(pw, ope, 0, parent.instFM[n].data[ops + 16] & 0x1f);
                    OutSetSlRr(pw, ope, (parent.instFM[n].data[ops + 20] & 0xf0) >> 4, parent.instFM[n].data[ops + 20] & 0x0f);
                }

                OutSetPanFeedbackAlgorithm(pw, pw.ipan, (parent.instFM[n].data[24] & 0x38) >> 3, parent.instFM[n].data[24] & 0x7);

                alg = parent.instFM[n].data[24] & 0x7;
                op  = new int[4] {
                    parent.instFM[n].data[4]
                    , parent.instFM[n].data[6]
                    , parent.instFM[n].data[5]
                    , parent.instFM[n].data[7]
                };
                break;

            case 2:     //@N
                for (int ope = 0; ope < 4; ope++)
                {
                    ((ClsOPN)pw.chip).OutFmSetSlRr(pw, ope, 0, 15);
                }

                for (int ope = 0; ope < 4; ope++)
                {
                    ((ClsOPN)pw.chip).OutFmSetDtMl(pw, ope, parent.instFM[n].data[ope * 11 + 8 + 2], parent.instFM[n].data[ope * 11 + 7 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetKsAr(pw, ope, parent.instFM[n].data[ope * 11 + 6 + 2], parent.instFM[n].data[ope * 11 + 0 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetAmDr(pw, ope, parent.instFM[n].data[ope * 11 + 9 + 2], parent.instFM[n].data[ope * 11 + 1 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetSr(pw, ope, parent.instFM[n].data[ope * 11 + 2 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetSlRr(pw, ope, parent.instFM[n].data[ope * 11 + 4 + 2], parent.instFM[n].data[ope * 11 + 3 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetSSGEG(pw, ope, parent.instFM[n].data[ope * 11 + 10 + 2]);
                    ((ClsOPN)pw.chip).OutFmSetTl(pw, ope, parent.instFM[n].data[ope * 11 + 5 + 2]);
                }

                pw.op1ml  = parent.instFM[n].data[0 * 11 + 7];
                pw.op2ml  = parent.instFM[n].data[1 * 11 + 7];
                pw.op3ml  = parent.instFM[n].data[2 * 11 + 7];
                pw.op4ml  = parent.instFM[n].data[3 * 11 + 7];
                pw.op1dt2 = 0;
                pw.op2dt2 = 0;
                pw.op3dt2 = 0;
                pw.op4dt2 = 0;

                ((ClsOPN)pw.chip).OutFmSetFeedbackAlgorithm(pw, parent.instFM[n].data[0], parent.instFM[n].data[1]);
                break;

            case 3:    //@L OPL
                msgBox.setErrMsg(msg.get("E11001"), pw.getSrcFn(), pw.getLineNumber());
                return;

            case 4:    //@M OPM
                for (int ope = 0; ope < 4; ope++)
                {
                    OutSetDtMl(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 8 + 3], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 7 + 3]);
                    OutSetKsAr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 6 + 3], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 0 + 3]);
                    OutSetAmDr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 10 + 3], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 1 + 3]);
                    OutSetDt2Sr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 9 + 3], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 2 + 3]);
                    OutSetSlRr(pw, ope, parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 4 + 3], parent.instFM[n].data[ope * Const.INSTRUMENT_M_OPERATOR_SIZE + 3 + 3]);
                }
                pw.op1ml  = parent.instFM[n].data[0 * Const.INSTRUMENT_M_OPERATOR_SIZE + 7 + 3];
                pw.op2ml  = parent.instFM[n].data[1 * Const.INSTRUMENT_M_OPERATOR_SIZE + 7 + 3];
                pw.op3ml  = parent.instFM[n].data[2 * Const.INSTRUMENT_M_OPERATOR_SIZE + 7 + 3];
                pw.op4ml  = parent.instFM[n].data[3 * Const.INSTRUMENT_M_OPERATOR_SIZE + 7 + 3];
                pw.op1dt2 = parent.instFM[n].data[0 * Const.INSTRUMENT_M_OPERATOR_SIZE + 9 + 3];
                pw.op2dt2 = parent.instFM[n].data[1 * Const.INSTRUMENT_M_OPERATOR_SIZE + 9 + 3];
                pw.op3dt2 = parent.instFM[n].data[2 * Const.INSTRUMENT_M_OPERATOR_SIZE + 9 + 3];
                pw.op4dt2 = parent.instFM[n].data[3 * Const.INSTRUMENT_M_OPERATOR_SIZE + 9 + 3];

                OutSetPanFeedbackAlgorithm(pw, pw.ipan, parent.instFM[n].data[2], parent.instFM[n].data[1]);

                alg = parent.instFM[n].data[1] & 0x7;
                op  = new int[4] {
                    parent.instFM[n].data[0 * Const.INSTRUMENT_M_OPERATOR_SIZE + 5 + 3]
                    , parent.instFM[n].data[1 * Const.INSTRUMENT_M_OPERATOR_SIZE + 5 + 3]
                    , parent.instFM[n].data[2 * Const.INSTRUMENT_M_OPERATOR_SIZE + 5 + 3]
                    , parent.instFM[n].data[3 * Const.INSTRUMENT_M_OPERATOR_SIZE + 5 + 3]
                };
                break;
            }

            int[][] algs = new int[8][]
            {
                new int[4] {
                    1, 1, 1, 0
                }
                , new int[4] {
                    1, 1, 1, 0
                }
                , new int[4] {
                    1, 1, 1, 0
                }
                , new int[4] {
                    1, 1, 1, 0
                }
                , new int[4] {
                    1, 0, 1, 0
                }
                , new int[4] {
                    1, 0, 0, 0
                }
                , new int[4] {
                    1, 0, 0, 0
                }
                , new int[4] {
                    0, 0, 0, 0
                }
            };

            for (int i = 0; i < 4; i++)
            {
                if (algs[alg][i] == 0 || (pw.slots & (1 << i)) == 0)
                {
                    op[i] = -1;
                    continue;
                }
                if (op[i] < 0)
                {
                    op[i] = 0;
                }
                if (op[i] > 127)
                {
                    op[i] = 127;
                }
            }

            if ((pw.slots & 1) != 0 && op[0] != -1)
            {
                OutSetTl(pw, 0, op[0]);
            }
            if ((pw.slots & 2) != 0 && op[1] != -1)
            {
                OutSetTl(pw, 1, op[1]);
            }
            if ((pw.slots & 4) != 0 && op[2] != -1)
            {
                OutSetTl(pw, 2, op[2]);
            }
            if ((pw.slots & 8) != 0 && op[3] != -1)
            {
                OutSetTl(pw, 3, op[3]);
            }

            ((YM2151)pw.chip).OutSetVolume(pw, vol, n);
        }
Exemplo n.º 7
0
        public void OutSetVolume(partWork pw, int vol, int n)
        {
            if (!parent.instFM.ContainsKey(n))
            {
                msgBox.setWrnMsg(string.Format(msg.get("E16000"), n));//, mml.line.Lp);
                return;
            }

            int alg = 0;

            int[] ope = null;
            switch (parent.instFM[n].type)
            {
            case 0:    // @
                alg = parent.instFM[n].data[1] & 0x7;
                ope = new int[4] {
                    parent.instFM[n].data[0 * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]
                    , parent.instFM[n].data[1 * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]
                    , parent.instFM[n].data[2 * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]
                    , parent.instFM[n].data[3 * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]
                };
                break;

            case 1:    // @%
                alg = parent.instFM[n].data[24] & 0x7;
                ope = new int[4] {
                    parent.instFM[n].data[4]
                    , parent.instFM[n].data[6]
                    , parent.instFM[n].data[5]
                    , parent.instFM[n].data[7]
                };
                break;

            case 2:    // @N
                alg = parent.instFM[n].data[1] & 0x7;
                ope = new int[4] {
                    parent.instFM[n].data[0 * 11 + 5 + 2]
                    , parent.instFM[n].data[1 * 11 + 5 + 2]
                    , parent.instFM[n].data[2 * 11 + 5 + 2]
                    , parent.instFM[n].data[3 * 11 + 5 + 2]
                };
                break;

            case 3:    // @L OPL
                msgBox.setErrMsg(string.Format(msg.get("E11000"), n), pw.getSrcFn(), pw.getLineNumber());
                return;

            case 4:    // @M OPM
                alg = parent.instFM[n].data[1] & 0x7;
                ope = new int[4] {
                    parent.instFM[n].data[0 * Const.INSTRUMENT_M_OPERATOR_SIZE + 5 + 3]
                    , parent.instFM[n].data[1 * Const.INSTRUMENT_M_OPERATOR_SIZE + 5 + 3]
                    , parent.instFM[n].data[2 * Const.INSTRUMENT_M_OPERATOR_SIZE + 5 + 3]
                    , parent.instFM[n].data[3 * Const.INSTRUMENT_M_OPERATOR_SIZE + 5 + 3]
                };
                break;
            }
            int[][] algs = new int[8][]
            {
                new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 1, 0, 1
                }
                , new int[4] {
                    0, 1, 1, 1
                }
                , new int[4] {
                    0, 1, 1, 1
                }
                , new int[4] {
                    1, 1, 1, 1
                }
            };

            //int minV = 127;
            //for (int i = 0; i < 4; i++)
            //{
            //    if (algs[alg][i] == 1 && (pw.ppg[pw.cpgNum].slots & (1 << i)) != 0)
            //    {
            //        minV = Math.Min(minV, ope[i]);
            //    }
            //}

            for (int i = 0; i < 4; i++)
            {
                if (algs[alg][i] == 0 || (pw.slots & (1 << i)) == 0)
                {
                    ope[i] = -1;
                    continue;
                }
                //ope[i] = ope[i] - minV + (127 - vol);
                ope[i] = ope[i] + vol;
                if (ope[i] < 0)
                {
                    ope[i] = 0;
                }
                if (ope[i] > 127)
                {
                    ope[i] = 127;
                }
            }

            if ((pw.slots & 1) != 0 && ope[0] != -1)
            {
                OutSetTl(pw, 0, ope[0]);
            }
            if ((pw.slots & 2) != 0 && ope[1] != -1)
            {
                OutSetTl(pw, 1, ope[1]);
            }
            if ((pw.slots & 4) != 0 && ope[2] != -1)
            {
                OutSetTl(pw, 2, ope[2]);
            }
            if ((pw.slots & 8) != 0 && ope[3] != -1)
            {
                OutSetTl(pw, 3, ope[3]);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// FMボリュームの設定
        /// </summary>
        /// <param name="ch">チャンネル</param>
        /// <param name="vol">ボリューム値</param>
        /// <param name="n">音色番号</param>
        public void OutFmSetVolume(partWork pw, int vol, int n)
        {
            if (!parent.instFM.ContainsKey(n))
            {
                msgBox.setWrnMsg(string.Format(msg.get("E11000"), n), pw.getSrcFn(), pw.getLineNumber());
                return;
            }

            int alg;

            int[] ope;
            if (parent.instFM[n].type == 0)
            {
                alg = parent.instFM[n].data[1] & 0x7;
                ope = new int[4] {
                    parent.instFM[n].data[0 * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]
                    , parent.instFM[n].data[1 * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]
                    , parent.instFM[n].data[2 * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]
                    , parent.instFM[n].data[3 * Const.INSTRUMENT_OPERATOR_SIZE + 5 + 2]
                };
            }
            else
            {
                alg = parent.instFM[n].data[24] & 0x7;
                ope = new int[4] {
                    parent.instFM[n].data[4]
                    , parent.instFM[n].data[6]
                    , parent.instFM[n].data[5]
                    , parent.instFM[n].data[7]
                };
            }
            int[][] algs = new int[8][]
            {
                new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 1, 0, 1
                }
                , new int[4] {
                    0, 1, 1, 1
                }
                , new int[4] {
                    0, 1, 1, 1
                }
                , new int[4] {
                    1, 1, 1, 1
                }
            };

            for (int i = 0; i < 4; i++)
            {
                if (algs[alg][i] == 0 || (pw.slots & (1 << i)) == 0)
                {
                    ope[i] = -1;
                    continue;
                }
                //ope[i] = ope[i] + (127 - vol);
                ope[i] = vol;
                ope[i] = Common.CheckRange(ope[i], 0, 127);
            }

            partWork vpw = pw;
            int      m   = 3;

            if (pw.chip.lstPartWork[2].Ch3SpecialMode && pw.ch >= m + 3 && pw.ch < m + 6)
            {
                vpw = pw.chip.lstPartWork[2];
            }

            if ((pw.slots & 1) != 0 && ope[0] != -1)
            {
                ((ClsOPN)pw.chip).OutFmSetTl(vpw, 0, ope[0]);
            }
            if ((pw.slots & 2) != 0 && ope[1] != -1)
            {
                ((ClsOPN)pw.chip).OutFmSetTl(vpw, 1, ope[1]);
            }
            if ((pw.slots & 4) != 0 && ope[2] != -1)
            {
                ((ClsOPN)pw.chip).OutFmSetTl(vpw, 2, ope[2]);
            }
            if ((pw.slots & 8) != 0 && ope[3] != -1)
            {
                ((ClsOPN)pw.chip).OutFmSetTl(vpw, 3, ope[3]);
            }
        }
Exemplo n.º 9
0
        public override void CmdExtendChannel(partWork pw, MML mml)
        {
            string cmd = (string)mml.args[0];

            switch (cmd)
            {
            case "EX":
                int  n   = (int)mml.args[1];
                byte res = 0;
                while (n % 10 != 0)
                {
                    if (n % 10 > 0 && n % 10 < 5)
                    {
                        res += (byte)(1 << (n % 10 - 1));
                    }
                    else
                    {
                        msgBox.setErrMsg(string.Format(msg.get("E11005"), n), pw.getSrcFn(), pw.getLineNumber());
                        break;
                    }
                    n /= 10;
                }
                if (res != 0)
                {
                    pw.slotsEX = res;
                    if (pw.Ch3SpecialMode)
                    {
                        pw.slots = pw.slotsEX;
                    }
                }
                break;

            case "EXON":
                pw.Ch3SpecialMode = true;
                ((ClsOPN)pw.chip).OutOPNSetCh3SpecialMode(pw, true);
                foreach (partWork p in pw.chip.lstPartWork)
                {
                    if (p.Type == enmChannelType.FMOPNex)
                    {
                        p.slots        = p.slotsEX;
                        p.beforeVolume = -1;
                        p.beforeFNum   = -1;
                        p.freq         = -1;
                        //SetFmFNum(p);
                    }
                }
                break;

            case "EXOF":
                pw.Ch3SpecialMode = false;
                ((ClsOPN)pw.chip).OutOPNSetCh3SpecialMode(pw, false);
                foreach (partWork p in pw.chip.lstPartWork)
                {
                    if (p.Type == enmChannelType.FMOPNex)
                    {
                        if (p.ch != 2)
                        {
                            p.slots = 0;
                        }
                        else
                        {
                            p.slots = p.slots4OP;
                        }
                        p.beforeVolume = -1;
                        p.beforeFNum   = -1;
                        p.freq         = -1;
                        //SetFmFNum(p);
                    }
                }
                break;

            case "EXD":
                pw.slotDetune[0] = (int)mml.args[1];
                pw.slotDetune[1] = (int)mml.args[2];
                pw.slotDetune[2] = (int)mml.args[3];
                pw.slotDetune[3] = (int)mml.args[4];
                break;
            }
        }
Exemplo n.º 10
0
        public override void CmdInstrument(partWork pw, MML mml)
        {
            char type = (char)mml.args[0];
            int  n    = 0;

            if (mml.args[1].GetType() == typeof(int))
            {
                n = (int)mml.args[1];
            }
            else
            {
                //文字指定
                n = -1;
                foreach (int instNo in parent.instFM.Keys)
                {
                    if (parent.instFM[instNo].Name.Trim() != ((string)mml.args[1]).Trim())
                    {
                        continue;
                    }
                    n = instNo;
                    break;
                }
                if (n == -1)
                {
                    msgBox.setErrMsg(string.Format(msg.get("E11001"), "\"" + ((string)mml.args[1]).Trim() + "\""), pw.getSrcFn(), pw.getLineNumber());
                    return;
                }
            }

            if (type == 'N')
            {
                if (pw.Type == enmChannelType.FMPCM || pw.Type == enmChannelType.FMPCMex)
                {
                    if (pw.isPcmMap)
                    {
                        pw.pcmMapNo = n;
                        if (!parent.instPCMMap.ContainsKey(n))
                        {
                            msgBox.setErrMsg(string.Format(msg.get("E10024"), n));
                        }
                        return;
                    }

                    pw.instrument = n;
                    if (!parent.instPCM.ContainsKey(n))
                    {
                        msgBox.setErrMsg(string.Format(msg.get("E20002"), n), pw.getSrcFn(), pw.getLineNumber());
                    }
                    else
                    {
                        if ((parent.instPCM[n].chip != enmChipType.YM2612) && (parent.instPCM[n].chip != enmChipType.YM2612X))
                        {
                            msgBox.setErrMsg(string.Format(msg.get("E20003"), n), pw.getSrcFn(), pw.getLineNumber());
                        }
                    }
                    return;
                }
            }

            base.CmdInstrument(pw, mml);
        }
Exemplo n.º 11
0
        public void OutSetVolume(partWork pw, int vol, int n)
        {
            if (!parent.instFM.ContainsKey(n))
            {
                msgBox.setWrnMsg(string.Format("未定義の音色(@{0})を指定している場合ボリュームの変更はできません。", n), pw.getSrcFn(), pw.getLineNumber());
                return;
            }

            int alg = parent.instFM[n][45] & 0x7;

            int[] ope = new int[4] {
                parent.instFM[n][0 * Const.INSTRUMENT_M_OPERATOR_SIZE + 6]
                , parent.instFM[n][1 * Const.INSTRUMENT_M_OPERATOR_SIZE + 6]
                , parent.instFM[n][2 * Const.INSTRUMENT_M_OPERATOR_SIZE + 6]
                , parent.instFM[n][3 * Const.INSTRUMENT_M_OPERATOR_SIZE + 6]
            };
            int[][] algs = new int[8][]
            {
                new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 0, 0, 1
                }
                , new int[4] {
                    0, 1, 0, 1
                }
                , new int[4] {
                    0, 1, 1, 1
                }
                , new int[4] {
                    0, 1, 1, 1
                }
                , new int[4] {
                    1, 1, 1, 1
                }
            };

            //int minV = 127;
            //for (int i = 0; i < 4; i++)
            //{
            //    if (algs[alg][i] == 1 && (pw.slots & (1 << i)) != 0)
            //    {
            //        minV = Math.Min(minV, ope[i]);
            //    }
            //}

            for (int i = 0; i < 4; i++)
            {
                if (algs[alg][i] == 0 || (pw.slots & (1 << i)) == 0)
                {
                    continue;
                }
                //ope[i] = ope[i] - minV + (127 - vol);
                ope[i] = ope[i] + (127 - vol);
                if (ope[i] < 0)
                {
                    ope[i] = 0;
                }
                if (ope[i] > 127)
                {
                    ope[i] = 127;
                }
            }

            if ((pw.slots & 1) != 0)
            {
                OutSetTl(pw, 0, ope[0]);
            }
            if ((pw.slots & 2) != 0)
            {
                OutSetTl(pw, 1, ope[1]);
            }
            if ((pw.slots & 4) != 0)
            {
                OutSetTl(pw, 2, ope[2]);
            }
            if ((pw.slots & 8) != 0)
            {
                OutSetTl(pw, 3, ope[3]);
            }
        }