|
| 1 | +namespace PckTool.Abstractions; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Represents a unified audio file that can be either a PCK package or a standalone BNK soundbank. |
| 5 | +/// </summary> |
| 6 | +/// <remarks> |
| 7 | +/// This interface provides a common abstraction for working with both: |
| 8 | +/// <list type="bullet"> |
| 9 | +/// <item> |
| 10 | +/// <description>PCK files - containers with multiple soundbanks and streaming files</description> |
| 11 | +/// </item> |
| 12 | +/// <item> |
| 13 | +/// <description>BNK files - standalone soundbanks with embedded media</description> |
| 14 | +/// </item> |
| 15 | +/// </list> |
| 16 | +/// </remarks> |
| 17 | +public interface IAudioFile : IDisposable |
| 18 | +{ |
| 19 | + /// <summary> |
| 20 | + /// Gets the source file path this audio file was loaded from, if applicable. |
| 21 | + /// </summary> |
| 22 | + string? SourcePath { get; } |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// Gets whether any entries have been modified since loading. |
| 26 | + /// </summary> |
| 27 | + bool HasModifications { get; } |
| 28 | + |
| 29 | + /// <summary> |
| 30 | + /// Gets the type of audio file (PCK or BNK). |
| 31 | + /// </summary> |
| 32 | + AudioFileType FileType { get; } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Gets the soundbank entries in this audio file. |
| 36 | + /// For BNK files, this returns a single-entry collection. |
| 37 | + /// </summary> |
| 38 | + ISoundBankCollection SoundBanks { get; } |
| 39 | + |
| 40 | + /// <summary> |
| 41 | + /// Gets the streaming file entries in this audio file. |
| 42 | + /// For BNK files, this returns an empty collection. |
| 43 | + /// </summary> |
| 44 | + IStreamingFileCollection StreamingFiles { get; } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// Gets the external file entries in this audio file. |
| 48 | + /// For BNK files, this returns an empty collection. |
| 49 | + /// </summary> |
| 50 | + IExternalFileCollection ExternalFiles { get; } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Gets the language ID to name mapping. |
| 54 | + /// For BNK files, this returns a single-entry mapping. |
| 55 | + /// </summary> |
| 56 | + IReadOnlyDictionary<uint, string> Languages { get; } |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// Gets the number of soundbanks contained in this audio file. |
| 60 | + /// </summary> |
| 61 | + int SoundBankCount { get; } |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// Gets the number of streaming WEM files in this audio file. |
| 65 | + /// </summary> |
| 66 | + int StreamingFileCount { get; } |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Gets the number of external WEM files in this audio file. |
| 70 | + /// </summary> |
| 71 | + int ExternalFileCount { get; } |
| 72 | + |
| 73 | + /// <summary> |
| 74 | + /// Finds a WEM file by its source ID across all storage locations. |
| 75 | + /// </summary> |
| 76 | + /// <param name="sourceId">The Wwise source ID of the WEM file.</param> |
| 77 | + /// <returns>The WEM data if found; otherwise, null.</returns> |
| 78 | + byte[]? FindWem(uint sourceId); |
| 79 | + |
| 80 | + /// <summary> |
| 81 | + /// Determines whether a WEM with the specified source ID exists. |
| 82 | + /// </summary> |
| 83 | + /// <param name="sourceId">The Wwise source ID to search for.</param> |
| 84 | + /// <returns>true if the WEM exists; otherwise, false.</returns> |
| 85 | + bool ContainsWem(uint sourceId); |
| 86 | + |
| 87 | + /// <summary> |
| 88 | + /// Replaces a WEM file's data across all locations where it exists. |
| 89 | + /// </summary> |
| 90 | + /// <param name="sourceId">The source ID of the WEM to replace.</param> |
| 91 | + /// <param name="data">The new WEM data.</param> |
| 92 | + /// <param name="updateHircSizes">Whether to update HIRC size references.</param> |
| 93 | + /// <returns>A result describing what was replaced.</returns> |
| 94 | + WemReplacementResult ReplaceWem(uint sourceId, byte[] data, bool updateHircSizes = true); |
| 95 | + |
| 96 | + /// <summary> |
| 97 | + /// Saves the audio file to the specified path. |
| 98 | + /// </summary> |
| 99 | + /// <param name="path">The file path to save to.</param> |
| 100 | + void Save(string path); |
| 101 | + |
| 102 | + /// <summary> |
| 103 | + /// Saves the audio file to a stream. |
| 104 | + /// </summary> |
| 105 | + /// <param name="stream">The stream to write to.</param> |
| 106 | + void Save(Stream stream); |
| 107 | +} |
| 108 | + |
| 109 | +/// <summary> |
| 110 | +/// Specifies the type of audio file. |
| 111 | +/// </summary> |
| 112 | +public enum AudioFileType |
| 113 | +{ |
| 114 | + /// <summary> |
| 115 | + /// A PCK package file containing multiple soundbanks and streaming files. |
| 116 | + /// </summary> |
| 117 | + Pck, |
| 118 | + |
| 119 | + /// <summary> |
| 120 | + /// A standalone BNK soundbank file. |
| 121 | + /// </summary> |
| 122 | + Bnk |
| 123 | +} |
0 commit comments