Example #1
0
        public void Close(List <Tuple <string, string> > tags)
        {
            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":
                        gd3.Notes = 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));

            dest.Close();
            dest = null;
        }
Example #2
0
        public void Close(List <Tuple <string, string> > tags, uint opnaMasterClock, uint opnbMasterClock, uint opmMasterClock)
        {
            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":
                        gd3.Notes = 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;
        }