示例#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;
                    }
                }
            }
        }
示例#2
0
        public DATASection(BinaryReader br, uint length, DIDXSection dataIndex) : base("DATA", null)
        {
            long offset = br.BaseStream.Position;

            foreach (DIDXSection.EmbeddedWEM embWEM in dataIndex.embeddedWEMFiles)
            {
                this.wemFiles.Add(new WEMFile(br, offset, embWEM));
            }
            br.BaseStream.Seek(offset + length, SeekOrigin.Begin);
        }
示例#3
0
        //.bnk内のサウンド一覧を取得
        public List <WEMFile> GetAudioFiles()
        {
            List <WEMFile> newList   = new List <WEMFile>();
            DIDXSection    dataIndex = (DIDXSection)this.GetSection("DIDX");
            DATASection    data      = (DATASection)this.GetSection("DATA");
            HIRCSection    hirc      = (HIRCSection)this.GetSection("HIRC");

            if (dataIndex != null && data != null)
            {
                foreach (DATASection.WEMFile wem in data.wemFiles)
                {
                    //一部の破損したbnkファイルを読み込もうとした場合クラッシュするためtry catchを使用(どぉーしてだよ"ぉ~)
                    //RavioliGameToolsで確認したところ、サウンド以外の謎のファイルが入っている場合にエラーが発生する可能性が高い
                    try
                    {
                        newList.Add(new WEMFile(wem.info.ID, 0, GetAudioFileSeconds(ref wem.data)));
                    }
                    catch { }
                }
            }
            WPKSoundBank wpkBank = this.GetWPKBank();

            if (wpkBank != null)
            {
                foreach (WPKSoundBank.WPKSoundBankWEMFile wem in wpkBank.wemFiles)
                {
                    newList.Add(new WEMFile(wem.ID, 0, GetAudioFileSeconds(ref wem.data)));
                }
            }
            //本家WoT内の音声ファイルを選択するとクラッシュしてしまうため廃止

            /*if (hirc != null)
             * {
             *  foreach (WEMFile wem in newList)
             *  {
             *      SoundSFXVoiceWwiseObject foundSfx = (SoundSFXVoiceWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Sound_SFX__Sound_Voice && ((SoundSFXVoiceWwiseObject)x).audioFileID == wem.ID);
             *      if (foundSfx != null)
             *      {
             *          EventActionWwiseObject foundEventAction = (EventActionWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Event_Action && ((EventActionWwiseObject)x).gameObject == foundSfx.ID);
             *          if (foundEventAction != null)
             *          {
             *              EventWwiseObject foundEvent = (EventWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Event && ((EventWwiseObject)x).eventActionList.Contains(foundEventAction.ID));
             *              if (foundEvent != null)
             *              {
             *                  wem.eventID = foundEvent.ID;
             *              }
             *          }
             *      }
             *  }
             * }*/
            return(newList);
        }
示例#4
0
        //.bnk内のサウンド一覧を取得
        public List <WEMFile> GetAudioFiles()
        {
            List <WEMFile> newList   = new List <WEMFile>();
            DIDXSection    dataIndex = (DIDXSection)this.GetSection("DIDX");
            DATASection    data      = (DATASection)this.GetSection("DATA");
            HIRCSection    hirc      = (HIRCSection)this.GetSection("HIRC");

            if (dataIndex != null && data != null)
            {
                foreach (DATASection.WEMFile wem in data.wemFiles)
                {
                    newList.Add(new WEMFile(wem.info.ID, 0, GetAudioFileSeconds(ref wem.data)));
                }
            }
            WPKSoundBank wpkBank = this.GetWPKBank();

            if (wpkBank != null)
            {
                foreach (WPKSoundBank.WPKSoundBankWEMFile wem in wpkBank.wemFiles)
                {
                    newList.Add(new WEMFile(wem.ID, 0, GetAudioFileSeconds(ref wem.data)));
                }
            }
            //本家WoT内の音声ファイルを選択するとクラッシュしてしまうため廃止

            /*if (hirc != null)
             * {
             *  foreach (WEMFile wem in newList)
             *  {
             *      SoundSFXVoiceWwiseObject foundSfx = (SoundSFXVoiceWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Sound_SFX__Sound_Voice && ((SoundSFXVoiceWwiseObject)x).audioFileID == wem.ID);
             *      if (foundSfx != null)
             *      {
             *          EventActionWwiseObject foundEventAction = (EventActionWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Event_Action && ((EventActionWwiseObject)x).gameObject == foundSfx.ID);
             *          if (foundEventAction != null)
             *          {
             *              EventWwiseObject foundEvent = (EventWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Event && ((EventWwiseObject)x).eventActionList.Contains(foundEventAction.ID));
             *              if (foundEvent != null)
             *              {
             *                  wem.eventID = foundEvent.ID;
             *              }
             *          }
             *      }
             *  }
             * }*/
            return(newList);
        }
示例#5
0
        public List <WEMFile> GetAudioFiles()
        {
            List <WEMFile> newList   = new List <WEMFile>();
            DIDXSection    dataIndex = (DIDXSection)this.GetSection("DIDX");
            DATASection    data      = (DATASection)this.GetSection("DATA");
            HIRCSection    hirc      = (HIRCSection)this.GetSection("HIRC");

            // List all audio files
            if (dataIndex != null && data != null)
            {
                foreach (DATASection.WEMFile wem in data.wemFiles)
                {
                    newList.Add(new WEMFile(wem.info.ID, 0, GetAudioFileSeconds(ref wem.data)));
                }
            }
            WPKSoundBank wpkBank = this.GetWPKBank();

            if (wpkBank != null)
            {
                foreach (WPKSoundBank.WPKSoundBankWEMFile wem in wpkBank.wemFiles)
                {
                    newList.Add(new WEMFile(wem.ID, 0, GetAudioFileSeconds(ref wem.data)));
                }
            }
            // Eventually find associated events
            if (hirc != null)
            {
                foreach (WEMFile wem in newList)
                {
                    SoundSFXVoiceWwiseObject foundSfx = (SoundSFXVoiceWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Sound_SFX__Sound_Voice && ((SoundSFXVoiceWwiseObject)x).audioFileID == wem.ID);
                    if (foundSfx != null)
                    {
                        EventActionWwiseObject foundEventAction = (EventActionWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Event_Action && ((EventActionWwiseObject)x).gameObject == foundSfx.ID);
                        if (foundEventAction != null)
                        {
                            EventWwiseObject foundEvent = (EventWwiseObject)hirc.objects.Find(x => x.objectType == WwiseObjectType.Event && ((EventWwiseObject)x).eventActionList.Contains(foundEventAction.ID));
                            if (foundEvent != null)
                            {
                                wem.eventID = foundEvent.ID;
                            }
                        }
                    }
                }
            }
            return(newList);
        }