Esempio n. 1
0
 public void AddLUT(FileCategory in_eType, FileLUT fileLUTs)
 {
     m_arFileLUTs[in_eType] = fileLUTs;
 }
Esempio n. 2
0
        public void OrganizeFiles(
            ulong in_uDataOffset,
            IEnumerable <FilePackageGenerator.Context.PackageItem> in_ordered,
            Dictionary <string, uint> in_mapLanguages,
            IProgressNotificationsDispatcher in_notifDispatcher)
        {
            // Build list of files based on specified file order.
            if (in_ordered != null)
            {
                foreach (FilePackageGenerator.Context.PackageItem item in in_ordered)
                {
                    string   language = "SFX";
                    string   name     = string.Empty;
                    UInt64   itemId   = 0;
                    FileType fileType = FileType.SoundBank;
                    if (item.ExternalSourceInfo != null)
                    {
                        fileType = FileType.ExternalSource;
                        itemId   = item.ExternalSourceInfo.Id;
                        name     = item.ExternalSourceInfo.Name;
                    }
                    else if (item.Descriptor != null)
                    {
                        language = item.Descriptor.Language;
                        itemId   = item.Descriptor.Id;
                        name     = item.Descriptor.ShortName;
                        if (item.Descriptor.GetType() == typeof(AK.Wwise.InfoFile.SoundBanksInfoStreamedFiles))
                        {
                            fileType = FileType.StreamedAudio;
                        }
                        else if (item.Descriptor.GetType() == typeof(AK.Wwise.InfoFile.SoundBanksInfoMediaFilesNotInAnyBank))
                        {
                            fileType = FileType.LooseMedia;
                        }
                    }

                    // Select proper LUT.
                    FileLUT lut = m_arFileLUTs[CategoryForType(fileType)];

                    // Find file (binary search: files in LUTs are sorted in ID/LanguageID.
                    uint uLanguageID;
                    if (in_mapLanguages.TryGetValue(language, out uLanguageID))
                    {
                        int iFileIndex = lut.FindEntry(itemId, 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
                    {
                        // Invalid language.
                        in_notifDispatcher.NotifyLogMsg("WARNING: File " + name + " specified in the layout has invalid language + " + language + ".", Severity.Warning);
                    }
                }
            }

            // 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);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <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>
        private IEnumerable <NamedAction> GeneratePackage(
            Context.GlobalInfo globalInfo,
            Context.PackageInfo packageInfo,
            FilePackageWriter in_writer,
            Results results)
        {
            List <NamedAction> actions = new List <NamedAction>();

            // Header chunk.
            Header header = new Header();

            // Language names map.
            // NOTE: As of Wwise 2009.1, language names are stored as ANSI strings when not on Windows (sync with type AkOSChar).
            bool bLanguageMapUsesAsciiStrings = true;

            switch (globalInfo.BasePlatform)
            {
            case AK.Wwise.InfoFile.SoundBanksInfoBasePlatform.Windows:
            case AK.Wwise.InfoFile.SoundBanksInfoBasePlatform.XboxOne:
                bLanguageMapUsesAsciiStrings = false;
                break;

            default:
                bLanguageMapUsesAsciiStrings = true;
                break;
            }

            IEnumerable <AK.Wwise.InfoFile.FileDescriptorType>            descriptors = packageInfo.Files.Where(f => f.Descriptor != null).Select(f => f.Descriptor);
            IEnumerable <FilePackageGenerator.Context.ExternalSourceInfo> externals   = packageInfo.Files.Where(f => f.ExternalSourceInfo != null).Select(f => f.ExternalSourceInfo);

            Dictionary <string, uint> mapLanguageIDs = FindAllLanguages(descriptors);
            LanguagesMap langMap = new LanguagesMap(mapLanguageIDs, bLanguageMapUsesAsciiStrings);

            // Add Banks files to LUT.
            FileLUT banksLUT = new FileLUT(globalInfo.SoundBanksRoot, packageInfo.BlockSize, typeof(UInt32));

            foreach (AK.Wwise.InfoFile.FileDescriptorType soundbank in descriptors.OfType <AK.Wwise.InfoFile.SoundBanksInfoSoundBanksSoundBank>())
            {
                if (!banksLUT.Add(soundbank, mapLanguageIDs))
                {
                    NotifyLogMsg("Missing soundbank: " + soundbank.ShortName + " (" + soundbank.Path + ")", Severity.Warning);
                    results.HasMissingFiles = true;
                }
            }
            banksLUT.Sort();

            // Add Steamed files to LUT.
            FileLUT streamsLUT = new FileLUT(globalInfo.SourceFilesRoot, packageInfo.BlockSize, typeof(UInt32));

            foreach (AK.Wwise.InfoFile.FileDescriptorType stream in descriptors.Where(fd => (fd is AK.Wwise.InfoFile.SoundBanksInfoStreamedFilesFile ||
                                                                                             fd is AK.Wwise.InfoFile.SoundBanksInfoMediaFilesNotInAnyBankFile)))
            {
                if (!streamsLUT.Add(stream, mapLanguageIDs))
                {
                    NotifyLogMsg("Missing streamed or loose media file: " + stream.ShortName + " (" + stream.Path + ")", Severity.Warning);
                    results.HasMissingFiles = true;
                }
            }
            streamsLUT.Sort();

            // Add External Source files to LUT.
            FileLUT externalLUT = new FileLUT(globalInfo.SourceFilesRoot, packageInfo.BlockSize, typeof(UInt64));

            foreach (FilePackageGenerator.Context.ExternalSourceInfo external in externals)
            {
                if (!externalLUT.Add(external, mapLanguageIDs))
                {
                    NotifyLogMsg("Missing external file: " + external.Name + " (" + external.Path + ")", Severity.Warning);
                    results.HasMissingFiles = true;
                }
            }
            externalLUT.Sort();

            // Find the header size.
            uint uHeaderSize =
                BaseHeaderSize +
                langMap.TotalSize +
                banksLUT.TotalSize +
                streamsLUT.TotalSize +
                externalLUT.TotalSize;

            // Prepare files for ordered concatenation.
            FileOrganizer organizer = new FileOrganizer();

            organizer.AddLUT(FileOrganizer.FileCategory.SoundBank, banksLUT);
            organizer.AddLUT(FileOrganizer.FileCategory.MediaFile, streamsLUT);
            organizer.AddLUT(FileOrganizer.FileCategory.ExternalSource, externalLUT);
            organizer.OrganizeFiles(uHeaderSize, packageInfo.Files, mapLanguageIDs, this);

            // Set header size.
            header.HeaderSize = uHeaderSize;


            // Write to output file:
            actions.Add(new NamedAction("Writing header", delegate()
            {
                // Header.
                header.Write(in_writer);
                in_writer.Write(langMap.TotalSize);
                in_writer.Write(banksLUT.TotalSize);
                in_writer.Write(streamsLUT.TotalSize);
                in_writer.Write(externalLUT.TotalSize);

                langMap.Write(in_writer);
                banksLUT.Write(in_writer);
                streamsLUT.Write(in_writer);
                externalLUT.Write(in_writer);
            }));

            // Concatenated files.
            return(actions.Concat(organizer.ConcatenateFiles(in_writer, this)));
        }