public void OrganizeFiles(ulong in_uDataOffset, List <OrderedFile> in_listOrderedFiles, Dictionary <string, uint> in_mapLanguages, IProgressNotificationsDispatcher in_notifDispatcher) { // Build list of files based on specified file order. if (in_listOrderedFiles != null) { foreach (OrderedFile orderedFile in in_listOrderedFiles) { // Select proper LUT. FileLUT lut = m_arFileLUTs[orderedFile.Type]; // Find file (binary search: files in LUTs are sorted in ID/LanguageID. uint uLanguageID; if (in_mapLanguages.TryGetValue(orderedFile.Language, out uLanguageID)) { int iFileIndex = lut.FindEntry(orderedFile.Id, uLanguageID); if (iFileIndex >= 0) { FileLUT.IncludedFile file = lut.GetAt(iFileIndex); // File was laid out. // Set starting block, mark as ready. AddOrganizedFile(file, ref in_uDataOffset); } else { // File specified in layout is not in the LUT. in_notifDispatcher.NotifyLogMsg("WARNING: File " + orderedFile.ShortName + " specified in the layout is missing."); } } else { // Invalid language. in_notifDispatcher.NotifyLogMsg("WARNING: File " + orderedFile.ShortName + " specified in the layout has invalid language + " + orderedFile.Language + "."); } } } // Default logic: add files of all LUTs in order. // Set each file's starting block. foreach (FileLUT lut in m_arFileLUTs.Values) { foreach (FileLUT.IncludedFile file in lut) { if (!file.Included) { AddOrganizedFile(file, ref in_uDataOffset); } } } }
/// <summary> /// Generate the file package. /// Creates the package header: /// - Header /// - Map of language strings /// - Map of soundbank titles /// - Soundbank files LUT /// - Streamed audio files LUT /// Writes the header to file. /// Concatenates files referenced in the LUTs. /// </summary> /// <param name="in_soundbanksInfo">Soundbank data model.</param> /// <param name="in_settings">Generation settings.</param> /// <param name="in_writer">Binary writer.</param> /// <returns>Returns true when no files are missing.</returns> internal bool GeneratePackage(SoundBanksInfo in_soundbanksInfo, PackageSettings in_settings, FilePackageWriter in_writer, List <OrderedFile> in_listOrderedFiles) { bool bNoFilesMissing = true; const int kNumSubStepsHeader = 6; const string kHeaderStepName = "Generating header"; OnStepChange(kNumSubStepsHeader, kHeaderStepName); // Header chunk. Header header = new Header(); OnSubStep(); // Language names map. Dictionary <string, uint> mapLanguageIDs = FindAllLanguages(in_soundbanksInfo); LanguagesMap langMap = new LanguagesMap(mapLanguageIDs); OnSubStep(); // Banks LUT. FileLUT banksLUT = new FileLUT(in_settings.uDefaultBlockSize); foreach (FileDescriptorType soundbank in in_soundbanksInfo.SoundBanks.SoundBankCollection) { if (!banksLUT.Add(soundbank, mapLanguageIDs)) { bNoFilesMissing = false; } } banksLUT.Sort(); OnSubStep(); // Steamed files LUT. FileLUT streamsLUT = new FileLUT(in_settings.uDefaultBlockSize); foreach (FileDescriptorType stream in in_soundbanksInfo.StreamedFiles.FileCollection) { if (!streamsLUT.Add(stream, mapLanguageIDs)) { bNoFilesMissing = false; } } streamsLUT.Sort(); OnSubStep(); // Find the header size. uint uHeaderSize = header.SizeOnDisk + langMap.MapSizeSize + banksLUT.LUTSizeSize + streamsLUT.LUTSizeSize + langMap.TotalSize + banksLUT.TotalSize + streamsLUT.TotalSize; // Prepare files for ordered concatenation. FileOrganizer organizer = new FileOrganizer(); organizer.AddLUT(AK.Wwise.FilePackager.PackageLayout.Type.SoundBank, banksLUT); organizer.AddLUT(AK.Wwise.FilePackager.PackageLayout.Type.StreamedAudio, streamsLUT); organizer.OrganizeFiles(uHeaderSize, in_listOrderedFiles, mapLanguageIDs, this); OnSubStep(); // Set header size. header.HeaderSize = uHeaderSize; // Write to output file: // Header. header.Write(in_writer); in_writer.Write(langMap.TotalSize); in_writer.Write(banksLUT.TotalSize); in_writer.Write(streamsLUT.TotalSize); langMap.Write(in_writer); banksLUT.Write(in_writer); streamsLUT.Write(in_writer); OnSubStep(); // Concatenated files. const string kConcatenateStepName = "Concatenating files"; OnStepChange((int)(banksLUT.NumFiles + streamsLUT.NumFiles), kConcatenateStepName); organizer.ConcatenateFiles(in_writer, this); return(bNoFilesMissing); }
public void AddLUT(AK.Wwise.FilePackager.PackageLayout.Type in_eType, FileLUT fileLUTs) { m_arFileLUTs[in_eType] = fileLUTs; }