/// <summary> /// Event handler for the SoundScanner.FoundSoundBankFile event. /// </summary> private void FoundSoundBankFile(object sender, SoundFileEventArgs <SoundBankFile> e) { //if (e.SourceEvent.ID != snd.SoundAddress1 && e.SourceEvent.ID != snd.SoundAddress2) return; // Find the sound bank's pack file so we can determine the offset of the audio data uint bankId = e.File.ParentBank.ID; SoundPackInfo packInfo = null; SoundPackFile packFile = null; foreach (SoundPackInfo pack in cache.SoundPacks) { packFile = pack.Pack.FindFileByID(bankId); if (packFile != null) { packInfo = pack; break; } } if (packFile == null) { return; } // Calculate the offset of the audio data and add it int offset = packFile.Offset + e.File.ParentBank.DataOffset + e.File.Offset; AddSound(packInfo.Reader, offset, e.File.Size, e.File.ID, e.SourceEvent.ID); }
private static void LoadCacheSoundPacks(CacheH4R Cache) { if (Cache.SoundPacks == null) { Cache.SoundPacks = new List <Composer.SoundPackInfo>(); var bank = new SoundPackInfo(); bank.Name = "SoundBank"; bank.Reader = new EndianReader(File.OpenRead(Cache.FilePath + @"\soundbank.pck"), EndianFormat.BigEndian); bank.Pack = new SoundPack(bank.Reader); Cache.SoundPacks.Add(bank); var stream = new SoundPackInfo(); stream.Name = "SoundStream"; stream.Reader = new EndianReader(File.OpenRead(Cache.FilePath + @"\soundstream.pck"), EndianFormat.BigEndian); stream.Pack = new SoundPack(stream.Reader); Cache.SoundPacks.Add(stream); } }