Ejemplo n.º 1
0
        public MmlDatum[] compileFromSrcText(string srcText, string wrkMMLFullPath, string srcFileFullPath, Point point, bool doTrace)
        {
            if (!ok)
            {
                return(null);
            }

            MoonDriverManager.wrkMMLFullPath = wrkMMLFullPath;
            compiler.Init();
            if (doTrace)
            {
                compiler.SetCompileSwitch("IDE");
            }

            if (point != Point.Empty)
            {
                compiler.SetCompileSwitch(string.Format("SkipPoint=R{0}:C{1}", point.Y, point.X));
            }

            MmlDatum[] ret;
            musicDriverInterface.Log.writeMethod = disp;
            musicDriverInterface.Log.off         = 0;

            if (!setting.other.LogWarning)
            {
                musicDriverInterface.Log.off = (int)musicDriverInterface.LogLevel.WARNING;
            }
            if (setting.other.LogLevel == (int)LogLevel.INFO)
            {
                musicDriverInterface.Log.level = LogLevel.INFO;
            }
            else if (setting.other.LogLevel == (int)LogLevel.DEBUG)
            {
                musicDriverInterface.Log.level = LogLevel.DEBUG;
            }
            else if (setting.other.LogLevel == (int)LogLevel.TRACE)
            {
                musicDriverInterface.Log.level = LogLevel.TRACE;
            }

            musicDriverInterface.Log.level = LogLevel.INFO;

            compiler.SetCompileSwitch(string.Format("ORIGPATH={0}", wrkMMLFullPath));
            compiler.SetCompileSwitch(
                "MoonDriverOption=-i"
                , string.Format("MoonDriverOption={0}", srcFileFullPath)
                );

            byte[] src = Encoding.GetEncoding(932).GetBytes(srcText);
            using (MemoryStream sourceMML = new MemoryStream(src))
                ret = compiler.Compile(sourceMML, appendFileReaderCallback); // wrkMUCFullPath, disp);

            currentGD3Tag = compiler.GetGD3TagInfo(src);
            //foreach(MmlDatum d in ret)
            //{
            //    if(d.type == enmMMLType.Note)
            //    {
            //        Console.WriteLine("{0} {1}", d.linePos.row, d.linePos.col);
            //        ;
            //    }
            //}
            return(ret);
        }
Ejemplo n.º 2
0
        public GD3Tag GetGD3TagInfo(byte[] srcBuf)
        {
            uint tagdata = Cmn.getLE32(srcBuf, 0x000c);
            uint tagsize = Cmn.getLE32(srcBuf, 0x0010);

            if (srcBuf[0] == 'm' && srcBuf[1] == 'u' && srcBuf[2] == 'P' && srcBuf[3] == 'b')
            {
                tagdata = Cmn.getLE32(srcBuf, 0x0012);
                tagsize = Cmn.getLE32(srcBuf, 0x0016);
            }

            if (tagdata == 0)
            {
                return(null);
            }
            if (srcBuf == null)
            {
                return(null);
            }

            List <byte> lb = new List <byte>();

            for (int i = 0; i < tagsize; i++)
            {
                lb.Add(srcBuf[tagdata + i]);
            }

            List <Tuple <string, string> > tags = GetTagsByteArray(lb.ToArray());
            GD3Tag gt = new GD3Tag();

            foreach (Tuple <string, string> tag in tags)
            {
                switch (tag.Item1)
                {
                case "title":
                    addItemAry(gt, enmTag.Title, tag.Item2);
                    addItemAry(gt, enmTag.TitleJ, tag.Item2);
                    break;

                case "composer":
                    addItemAry(gt, enmTag.Composer, tag.Item2);
                    addItemAry(gt, enmTag.ComposerJ, tag.Item2);
                    break;

                case "author":
                    addItemAry(gt, enmTag.Artist, tag.Item2);
                    addItemAry(gt, enmTag.ArtistJ, tag.Item2);
                    break;

                case "comment":
                    addItemAry(gt, enmTag.Note, tag.Item2);
                    break;

                case "mucom88":
                    addItemAry(gt, enmTag.RequestDriverVersion, tag.Item2);
                    break;

                case "date":
                    addItemAry(gt, enmTag.ReleaseDate, tag.Item2);
                    break;

                case "driver":
                    addItemAry(gt, enmTag.DriverName, tag.Item2);
                    break;
                }
            }

            return(gt);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// GD3タグを取得(一般的な曲情報)
        /// </summary>
        public GD3Tag GetGD3TagInfo(byte[] srcBuf)
        {
            List <MmlDatum> sc = new List <MmlDatum>();

            foreach (byte b in srcBuf)
            {
                sc.Add(new MmlDatum(b));
            }
            Driver.srcBuf = sc.ToArray();
            List <Tuple <string, string> > lstTag = GetTags();
            GD3Tag gd3tag = new GD3Tag();

            gd3tag.dicItem.Clear();
            foreach (Tuple <string, string> ttag in lstTag)
            {
                if (ttag.Item1 == "title")
                {
                    if (gd3tag.dicItem.ContainsKey(enmTag.Title))
                    {
                        gd3tag.dicItem.Remove(enmTag.Title);
                    }
                    gd3tag.dicItem.Add(enmTag.Title, new string[] { ttag.Item2 });
                    if (gd3tag.dicItem.ContainsKey(enmTag.TitleJ))
                    {
                        gd3tag.dicItem.Remove(enmTag.TitleJ);
                    }
                    gd3tag.dicItem.Add(enmTag.TitleJ, new string[] { ttag.Item2 });
                }
                else if (ttag.Item1 == "composer")
                {
                    if (gd3tag.dicItem.ContainsKey(enmTag.Composer))
                    {
                        gd3tag.dicItem.Remove(enmTag.Composer);
                    }
                    gd3tag.dicItem.Add(enmTag.Composer, new string[] { ttag.Item2 });
                    if (gd3tag.dicItem.ContainsKey(enmTag.ComposerJ))
                    {
                        gd3tag.dicItem.Remove(enmTag.ComposerJ);
                    }
                    gd3tag.dicItem.Add(enmTag.ComposerJ, new string[] { ttag.Item2 });
                }
                else if (ttag.Item1 == "arranger")
                {
                    if (gd3tag.dicItem.ContainsKey(enmTag.Arranger))
                    {
                        gd3tag.dicItem.Remove(enmTag.Arranger);
                    }
                    gd3tag.dicItem.Add(enmTag.Arranger, new string[] { ttag.Item2 });
                    if (gd3tag.dicItem.ContainsKey(enmTag.ArrangerJ))
                    {
                        gd3tag.dicItem.Remove(enmTag.ArrangerJ);
                    }
                    gd3tag.dicItem.Add(enmTag.ArrangerJ, new string[] { ttag.Item2 });
                }
                else if (ttag.Item1 == "memo")
                {
                    if (gd3tag.dicItem.ContainsKey(enmTag.Memo))
                    {
                        gd3tag.dicItem.Remove(enmTag.Memo);
                    }
                    gd3tag.dicItem.Add(enmTag.Memo, new string[] { ttag.Item2 });
                }
            }
            return(gd3tag);
        }