Exemplo n.º 1
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID (" KPV")
            if (fileReader.Read_32bitsBE(offset) != 0x204B5056)
            {
                return(0);
            }

            uint channel_count = fileReader.Read_32bits(offset + 0x14);
            uint sample_rate   = fileReader.Read_32bits(offset + 0x10);

            if (!VGM_Utils.CheckChannels(channel_count))
            {
                return(0);
            }

            if (!VGM_Utils.CheckSampleRate(sample_rate))
            {
                return(0);
            }

            uint fileLength = fileReader.Read_32bits(offset + 0x04);
            uint interleave = fileReader.Read_32bits(offset + 0x0C) / channel_count;
            int  blockCount = (int)(fileLength / interleave);

            if ((fileLength % interleave) != 0)
            {
                blockCount++;
            }

            fileLength = (uint)(blockCount * interleave * channel_count);

            return(fileLength + fileReader.Read_32bits(offset + 0x08));
        }
Exemplo n.º 2
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID ("AUS ")
            if (fileReader.Read_32bitsBE(offset) != 0x41555320)
            {
                return(0);
            }

            uint channel_count = fileReader.Read_32bits(offset + 0x0C);
            uint sample_rate   = fileReader.Read_32bits(offset + 0x10);

            if (!VGM_Utils.CheckChannels(channel_count))
            {
                return(0);
            }

            if (!VGM_Utils.CheckSampleRate(sample_rate))
            {
                return(0);
            }

            uint fileLength = (fileReader.Read_32bits(offset + 0x08) * 28 / 16) * channel_count;

            return(fileLength + 0x28);
        }
Exemplo n.º 3
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID (" KPV")
            if (fileReader.Read_32bitsBE(offset) != 0x58564147)
            {
                return(0);
            }

            uint channel_count = fileReader.Read_32bitsBE(offset + 0x28);
            uint sample_rate   = fileReader.Read_32bitsBE(offset + 0x3C);

            if (!VGM_Utils.CheckChannels(channel_count))
            {
                return(0);
            }

            if (!VGM_Utils.CheckSampleRate(sample_rate))
            {
                return(0);
            }

            uint fileLength = fileReader.Read_32bitsBE(offset + 0x04) + fileReader.Read_32bitsBE(offset + 0x40);

            return(fileLength);
        }
Exemplo n.º 4
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID ("RIFF")
            if (fileReader.Read_32bitsBE(offset) != 0x52494646)
            {
                return(0);
            }

            // Check for Mark ID ("WAVE" + "fmt ")
            if ((fileReader.Read_32bitsBE(offset + 0x08) == 0x57415645) && (fileReader.Read_32bitsBE(offset + 0x0C) == 0x666D7420))
            {
                if (fileReader.Read_16bits(offset + 0x14) == 0xFFFE)
                {
                    if ((fileReader.Read_32bitsBE(offset + 0x2C) == 0xBFAA23E9) &&
                        (fileReader.Read_32bitsBE(offset + 0x30) == 0x58CB7144) &&
                        (fileReader.Read_32bitsBE(offset + 0x34) == 0xA119FFFA))
                    {
                        if (VGM_Utils.CheckSampleRate(fileReader.Read_16bits(offset + 0x18)))
                        {
                            length = fileReader.Read_32bits(offset + 0x04) + 0x8;
                            return(length);
                        }
                    }
                }
            }
            return(0);
        }
Exemplo n.º 5
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID ("RIFX")
            if (fileReader.Read_32bitsBE(offset) != 0x52494658)
            {
                return(0);
            }

            // Check for Mark ID ("WAVE" + "fmt ")
            if ((fileReader.Read_32bitsBE(offset + 0x08) == 0x57415645) && (fileReader.Read_32bitsBE(offset + 0x0C) == 0x666D7420))
            {
                for (UInt64 i = 0; i < 0x100; i += 4)
                {
                    if ((fileReader.Read_32bitsBE(offset + i) == 0x766F7262) ||
                        (fileReader.Read_32bitsBE(offset + i) == 0x63756520) ||
                        (fileReader.Read_32bitsBE(offset + i) == 0x4A554E4B))
                    {
                        if (VGM_Utils.CheckSampleRate(fileReader.Read_32bitsBE(offset + 0x18)))
                        {
                            length = fileReader.Read_32bitsBE(offset + 0x04) + 0x8;
                            return(length);
                        }
                    }
                }
            }
            return(0);
        }
Exemplo n.º 6
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID ("SShd")
            if (fileReader.Read_32bitsBE(offset) != 0x53536864)
            {
                return(0);
            }

            // Check for Mark ID ("SSbd")
            if (fileReader.Read_32bitsBE(offset + 0x20) != 0x53536264)
            {
                return(0);
            }

            uint channel_count = fileReader.Read_32bits(offset + 0x10);
            uint sample_rate   = fileReader.Read_32bits(offset + 0x0c);

            if (!VGM_Utils.CheckChannels(channel_count))
            {
                return(0);
            }

            if (!VGM_Utils.CheckSampleRate(sample_rate))
            {
                return(0);
            }

            uint fileLength = fileReader.Read_32bits(offset + 0x024);

            return(fileLength + 0x28);
        }
Exemplo n.º 7
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            if (fileReader.Read_32bitsBE(offset + 0) != 0x5253544D) /* "RSTM" */
            {
                return(0);
            }

            if ((fileReader.Read_32bitsBE(offset + 0x04) != 0xFEFF0100) && (fileReader.Read_32bitsBE(offset + 0x04) != 0xFEFF0001))
            {
                return(0);
            }

            /* get head offset, check */
            UInt64 head_offset = fileReader.Read_16bitsBE(offset + 0x0C);

            if (head_offset == 0x10)
            {
                m_Description = "Nintendo RSTM Header v1";
            }
            else
            {
                m_Description = "Nintendo RSTM Header v2";
            }

            UInt64 rl_head_offset = head_offset + offset;

            if (fileReader.Read_32bitsBE(head_offset + offset) != 0x48454144) /* "HEAD" */
            {
                return(0);
            }

            /* check type details */
            byte codec_number  = fileReader.Read_8Bits((head_offset == 0x10) ? rl_head_offset + 0x8 : rl_head_offset + 0x20);
            bool loop_flag     = (fileReader.Read_8Bits((head_offset == 0x10) ? rl_head_offset + 0x19 : rl_head_offset + 0x21) != 0);
            uint channel_count = fileReader.Read_8Bits((head_offset == 0x10) ? rl_head_offset + 0xa : rl_head_offset + 0x22);
            uint sample_rate   = fileReader.Read_16bitsBE((head_offset == 0x10) ? rl_head_offset + 0xc : rl_head_offset + 0x24);

            if (!VGM_Utils.CheckChannels(channel_count))
            {
                return(0);
            }

            if (!VGM_Utils.CheckSampleRate(sample_rate))
            {
                return(0);
            }

            if (codec_number > 2)
            {
                return(0);
            }

            return(fileReader.Read_32bitsBE(offset + 0x08));
        }
Exemplo n.º 8
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID ("Svag")
            if (fileReader.Read_32bitsBE(offset) != 0x53766167)
            {
                return(0);
            }

            // Check for Sample Rate
            if (!VGM_Utils.CheckSampleRate(fileReader.Read_32bits(offset + 0x08)))
            {
                return(0);
            }

            // Check Channels count
            if (!VGM_Utils.CheckChannels(fileReader.Read_32bits(offset + 0x0C)))
            {
                return(0);
            }

            // Values from 0 -> 0x1C are duplicated at offset 0x400
            for (UInt64 i = 0; i < 0x1C / 4; i++)
            {
                if (fileReader.Read_32bits(offset + i) != fileReader.Read_32bits(offset + 0x400 + i))
                {
                    return(0);
                }
            }

            // Try to find file Length
            UInt64 startOffset = 0x800;
            UInt64 fileLength  = fileReader.Read_32bits(offset + 0x04);

            //if (!VGM_Utils.IsPS2ADPCM(fileReader, startOffset + offset, startOffset + offset + fileLength))
            //    return 0;

            if (fileReader.Read_32bits(offset + 0x30) == 0x45434B2E)
            {
                m_Description = "Konami SVAG (KCE-Tokyo)";
            }
            else
            {
                m_Description = "Konami SVAG (KONAMITYO)";
            }

            return(fileLength + startOffset);
        }
Exemplo n.º 9
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID ("NPSF")
            if (fileReader.Read_32bitsBE(offset) != 0x4E505346)
            {
                return(0);
            }

            uint channel_count = fileReader.Read_32bits(offset + 0x0C);
            uint sample_rate   = fileReader.Read_32bits(offset + 0x18);

            if (!VGM_Utils.CheckChannels(channel_count))
            {
                return(0);
            }

            if (!VGM_Utils.CheckSampleRate(sample_rate))
            {
                return(0);
            }

            if (fileReader.Read_32bits(offset + 0x10) != 0x800)
            {
                return(0);
            }

            uint fileLength = fileReader.Read_32bits(offset + 0x08);

            m_Filename = fileReader.Read_String(offset + 0x34, 0x20);

            if (channel_count == 1)
            {
                return(fileLength + 0x800);
            }
            else
            {
                uint blockCount = fileLength / 0x800;
                if ((fileLength % 0x800) != 0)
                {
                    blockCount++;
                }

                fileLength = (blockCount * channel_count * 0x800) + 0x800;
            }
            return(fileLength);
        }
Exemplo n.º 10
0
        public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length)
        {
            // Check for Mark ID ("VAGx") where x can be "p","i","s"
            if ((fileReader.Read_32bitsBE(offset) & 0xFFFFFF00) != 0x56414700)
            {
                return(0);
            }

            uint vagLength = fileReader.Read_32bitsBE(offset + 0x0C) + 0x30;

            if (fileReader.Read_32bitsBE(offset + 0x24) == 0x56414778)
            {
                uint k = 0;
                do
                {
                    k         += 0x10;
                    vagLength += 0x10;
                }while (fileReader.Read_16bitsBE(offset + fileReader.Read_32bitsBE(offset + 0x0C) + k) != 0x0007);
            }

            if ((length != (UInt64)(0xFFFFFFFFF)) && (vagLength != length))
            {
                return(0);
            }

            // Check for Sample Rate
            if (!VGM_Utils.CheckSampleRate(fileReader.Read_32bitsBE(offset + 0x10)))
            {
                return(0);
            }



            if (!VGM_Utils.IsPS2ADPCM(fileReader, offset + 0x30, offset + vagLength))
            {
                return(0);
            }

            // Filename is stored at offset +0x20
            m_Filename = fileReader.Read_String(offset + 0x20, 0x10);
            return(vagLength + 0x30);
        }