Exemplo n.º 1
0
        public void EditAudioFile(uint fileID, byte[] newData)
        {
            DIDXSection dataIndex = (DIDXSection)this.GetSection("DIDX");
            DATASection data      = (DATASection)this.GetSection("DATA");

            if (dataIndex != null && data != null)
            {
                uint lastOffset = 0;
                for (int i = 0; i < dataIndex.embeddedWEMFiles.Count; i++)
                {
                    dataIndex.embeddedWEMFiles[i].offset = lastOffset;
                    if (dataIndex.embeddedWEMFiles[i].ID == fileID)
                    {
                        dataIndex.embeddedWEMFiles[i].length = (uint)newData.Length;
                    }
                    lastOffset += dataIndex.embeddedWEMFiles[i].length + 10;
                }

                for (int i = 0; i < data.wemFiles.Count; i++)
                {
                    if (data.wemFiles[i].info.ID == fileID)
                    {
                        data.wemFiles[i].data = newData;
                    }
                }
                HIRCSection hirc = (HIRCSection)this.GetSection("HIRC");
                if (hirc != null)
                {
                    foreach (WwiseObject obj in hirc.objects)
                    {
                        if (obj.objectType == WwiseObjectType.Sound_SFX__Sound_Voice)
                        {
                            SoundSFXVoiceWwiseObject soundObj    = (SoundSFXVoiceWwiseObject)obj;
                            DIDXSection.EmbeddedWEM  gotEmbedded = dataIndex.GetEmbeddedWEM(soundObj.audioFileID);
                            if (gotEmbedded != null)
                            {
                                soundObj.fileOffset = (uint)data.dataStartOffset + gotEmbedded.offset;
                                soundObj.fileLength = gotEmbedded.length;
                            }
                        }
                    }
                }
            }
            WPKSoundBank wpkBank = this.GetWPKBank();

            if (wpkBank != null)
            {
                foreach (WPKSoundBank.WPKSoundBankWEMFile wemFile in wpkBank.wemFiles)
                {
                    if (wemFile.ID == fileID)
                    {
                        wemFile.data = newData;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public WEMFile(BinaryReader br, long DATASectionOffset, DIDXSection.EmbeddedWEM info)
 {
     this.info = info;
     br.BaseStream.Seek(DATASectionOffset + info.offset, SeekOrigin.Begin);
     this.data = br.ReadBytes((int)info.length);
 }