Exemple #1
0
        public int Count  = 0; //1行に定義されているパートの総数

        public Line(LinePos lp, string txt)
        {
            Lp    = lp;
            Txt   = txt;
            Index = 0;
            Count = 0;
        }
Exemple #2
0
 public outDatum(enmMMLType type, List <object> args, LinePos linePos, byte val)
 {
     this.type    = type;
     this.args    = args;
     this.linePos = linePos;
     this.val     = val;
 }
Exemple #3
0
        public Line Copy()
        {
            LinePos lp = new LinePos(this.Lp.fullPath, this.Lp.row, this.Lp.col, this.Lp.length, this.Lp.part, this.Lp.chip, this.Lp.chipIndex, this.Lp.chipNumber, this.Lp.ch);
            Line    l  = new Line(lp, this.Txt);

            return(l);
        }
Exemple #4
0
        public Line Copy()
        {
            LinePos lp = new LinePos(this.Lp.document, this.Lp.srcMMLID, this.Lp.row, this.Lp.col, this.Lp.length, this.Lp.part, this.Lp.chip, this.Lp.chipIndex, this.Lp.chipNumber, this.Lp.ch);
            Line    l  = new Line(lp, this.Txt);

            l.Index = this.Index;
            l.Count = this.Count;
            return(l);
        }
Exemple #5
0
 public static void setWrnMsg(string msg, LinePos lp)
 {
     if (lp != null)
     {
         wrnBox.Add(new msgInfo(lp.srcMMLID, lp.row, lp.col, lp.length, msg));
     }
     else
     {
         wrnBox.Add(new msgInfo("-", -1, -1, -1, msg));
     }
 }
Exemple #6
0
 public static void setErrMsg(string msg, LinePos lp)
 {
     //errBox.Add(string.Format("(F : {0}  L : {1}) : {2}", System.IO.Path.GetFileName(fn), lineNumber, msg));
     if (lp != null)
     {
         errBox.Add(new msgInfo(lp.srcMMLID, lp.row, lp.col, lp.length, msg));
     }
     else
     {
         errBox.Add(new msgInfo("-", -1, -1, -1, msg));
     }
 }
Exemple #7
0
        private LinePos[] CopyAndToArrayStackAliesPos(Stack <LinePos> stackAliesPos)
        {
            List <LinePos> ret = new List <LinePos>();

            LinePos[] saps = stackAliesPos.ToArray();
            foreach (LinePos sap in saps)
            {
                LinePos ap = LinePos.Copy(sap);
                ret.Add(ap);
            }

            return(ret.ToArray());
        }
Exemple #8
0
        private void OutQSoundKeyOn(partPage page, MML mml)
        {
            byte   adr  = 0;
            ushort data = 0;

            if (page.instrument == -1)
            {
                LinePos lp = mml?.line?.Lp;
                if (lp == null)
                {
                    lp = new LinePos(null, "-");
                }
                msgBox.setErrMsg(msg.get("E22005"), lp);
                return;
            }

            //Volume
            SetVolume(page, mml);

            //Address shift
            int stAdr = page.pcmStartAddress + page.addressShift;

            if (stAdr >= page.pcmEndAddress)
            {
                stAdr = page.pcmEndAddress - 1;
            }

            //if (pw.ppg[pw.cpgNum].beforepcmStartAddress != stAdr)
            {
                //StartAdr
                adr  = (byte)((page.ch << 3) + 0x01);
                data = (ushort)stAdr;
                OutQSoundPort(mml, port[0], page
                              , adr
                              , (ushort)data
                              );

                page.beforepcmStartAddress = stAdr;
            }

            if (page.beforepcmEndAddress != page.pcmEndAddress)
            {
                //EndAdr
                adr  = (byte)((page.ch << 3) + 0x05);
                data = (ushort)page.pcmEndAddress;
                OutQSoundPort(mml, port[0], page
                              , adr
                              , (ushort)data
                              );

                page.beforepcmEndAddress = page.pcmEndAddress;
            }

            if (page.beforepcmLoopAddress != (page.pcmEndAddress - page.pcmLoopAddress) && page.beforepcmLoopAddress != 4)
            {
                //LoopAdr
                adr  = (byte)((page.ch << 3) + 0x04);
                data = (ushort)(page.pcmLoopAddress == -1
                    ? 4 //QSoundはループがデフォ。(thanks Ian(@SuperCTR)さん)
                    : (page.pcmEndAddress - page.pcmLoopAddress)
                                );
                OutQSoundPort(mml, port[0], page
                              , adr
                              , (ushort)data
                              );

                page.beforepcmLoopAddress = data;
            }

            if (page.beforepcmBank != page.pcmBank)
            {
                int bch = (page.ch - 1) & 0xf;
                adr  = (byte)((bch << 3) + 0x00);
                data = (ushort)(page.pcmBank);
                OutQSoundPort(mml, port[0], page
                              , adr
                              , (ushort)(data | 0x8000)
                              );

                page.beforepcmBank = page.pcmBank;
            }

            adr  = (byte)((page.ch << 3) + 0x03);
            data = (ushort)0x8000;

            if (parent.instPCM[page.instrument].Item2.status != enmPCMSTATUS.ERROR)
            {
                parent.instPCM[page.instrument].Item2.status = enmPCMSTATUS.USED;
            }

            OutQSoundPort(mml, port[0], page
                          , adr
                          , (ushort)data
                          );
        }
Exemple #9
0
        private void OutK053260KeyOn(partPage page, MML mml)
        {
            byte adr  = 0;
            byte data = 0;

            if (page.instrument == -1)
            {
                LinePos lp = mml?.line?.Lp;
                if (lp == null)
                {
                    lp = new LinePos(null, "-");
                }
                msgBox.setErrMsg(msg.get("E23005"), lp);
                return;
            }

            //Volume
            SetVolume(page, mml);

            //Address shift
            int stAdr = page.pcmStartAddress + page.addressShift;

            if (stAdr >= page.pcmEndAddress)
            {
                stAdr = page.pcmEndAddress - 1;
            }

            if (page.spg.beforepcmStartAddress != stAdr)
            {
                //StartAdr L
                adr  = (byte)((page.ch + 1) * 8 + 0x04);
                data = (byte)stAdr;
                OutK053260Port(mml, port[0], page
                               , adr
                               , data
                               );
                //StartAdr H
                adr  = (byte)((page.ch + 1) * 8 + 0x05);
                data = (byte)(stAdr >> 8);
                OutK053260Port(mml, port[0], page
                               , adr
                               , data
                               );

                page.spg.beforepcmStartAddress = stAdr;
            }

            //K053260は終了アドレスではなくサイズを指定する
            //また、K053260はバンクをまたぐ演奏が可能(但しサイズは65534まで)
            //TODO:よって現在、パディングを行っているが不要かもしれない。
            int size = page.pcmEndAddress - page.pcmStartAddress + 1;

            if (page.spg.beforepcmEndAddress != size)
            {
                //EndAdr L
                adr  = (byte)((page.ch + 1) * 8 + 0x02);
                data = (byte)size;
                OutK053260Port(mml, port[0], page
                               , adr
                               , data
                               );
                //EndAdr H
                adr  = (byte)((page.ch + 1) * 8 + 0x03);
                data = (byte)(size >> 8);
                OutK053260Port(mml, port[0], page
                               , adr
                               , data
                               );

                page.spg.beforepcmEndAddress = size;
            }


            //K053260のループはFlagです。trueのとき、StartAddressに戻ります
            //また、他のチャンネルと合わせて設定する必要があります。


            if (page.spg.beforepcmBank != page.pcmBank)
            {
                adr  = (byte)((page.ch + 1) * 8 + 0x06);
                data = (byte)(page.pcmBank);
                OutK053260Port(mml, port[0], page
                               , adr
                               , data
                               );

                page.spg.beforepcmBank = page.pcmBank;
            }

            if (parent.instPCM[page.instrument].Item2.status != enmPCMSTATUS.ERROR)
            {
                parent.instPCM[page.instrument].Item2.status = enmPCMSTATUS.USED;
            }
        }
Exemple #10
0
        //private List<clsPos> LstPos = null;

        //public int pcmMapNo { get; set; } = 0;
        //public int dutyCycle { get; set; } = 0;
        //public int oldDutyCycle { get; set; } = -1;
        //public int oldFreq { get; set; } = -1;

        //public bool directModeVib { get; set; }
        //public bool directModeTre { get; set; }
        //public int pitchBend { get; set; } = 0;
        //public int tieBend { get; set; } = 0;
        //public int portaBend { get; set; } = 0;
        //public int lfoBend { get; set; } = 0;
        //public int bendStartOctave { get; set; } = 0;
        //public char bendStartNote { get; set; } = 'c';
        //public int bendStartShift { get; set; } = 0;
        //public int velocity { get; set; } = 110;
        //public int effectDistortionSwitch { get; internal set; } = 0;
        //public int effectDistortionVolume { get; internal set; } = 32;
        //public bool isOp4Mode { get; internal set; } = false;
        //public int beforeBendNoteNum { get; internal set; } = -1;
        //public int panRL { get; internal set; }
        //public int panRR { get; internal set; }
        //public int flag { get; internal set; }
        //public bool changeFlag { get; internal set; }
        //public int C352flag { get; internal set; }

        public void MakeLstPos(partPage page)
        {
            if (page.pData == null)
            {
                return;
            }

            int    tCol      = 0;
            int    row       = 0;
            int    col       = 0;
            int    pCol      = 0;
            string aliesName = "";

            //int aliesDepth = 0;

            page.LstPos = new List <clsPos>();
            page.LstPos.Add(new clsPos());
            page.stackAliesPos = new Stack <LinePos>();
            resetPos(page);

            while (true)
            {
                string data;
                char   ch;

                //読みだすデータの頭出し
                if (aliesName == "")
                {
                    if (page.pData.Count == row)
                    {
                        return;
                    }
                    data = page.pData[row].Txt;
                    pCol = page.pData[row].Lp.col;
                }
                else
                {
                    data = aData[aliesName].Txt;
                    pCol = aData[aliesName].Lp.col;
                }

                data = Common.CutComment(data);

                //解析行の解析位置が終端に達したときの処理
                while (data.Length == col + pCol)
                {
                    if (aliesName == "")
                    {
                        row++;
                        if (page.pData.Count == row)
                        {
                            break;
                        }
                        else
                        {
                            data = page.pData[row].Txt;
                            data = Common.CutComment(data);
                            pCol = page.pData[row].Lp.col;
                            col  = 0;// pData[row].Lp.col;

                            clsPos p = new clsPos();
                            p.tCol  = tCol;
                            p.alies = null;
                            p.col   = 0;
                            p.row   = row;
                            page.LstPos.Add(p);

                            break;
                        }
                    }
                    else
                    {
                        clsPos p = page.stackPos.Pop();
                        aliesName = p.alies[0].aliesName;
                        page.stackAliesPos.Pop();
                        col = p.col;
                        row = p.row;
                        if (aliesName == "")
                        {
                            data = page.pData[row].Txt;
                            pCol = page.pData[row].Lp.col;
                        }
                        else
                        {
                            data = aData[aliesName].Txt;
                            pCol = aData[aliesName].Lp.col;
                        }

                        data   = Common.CutComment(data);
                        p.tCol = tCol;
                        page.LstPos.Add(p);
                    }
                }

                ch = data[col + pCol];

                //解析位置でエイリアス指定されている場合
                while (ch == '%')
                {
                    string a = getAliesName(data, col + pCol);
                    if (a != "")
                    {
                        LinePos ali = new LinePos();
                        ali.aliesName     = aliesName; //現在のエイリアス名
                        ali.aliesNextName = a;         //飛び先となるエイリアス名
                        ali.aliesDepth    = page.stackAliesPos.Count + 1;
                        //ali.nextDepth = page.stackAliesPos.Count + 1;
                        ali.row    = page.pData[row].Lp.row;
                        ali.col    = col + pCol;
                        ali.length = a.Length + 1;

                        //マクロから復帰する際に使用する場所情報を作成
                        clsPos p = new clsPos();
                        p.col   = col + a.Length + 1;
                        p.row   = row;
                        p.alies = CopyAndToArrayStackAliesPos(page.stackAliesPos); //現時点のスタックの内容に戻す

                        page.stackPos.Push(p);
                        page.stackAliesPos.Push(ali);

                        data      = aData[a].Txt;
                        data      = Common.CutComment(data);
                        pCol      = aData[a].Lp.col;
                        col       = 0;
                        aliesName = a;
                        row       = 0;

                        p       = new clsPos();
                        p.tCol  = tCol;
                        p.alies = CopyAndToArrayStackAliesPos(page.stackAliesPos);
                        p.col   = 0;
                        p.row   = 0;
                        page.LstPos.Add(p);
                    }
                    else
                    {
                        msgBox.setWrnMsg(msg.get("E06000")
                                         , (aliesName == "") ? page.pData[row].Lp : aData[aliesName].Lp
                                         );
                        col++;
                    }

                    ch = data[col + pCol];
                }

                tCol++;
                col++;
                //解析行の解析位置が終端に達したときの処理
                while (data.Length == col + pCol)// || data[col + pCol] == ';')
                {
                    if (aliesName == "")
                    {
                        row++;
                        if (page.pData.Count == row)
                        {
                            break;
                        }
                        else
                        {
                            data = page.pData[row].Txt;
                            data = Common.CutComment(data);
                            pCol = page.pData[row].Lp.col;
                            col  = 0;

                            clsPos p = new clsPos();
                            p.tCol  = tCol;
                            p.alies = null;
                            p.col   = 0;
                            p.row   = row;
                            page.LstPos.Add(p);

                            break;
                        }
                    }
                    else
                    {
                        clsPos p = page.stackPos.Pop();
                        aliesName = p.alies.Length < 1 ? "" : p.alies[0].aliesNextName;
                        page.stackAliesPos.Pop();
                        col = p.col;
                        row = p.row;
                        if (aliesName == "")
                        {
                            data = page.pData[row].Txt;
                            data = Common.CutComment(data);
                            pCol = page.pData[row].Lp.col;
                        }
                        else
                        {
                            data = aData[aliesName].Txt;
                            data = Common.CutComment(data);
                            pCol = aData[aliesName].Lp.col;
                        }

                        p.tCol = tCol;
                        page.LstPos.Add(p);
                    }
                }
            }
        }
Exemple #11
0
        private void OutQSoundKeyOn(partWork pw, MML mml)
        {
            byte   adr  = 0;
            ushort data = 0;

            if (pw.instrument == -1)
            {
                LinePos lp = mml?.line?.Lp;
                if (lp == null)
                {
                    lp = new LinePos("-");
                }
                msgBox.setErrMsg(msg.get("E22005"), lp);
                return;
            }

            //Volume
            SetVolume(pw, mml);

            //Address shift
            int stAdr = pw.pcmStartAddress + pw.addressShift;

            if (stAdr >= pw.pcmEndAddress)
            {
                stAdr = pw.pcmEndAddress - 1;
            }

            //if (pw.beforepcmStartAddress != stAdr)
            {
                //StartAdr
                adr  = (byte)((pw.ch << 3) + 0x01);
                data = (ushort)stAdr;
                OutQSoundPort(mml, port[0], pw
                              , adr
                              , (ushort)data
                              );

                pw.beforepcmStartAddress = stAdr;
            }

            if (pw.beforepcmEndAddress != pw.pcmEndAddress)
            {
                //EndAdr
                adr  = (byte)((pw.ch << 3) + 0x05);
                data = (ushort)pw.pcmEndAddress;
                OutQSoundPort(mml, port[0], pw
                              , adr
                              , (ushort)data
                              );

                pw.beforepcmEndAddress = pw.pcmEndAddress;
            }

            if (pw.beforepcmLoopAddress != pw.pcmLoopAddress)
            {
                //LoopAdr
                adr  = (byte)((pw.ch << 3) + 0x04);
                data = (ushort)(pw.pcmLoopAddress == -1 ? 0 : (pw.pcmEndAddress - pw.pcmLoopAddress));
                OutQSoundPort(mml, port[0], pw
                              , adr
                              , (ushort)data
                              );

                pw.beforepcmLoopAddress = pw.pcmLoopAddress;
            }

            if (pw.beforepcmBank != pw.pcmBank)
            {
                int bch = (pw.ch - 1) & 0xf;
                adr  = (byte)((bch << 3) + 0x00);
                data = (ushort)(pw.pcmBank);
                OutQSoundPort(mml, port[0], pw
                              , adr
                              , (ushort)data
                              );

                pw.beforepcmBank = pw.pcmBank;
            }

            adr  = (byte)((pw.ch << 3) + 0x03);
            data = (ushort)0x8000;

            if (parent.instPCM[pw.instrument].status != enmPCMSTATUS.ERROR)
            {
                parent.instPCM[pw.instrument].status = enmPCMSTATUS.USED;
            }

            OutQSoundPort(mml, port[0], pw
                          , adr
                          , (ushort)data
                          );
        }
Exemple #12
0
        public void OutC140KeyOn(partWork pw, MML mml)
        {
            int  adr  = 0;
            byte data = 0;

            if (pw.instrument == -1)
            {
                LinePos lp = mml?.line?.Lp;
                if (lp == null)
                {
                    lp = new LinePos("-");
                }
                msgBox.setErrMsg(msg.get("E10030"), lp);
                return;
            }

            //Volume
            SetVolume(pw, mml);

            //Address shift
            int stAdr = pw.pcmStartAddress + pw.addressShift;

            if (stAdr >= pw.pcmEndAddress)
            {
                stAdr = pw.pcmEndAddress - 1;
            }

            if (pw.beforepcmStartAddress != stAdr)
            {
                //StartAdr H
                adr  = pw.ch * 16 + 0x06;
                data = (byte)((stAdr & 0xff00) >> 8);
                OutC140Port(mml, pw
                            , (byte)(adr >> 8)
                            , (byte)adr
                            , data);

                //StartAdr L
                adr  = pw.ch * 16 + 0x07;
                data = (byte)((stAdr & 0x00ff) >> 0);
                OutC140Port(mml, pw
                            , (byte)(adr >> 8)
                            , (byte)adr
                            , data);

                pw.beforepcmStartAddress = stAdr;
            }

            if (pw.beforepcmEndAddress != pw.pcmEndAddress)
            {
                int eAdr = pw.pcmEndAddress;
                //EndAdr H
                adr  = pw.ch * 16 + 0x08;
                data = (byte)((eAdr & 0xff00) >> 8);
                OutC140Port(mml, pw
                            , (byte)(adr >> 8)
                            , (byte)adr
                            , data);
                //EndAdr L
                adr  = pw.ch * 16 + 0x09;
                data = (byte)((eAdr & 0x00ff) >> 0);
                OutC140Port(mml, pw
                            , (byte)(adr >> 8)
                            , (byte)adr
                            , data);

                pw.beforepcmEndAddress = pw.pcmEndAddress;
            }

            if (pw.beforepcmLoopAddress != pw.pcmLoopAddress)
            {
                if (pw.pcmLoopAddress != -1)
                {
                    //LoopAdr H
                    adr  = pw.ch * 16 + 0x0a;
                    data = (byte)((pw.pcmLoopAddress & 0xff00) >> 8);
                    OutC140Port(mml, pw
                                , (byte)(adr >> 8)
                                , (byte)adr
                                , data);

                    //LoopAdr L
                    adr  = pw.ch * 16 + 0x0b;
                    data = (byte)((pw.pcmLoopAddress & 0x00ff) >> 0);
                    OutC140Port(mml, pw
                                , (byte)(adr >> 8)
                                , (byte)adr
                                , data);

                    pw.beforepcmLoopAddress = pw.pcmLoopAddress;
                }
            }

            if (pw.beforepcmBank != pw.pcmBank)
            {
                adr  = pw.ch * 16 + 0x04;
                data = (byte)((pw.pcmBank & 7) | (isSystem2 ? ((pw.pcmBank & 0x8) << 2) : ((pw.pcmBank & 0x18) << 1)));
                OutC140Port(mml, pw
                            , (byte)(adr >> 8)
                            , (byte)adr
                            , data);

                pw.beforepcmBank = pw.pcmBank;
            }

            adr = pw.ch * 16 + 0x05;

            bool is16bit = false;

            if (pw.instrument >= 0 && parent.instPCM.ContainsKey(pw.instrument))
            {
                is16bit = (bool)parent.instPCM[pw.instrument].is16bit;
            }

            if (parent.instPCM[pw.instrument].status != enmPCMSTATUS.ERROR)
            {
                parent.instPCM[pw.instrument].status = enmPCMSTATUS.USED;
            }

            data = (byte)(
                0x80                                        //KeyOn
                | (is16bit ? 0x08 : 0x00)                   //CompPCM
                | ((pw.pcmLoopAddress != -1) ? 0x10 : 0x00) //Loop
                );
            OutC140Port(mml, pw
                        , (byte)(adr >> 8)
                        , (byte)adr
                        , data);
        }
Exemple #13
0
 public Line(LinePos lp, string txt)
 {
     Lp  = lp;
     Txt = txt;
 }