示例#1
0
文件: sid.cs 项目: hiroshica/MDPlayer
        public override GD3 getGD3Info(byte[] buf, uint vgmGd3)
        {
            if (buf == null)
            {
                return(null);
            }

            if (
                common.getLE32(buf, 0) != FCC_PSID &&
                common.getLE32(buf, 0) != FCC_RSID
                )
            {
                return(null);
            }

            songs = (int)common.getBE16(buf, 0x0e);

            GD3 gd3 = new GD3();

            gd3.TrackName = Encoding.ASCII.GetString(buf, 0x16, 32).Trim();
            gd3.TrackName = gd3.TrackName.Substring(0, gd3.TrackName.IndexOf((char)0));
            gd3.Composer  = Encoding.ASCII.GetString(buf, 0x36, 32).Trim();
            gd3.Composer  = gd3.Composer.Substring(0, gd3.Composer.IndexOf((char)0));
            gd3.Notes     = Encoding.ASCII.GetString(buf, 0x56, 32).Trim();
            gd3.Notes     = gd3.Notes.Substring(0, gd3.Notes.IndexOf((char)0));

            return(gd3);
        }
示例#2
0
        /// <summary>
        /// 曲情報取得
        /// </summary>
        /// <param name="buf"></param>
        /// <param name="vgmGd3"></param>
        /// <returns></returns>
        public override GD3 getGD3Info(byte[] buf, uint vgmGd3)
        {
            if (CheckFileType(buf) != enmMUCOMFileType.MUC)
            {
                throw new NotImplementedException();
            }

            tags = GetTagsFromMUC(buf);
            GD3 gd3 = new GD3();

            foreach (Tuple <string, string> tag in tags)
            {
                switch (tag.Item1)
                {
                case "title":
                    gd3.TrackName  = tag.Item2;
                    gd3.TrackNameJ = tag.Item2;
                    break;

                case "composer":
                    gd3.Composer  = tag.Item2;
                    gd3.ComposerJ = tag.Item2;
                    break;

                case "author":
                    gd3.VGMBy = tag.Item2;
                    break;

                case "comment":
                    //gd3.Notes = tag.Item2;
                    break;

                case "mucom88":
                    gd3.Version = tag.Item2;
                    gd3.Notes   = tag.Item2;
                    break;

                case "date":
                    gd3.Converted = tag.Item2;
                    break;

                case "voice":
                    fnVoicedat = tag.Item2;
                    break;

                case "pcm":
                    fnPcm = tag.Item2;
                    break;
                }
            }

            return(gd3);
        }
示例#3
0
文件: xgm.cs 项目: kuma4649/mml2vgm
        private GD3 getGD3Info(outDatum[] vgmBuf)
        {
            if (!existGD3)
            {
                return(new GD3());
            }

            GD3 GD3 = Common.getGD3Info(vgmBuf, gd3InfoStartAddr + 12);

            GD3.UsedChips = UsedChips;

            return(GD3);
        }
示例#4
0
        public void update()
        {
            lblTitle.Text     = "";
            lblTitleJ.Text    = "";
            lblGame.Text      = "";
            lblGameJ.Text     = "";
            lblSystem.Text    = "";
            lblSystemJ.Text   = "";
            lblComposer.Text  = "";
            lblComposerJ.Text = "";
            lblRelease.Text   = "";
            lblVGMBy.Text     = "";
            lblNotes.Text     = "";
            lblVersion.Text   = "";
            lblUsedChips.Text = "";
            rtbLyrics.Clear();

            GD3 gd3 = Audio.GetGD3();

            if (gd3 == null)
            {
                return;
            }

            lblTitle.Text     = gd3.TrackName;
            lblTitleJ.Text    = gd3.TrackNameJ;
            lblGame.Text      = gd3.GameName;
            lblGameJ.Text     = gd3.GameNameJ;
            lblSystem.Text    = gd3.SystemName;
            lblSystemJ.Text   = gd3.SystemNameJ;
            lblComposer.Text  = gd3.Composer;
            lblComposerJ.Text = gd3.ComposerJ;
            lblRelease.Text   = gd3.Converted;
            lblVGMBy.Text     = gd3.VGMBy;
            lblNotes.Text     = gd3.Notes;
            lblVersion.Text   = gd3.Version;
            lblUsedChips.Text = gd3.UsedChips;

            if (gd3.Lyrics == null)
            {
                timer.Enabled = false;
            }
            else
            {
                lyrics        = gd3.Lyrics;
                timer.Enabled = true;
            }
        }
示例#5
0
        public void update()
        {
            rtbLyrics.Clear();
            GD3 gd3 = Audio.GetGD3();

            if (gd3 == null)
            {
                return;
            }

            if (gd3.Lyrics == null)
            {
                timer.Enabled = false;
            }
            else
            {
                lyrics      = gd3.Lyrics;
                lyricsIndex = 0;
                skip        = Audio.sm.GetDriverSeqCounterDelay();
                skip       += Audio.getLatency();

                timer.Enabled = true;
            }
        }
示例#6
0
文件: MID.cs 项目: hiroshica/MDPlayer
        public override GD3 getGD3Info(byte[] buf, uint vgmGd3)
        {
            if (buf == null) return null;

            GD3 gd3 = new GD3();
            string T01TrackName = "";


            try
            {
                if (common.getLE32(buf, 0) != FCC_MID) return null;
                uint format = (uint)(buf[8]*0x100+buf[9]);
                uint trkCount = (uint)(buf[10] * 0x100 + buf[11]);
                uint adr = 14;
                byte midiEventBackup = 0;

                for (int i = 0; i < trkCount; i++)
                {
                    if (buf.Length <= adr) break;

                    if (common.getLE32(buf, adr) != FCC_TRK) return null;
                    uint len = (uint)(buf[adr + 4] * 0x1000000 + buf[adr + 5] * 0x10000 + buf[adr + 6] * 0x100 + buf[adr + 7]);
                    adr += 8;
                    uint trkEndadr = adr + len;

                    while (adr < trkEndadr && adr < buf.Length)
                    {
                        int delta = common.getDelta(ref adr, buf);
                        byte cmd = buf[adr++];
                        if (cmd == 0xf0 || cmd == 0xf7)
                        {
                            uint bAdr = adr - 1;
                            int datalen = common.getDelta(ref adr, buf);
                            adr = adr + (uint)datalen;
                        }
                        else if (cmd == 0xff)
                        {
                            byte eventType = buf[adr++];
                            uint eventLen = (uint)common.getDelta(ref adr, buf);
                            List<byte> eventData = new List<byte>();
                            for (int j = 0; j < eventLen; j++)
                            {
                                if (buf[adr + j] == 0) break;
                                eventData.Add(buf[adr + j]);
                            }
                            adr = adr + eventLen;
                            if (eventData.Count > 0)
                            {
                                switch (eventType)
                                {
                                    case 0x01:
                                        //case 0x02:
                                        if (T01TrackName == "")
                                        {
                                            T01TrackName = Encoding.GetEncoding(932).GetString(eventData.ToArray()).Trim();
                                        }
                                        break;
                                    case 0x03:
                                        if (gd3.TrackName == "")
                                        {
                                            if (format == 0 || (format == 1 && i == 0))
                                            {
                                                gd3.TrackName = Encoding.GetEncoding(932).GetString(eventData.ToArray()).Trim();
                                                gd3.TrackNameJ = Encoding.GetEncoding(932).GetString(eventData.ToArray()).Trim();
                                            }
                                        }
                                        break;
                                    case 0x05:
                                        //case 0x04:
                                        //case 0x06:
                                        //case 0x07:
                                        break;
                                }
                            }
                        }
                        else
                        {
                            if ((cmd & 0x80) != 0)
                            {
                                midiEventBackup = (byte)(cmd & 0xff);
                                midiEvent = midiEventBackup;

                                if ((cmd & 0xf0) != 0xC0 && (cmd & 0xf0) != 0xD0)
                                {
                                    adr += 2;
                                }
                                else
                                {
                                    adr++;
                                }
                            }
                            else
                            {
                                //ランニングステータス発動
                                midiEvent = midiEventBackup;
                                midiEventCh = midiEventChBackup;

                                if ((cmd & 0xf0) != 0xC0 && (cmd & 0xf0) != 0xD0)
                                {
                                    adr++;
                                }
                            }
                        }

                    }

                }

                //タイトルが見つからなかった場合
                if (gd3.TrackName == "" && gd3.TrackNameJ == "" && T01TrackName != "")
                {
                    gd3.TrackName = T01TrackName;
                    gd3.TrackNameJ = T01TrackName;
                }
            }
            catch
            {
            }

            return gd3;
        }
示例#7
0
        public static GD3 getGD3Info(outDatum[] buf, uint adr)
        {
            GD3 GD3 = new GD3();

            GD3.TrackName   = "";
            GD3.TrackNameJ  = "";
            GD3.GameName    = "";
            GD3.GameNameJ   = "";
            GD3.SystemName  = "";
            GD3.SystemNameJ = "";
            GD3.Composer    = "";
            GD3.ComposerJ   = "";
            GD3.Converted   = "";
            GD3.Notes       = "";
            GD3.VGMBy       = "";
            GD3.Version     = "";
            GD3.UsedChips   = "";

            try
            {
                //trackName
                GD3.TrackName = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //trackNameJ
                GD3.TrackNameJ = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //gameName
                GD3.GameName = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //gameNameJ
                GD3.GameNameJ = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //systemName
                GD3.SystemName = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //systemNameJ
                GD3.SystemNameJ = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //Composer
                GD3.Composer = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //ComposerJ
                GD3.ComposerJ = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //Converted
                GD3.Converted = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //VGMBy
                GD3.VGMBy = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //Notes
                GD3.Notes = Encoding.Unicode.GetString(Common.getByteArray(buf, ref adr));
                //Lyric(独自拡張)
                byte[] bLyric = Common.getByteArray(buf, ref adr);
                if (bLyric != null)
                {
                    GD3.Lyrics = new List <Tuple <int, int, string> >();
                    int i  = 0;
                    int st = 0;
                    while (i < bLyric.Length)
                    {
                        byte h = bLyric[i];
                        byte l = bLyric[i + 1];
                        if ((h == 0x5b && l == 0x00 && i != 0) || i >= bLyric.Length - 2)
                        {
                            if ((i >= bLyric.Length - 2) || (bLyric[i + 2] != 0x5b || bLyric[i + 3] != 0x00))
                            {
                                string m = Encoding.Unicode.GetString(bLyric, st, i - st + ((i >= bLyric.Length - 2) ? 2 : 0));
                                st = i;

                                int cnt = int.Parse(m.Substring(1, m.IndexOf("]") - 1));
                                m = m.Substring(m.IndexOf("]") + 1);
                                GD3.Lyrics.Add(new Tuple <int, int, string>(cnt, cnt, m));
                            }
                        }
                        i += 2;
                    }
                }
                else
                {
                    GD3.Lyrics = null;
                }
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
            }

            return(GD3);
        }
示例#8
0
文件: nsf.cs 项目: hiroshica/MDPlayer
        public override GD3 getGD3Info(byte[] buf, uint vgmGd3)
        {
            if (common.getLE32(buf, 0) != FCC_NSF)
            {
                //NSFeはとりあえず未サポート
                return(null);
            }

            if (buf.Length < 0x80) // no header?
            {
                return(null);
            }

            version      = buf[0x05];
            songs        = buf[0x06];
            start        = buf[0x07];
            load_address = (UInt16)(buf[0x08] | (buf[0x09] << 8));
            init_address = (UInt16)(buf[0x0a] | (buf[0x0B] << 8));
            play_address = (UInt16)(buf[0x0c] | (buf[0x0D] << 8));

            //memcpy(title_nsf, image + 0x0e, 32);
            //title_nsf[31] = '\0';
            List <byte> strLst = new List <byte>();
            Int32       TAGAdr = 0x0e;

            for (int i = 0; i < 32; i++)
            {
                if (buf[TAGAdr] == 0)
                {
                    break;
                }
                strLst.Add(buf[TAGAdr++]);
            }
            title_nsf = Encoding.GetEncoding(932).GetString(strLst.ToArray());
            title     = title_nsf;

            //memcpy(artist_nsf, image + 0x2e, 32);
            //artist_nsf[31] = '\0';
            strLst.Clear();
            TAGAdr = 0x2e;
            for (int i = 0; i < 32; i++)
            {
                if (buf[TAGAdr] == 0)
                {
                    break;
                }
                strLst.Add(buf[TAGAdr++]);
            }
            artist_nsf = Encoding.GetEncoding(932).GetString(strLst.ToArray());
            artist     = artist_nsf;

            //memcpy(copyright_nsf, image + 0x4e, 32);
            //copyright_nsf[31] = '\0';
            strLst.Clear();
            TAGAdr = 0x4e;
            for (int i = 0; i < 32; i++)
            {
                if (buf[TAGAdr] == 0)
                {
                    break;
                }
                strLst.Add(buf[TAGAdr++]);
            }
            copyright_nsf = Encoding.GetEncoding(932).GetString(strLst.ToArray());
            copyright     = copyright_nsf;

            ripper     = ""; // NSFe only
            text       = ""; // NSFe only
            text_len   = 0;  // NSFe only
            speed_ntsc = (UInt16)(buf[0x6e] | (buf[0x6f] << 8));
            //memcpy(bankswitch, image + 0x70, 8);
            for (int i = 0; i < 8; i++)
            {
                bankswitch[i] = buf[0x70 + i];
            }
            speed_pal = (UInt16)(buf[0x78] | (buf[0x79] << 8));
            pal_ntsc  = buf[0x7a];

            if (speed_pal == 0)
            {
                speed_pal = 0x4e20;
            }
            if (speed_ntsc == 0)
            {
                speed_ntsc = 0x411A;
            }

            soundchip = buf[0x7b];

            use_vrc6 = (soundchip & 1) != 0;
            use_vrc7 = (soundchip & 2) != 0;
            use_fds  = (soundchip & 4) != 0;
            use_mmc5 = (soundchip & 8) != 0;
            use_n106 = (soundchip & 16) != 0;
            use_fme7 = (soundchip & 32) != 0;

            //memcpy(extra, image + 0x7c, 4);
            for (int i = 0; i < 4; i++)
            {
                extra[i] = buf[0x7c + i];
            }

            //delete[] body;
            //body = new UINT8[size - 0x80];
            //memcpy(body, image + 0x80, size - 0x80);
            body = new byte[buf.Length - 0x80];
            for (int i = 0; i < buf.Length - 0x80; i++)
            {
                body[i] = buf[0x80 + i];
            }

            bodysize = buf.Length - 0x80;

            //song = start - 1;

            GD3 gd3 = new GD3();

            gd3.GameName    = title;
            gd3.GameNameJ   = title;
            gd3.Composer    = artist;
            gd3.ComposerJ   = artist;
            gd3.TrackName   = title;
            gd3.TrackNameJ  = title;
            gd3.SystemName  = copyright;
            gd3.SystemNameJ = copyright;

            return(gd3);
        }
示例#9
0
文件: S98.cs 项目: tenchoTCS/MDPlayer
        public override GD3 getGD3Info(byte[] buf, uint vgmGd3)
        {
            if (buf == null)
            {
                return(null);
            }

            GD3 gd3 = new GD3();

            s98Info = new S98Info();
            chips   = new List <string>();

            try
            {
                if (Common.getLE24(buf, 0) != FCC_S98)
                {
                    return(null);
                }
                int  Format = (int)(buf[3] - '0');
                uint TAGAdr = Common.getLE32(buf, 0x10);
                if (Format < 2)
                {
                    List <byte> strLst = new List <byte>();
                    string      str;
                    while (buf[TAGAdr] != 0x0a && buf[TAGAdr] != 0x00)
                    {
                        strLst.Add(buf[TAGAdr++]);
                    }
                    str            = Encoding.GetEncoding(932).GetString(strLst.ToArray());
                    gd3.TrackName  = str;
                    gd3.TrackNameJ = str;
                }
                else if (Format == 3)
                {
                    if (buf[TAGAdr++] != 0x5b)
                    {
                        return(null);
                    }
                    if (buf[TAGAdr++] != 0x53)
                    {
                        return(null);
                    }
                    if (buf[TAGAdr++] != 0x39)
                    {
                        return(null);
                    }
                    if (buf[TAGAdr++] != 0x38)
                    {
                        return(null);
                    }
                    if (buf[TAGAdr++] != 0x5d)
                    {
                        return(null);
                    }
                    bool IsUTF8 = false;
                    if (Common.getLE24(buf, TAGAdr) == FCC_BOM)
                    {
                        IsUTF8  = true;
                        TAGAdr += 3;
                    }

                    while (buf.Length > TAGAdr && buf[TAGAdr] != 0x00)
                    {
                        List <byte> strLst = new List <byte>();
                        string      str;
                        while (buf[TAGAdr] != 0x0a && buf[TAGAdr] != 0x00)
                        {
                            strLst.Add(buf[TAGAdr++]);
                        }
                        if (IsUTF8)
                        {
                            str = Encoding.UTF8.GetString(strLst.ToArray());
                        }
                        else
                        {
                            str = Encoding.GetEncoding(932).GetString(strLst.ToArray());
                        }
                        TAGAdr++;

                        if (str.ToLower().IndexOf("artist=") != -1)
                        {
                            try
                            {
                                gd3.Composer  = str.Substring(str.IndexOf("=") + 1);
                                gd3.ComposerJ = str.Substring(str.IndexOf("=") + 1);
                            }
                            catch
                            { }
                        }
                        if (str.ToLower().IndexOf("s98by=") != -1)
                        {
                            try
                            {
                                gd3.VGMBy = str.Substring(str.IndexOf("=") + 1);
                            }
                            catch
                            { }
                        }
                        if (str.ToLower().IndexOf("game=") != -1)
                        {
                            try
                            {
                                gd3.GameName  = str.Substring(str.IndexOf("=") + 1);
                                gd3.GameNameJ = str.Substring(str.IndexOf("=") + 1);
                            }
                            catch
                            { }
                        }
                        SSGVolumeFromTAG = -1;
                        if (str.ToLower().IndexOf("system=") != -1)
                        {
                            try
                            {
                                gd3.SystemName  = str.Substring(str.IndexOf("=") + 1);
                                gd3.SystemNameJ = str.Substring(str.IndexOf("=") + 1);

                                if (gd3.SystemName.IndexOf("8801") > 0)
                                {
                                    SSGVolumeFromTAG = 63;
                                }
                                else if (gd3.SystemName.IndexOf("9801") > 0)
                                {
                                    SSGVolumeFromTAG = 31;
                                }
                            }
                            catch
                            { }
                        }
                        if (str.ToLower().IndexOf("title=") != -1)
                        {
                            try
                            {
                                gd3.TrackName  = str.Substring(str.IndexOf("=") + 1);
                                gd3.TrackNameJ = str.Substring(str.IndexOf("=") + 1);
                            }
                            catch
                            { }
                        }
                        if (str.ToLower().IndexOf("year=") != -1)
                        {
                            try
                            {
                                gd3.Converted = str.Substring(str.IndexOf("=") + 1);
                            }
                            catch
                            { }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                log.Write(string.Format("S98のTAG情報取得中に例外発生 Message=[{0}] StackTrace=[{1}]", e.Message, e.StackTrace));
                return(null);
            }

            return(gd3);
        }
示例#10
0
        public void Close()
        {
            if (dest == null)
            {
                return;
            }


            //ヘッダ、フッタの調整

            //end of data
            dest.WriteByte(0x66);

            //Total # samples
            dest.Position = 0x18;
            dest.WriteByte((byte)totalSample);
            dest.WriteByte((byte)(totalSample >> 8));
            dest.WriteByte((byte)(totalSample >> 16));
            dest.WriteByte((byte)(totalSample >> 24));

            //tag
            if (tags != null)
            {
                GD3 gd3 = new GD3();
                foreach (Tuple <string, string> tag in tags)
                {
                    switch (tag.Item1)
                    {
                    case "title":
                        gd3.TrackName  = tag.Item2;
                        gd3.TrackNameJ = tag.Item2;
                        break;

                    case "composer":
                        gd3.Composer  = tag.Item2;
                        gd3.ComposerJ = tag.Item2;
                        break;

                    case "author":
                        gd3.VGMBy = tag.Item2;
                        break;

                    case "comment":
                        if (string.IsNullOrEmpty(gd3.Notes))
                        {
                            gd3.Notes = tag.Item2;
                        }
                        else
                        {
                            gd3.Notes += "\r\n" + tag.Item2;
                        }
                        break;

                    case "mucom88":
                        gd3.Version = tag.Item2;
                        gd3.Notes   = tag.Item2;
                        break;

                    case "date":
                        gd3.Converted = tag.Item2;
                        break;
                    }
                }

                byte[] tagary = gd3.make();
                dest.Seek(0, SeekOrigin.End);
                long gd3ofs = dest.Length - 0x14;
                foreach (byte b in tagary)
                {
                    dest.WriteByte(b);
                }

                //Tag offset
                if (tagary != null && tagary.Length > 0)
                {
                    dest.Position = 0x14;
                    dest.WriteByte((byte)gd3ofs);
                    dest.WriteByte((byte)(gd3ofs >> 8));
                    dest.WriteByte((byte)(gd3ofs >> 16));
                    dest.WriteByte((byte)(gd3ofs >> 24));
                }
            }

            //EOF offset
            dest.Position = 0x4;
            dest.WriteByte((byte)(dest.Length - 4));
            dest.WriteByte((byte)((dest.Length - 4) >> 8));
            dest.WriteByte((byte)((dest.Length - 4) >> 16));
            dest.WriteByte((byte)((dest.Length - 4) >> 24));

            //YM2608 offset
            dest.Position = 0x48;
            dest.WriteByte(0);
            dest.WriteByte(0);
            dest.WriteByte(0);
            dest.WriteByte(0);

            //YM2610 offset
            dest.Position = 0x4c;
            dest.WriteByte(0);
            dest.WriteByte(0);
            dest.WriteByte(0);
            dest.WriteByte(0);

            //YM2151 offset
            dest.Position = 0x30;
            dest.WriteByte(0);
            dest.WriteByte(0);
            dest.WriteByte(0);
            dest.WriteByte(0);

            for (int i = 0; i < 5; i++)
            {
                if (useChips[i] == 0 || useChips[i] > 5)
                {
                    continue;
                }
                switch (useChips[i])
                {
                case 1:
                case 2:
                    dest.Position = 0x48;
                    dest.WriteByte((byte)(opnaMasterClock >> 0));
                    dest.WriteByte((byte)(opnaMasterClock >> 8));
                    dest.WriteByte((byte)(opnaMasterClock >> 16));
                    if (useChips[i] == 1)
                    {
                        dest.WriteByte(0);
                    }
                    else
                    {
                        dest.WriteByte(0x40);
                    }
                    break;

                case 3:
                case 4:
                    dest.Position = 0x4c;
                    dest.WriteByte((byte)(opnbMasterClock >> 0));
                    dest.WriteByte((byte)(opnbMasterClock >> 8));
                    dest.WriteByte((byte)(opnbMasterClock >> 16));
                    if (useChips[i] == 3)
                    {
                        dest.WriteByte(0);
                    }
                    else
                    {
                        dest.WriteByte(0x40);
                    }
                    break;

                case 5:
                    dest.Position = 0x30;
                    dest.WriteByte((byte)(opmMasterClock >> 0));
                    dest.WriteByte((byte)(opmMasterClock >> 8));
                    dest.WriteByte((byte)(opmMasterClock >> 16));
                    if (useChips[i] == 5)
                    {
                        dest.WriteByte(0);
                    }
                    else
                    {
                        dest.WriteByte(0x40);
                    }
                    break;
                }
            }

            dest.Close();
            dest = null;
        }