Esempio n. 1
0
        public override void ExtractAsWav(IApplicationLogger logger, MaterialSection.MaterialEntry entry, byte[] fullFileBytes, string wavPath)
        {
            var rawContentBytes = fullFileBytes.SubArray(entry.InnerStreamStartPosition, entry.InnerStreamSize);

            AudioData    audioData        = null;
            HcaReader    reader           = new HcaReader();
            BinaryReader fullBinaryReader = new BinaryReader(new MemoryStream(fullFileBytes));
            var          encryption       = fullBinaryReader.ReadByteAt(entry.ExtraDataOffset + 0x0d);

            if (encryption == 1)
            {
                DecryptHCA(entry, rawContentBytes, fullBinaryReader);
            }
            audioData = reader.Read(rawContentBytes);
            WaveWriter writer   = new WaveWriter();
            var        wavBytes = writer.GetFile(audioData);

            File.WriteAllBytes(wavPath, wavBytes);
            logger.Log($"Created wav audio track at: {wavPath}");
        }