|
Wwise SDK 2025.1.3
|
有限的带宽往往会使得存储设备的访问速度成为游戏的瓶颈。Therefore, to keep data transfer requests orderly, game titles usually centralize access to I/O. This order is based on relative priority and consumer requirements relative to transfer size, throughput and latency. Audio is typically I/O intensive: music and long sounds are usually streamed from disk as they are played back.
Audiokinetic Sound Engine's I/O streaming solution consists of an autonomous, overridable streaming management module. The following figure is a block diagram representing the module and its place in the sound engine / game architecture:
Its public interface, defined in IAkStreamMgr.h, is intended to be used by both the sound engine and the game. 前者使用此接口来加载 SoundBank 和流播放音频文件,而后者可用它来加载图形、纹理、游戏关、保存的游戏等。
The public interface is a platform-independent high-level abstraction for data transfers involving storage (I/O) devices that wraps handles to files or other objects close to the platform's operating system or hardware into so-called "streams". In this documentation, the module that implements the stream objects and stream factory is referred to as the High-Level Stream Manager, or simply the Stream Manager.
You may override the Stream Manager entirely if you wish, but the Wwise SDK comes with a default implementation. This default implementation defines another level for you to hook your I/O-related code, called the Low-Level I/O, which is much simpler to use. 它是将 Wwise I/O 集成到游戏中的首选方式。
Default Streaming Manager Information
默认 Stream Manager 中特定的流播放相关函数和结构(例如 AK::StreamMgr::Create())定义于 SDK include 目录下的 AkStreamMgrModule.h 中。 |
To get things up and running quickly when you first integrate Wwise, use the default Stream Manager and the low-level I/O samples that ship with the Wwise SDK:
1)链接 AkStreamMgr.lib。
2)Include the default File Location Resolver and I/O Hook into your game's project:
3)After creating the Stream Manager, instantiate and initialize the low-level I/O hook device CAkDefaultIOHookDeferred. Note that you may use CAkFilePackageLowLevelIODeferred instead, which implements the File Package extension of the I/O hook (see next section). 当您需要时,它将准备就绪。请参阅 初始化 Streaming Manager 了解有关如何将其初始化的示例。
4)The default file location resolver (implemented in CAkFileLocationBase) needs to be told the directory where files generated by the Wwise authoring tool are located. In your code, set the base path where audio assets are deployed, using CAkDefaultIOHookDeferred::SetBasePath() (or CAkDefaultIOHookDeferred::AddBasePath() ). 如果您有本地化语音资源,请使用 AK::StreamMgr::SetCurrentLanguage() 为默认 Stream Manager 模块设置当前语言。The default file location resolver concatenates the language name to the base path to find localized assets.
![]() | 警告: 请勿在传输给 AK::StreamMgr::SetCurrentLanguage() 的语言名称后面附加目录分隔符(斜线或反斜线)。 |
声音引擎现在可以加载 SoundBank 并从 SetBasePath()(或AddBasePath())中指定的目录中播放流文件了。 To automatically copy streamed files in the SoundBanks output directory in Wwise Authoring, enable Copy Loose/Streamed Media on the SoundBanks tab in the Wwise Project Settings. See SoundBanks Tabfor more details.
If you instantiated the CAkFilePackageLowLevelIODeferred device, you are a few steps away from being ready to also use file packages. 文件包(*.PCK)是通过将 Wwise 工程中的所有 SoundBank 和流音频文件组合形成单一文件。您还可以将 SoundBank 和流文件分配给不同的文件包。请参阅 File Packager 实用程序文档了解更多详情。
1)Have the Wwise tool automatically generate a file package with your soundbanks and streaming files after soundbank generation, using the "FilePackager" executable as a post-soundbank-generation step (see the SoundBank Settings section of the Wwise Help).
2)In your code, load the file package(s) explicitly using CAkFilePackageLowLevelIODeferred::LoadFilePackage(). LoadFilePackage() 将从 SetBasePath()(或 AddBasePath())中指定的路径打开文件包。In the deployment directory of audio assets, you need to include your file packages, but not the soundbanks and streamed files that they contain. When you load a file package, its header is parsed and a look-up table is created inside CAkFilePackageLowLevelIODeferred. When the sound engine tries to open a file, following a call to AK::SoundEngine::LoadBank() or an event involving playback of a streamed file, CAkFilePackageLowLevelIODeferred searches for it in the look-up tables of all its loaded file packages. 如果未找到,则在基本路径中查找该文件。
CAkDefaultIOHookDeferred reads files using the platform file system API. If your game engine already has an I/O manager, you might want to route the I/O read request issued from the Wwise Stream Manager to your I/O manager instead. Edit CAkDefaultIOHookDeferred::BatchRead() to call your I/O manager instead of the platform file system. If necessary, you can also edit CAkDefaultIOHookDeferred::BatchOpen().
SDK 中的默认 Stream Manager 位于 Low-Level I/O 子模块上。 上文所述的类均作为 Low-Level I/O 的示例在 Wwise SDK 中提供。 它们的相关文件位于:默认底层 I/O 实现 。
The preferred way of integrating Wwise I/O into your game engine is to let you implement a Low-Level I/O layer as an adapter between Wwise I/O and your I/O management technology. Typical implementations of the Low-Level I/O in games range from very simple to very complex and highly customized. 您可以使用这些示例作为起点。
Low-Level I/O 模块有两个用途:
Stream Manager 的初始化设置将影响它与 Low-Level I/O 系统间的互动方式以及整个 I/O 性能。 Audiokinetic Stream Manager 初始化设置 一章中对此进行了全面描述。I/O 技巧、故障排除和优化 章节讲述了如何对其进行微调。
The Stream Manager, whose interface is defined in IAkStreamMgr.h, is used by the Wwise sound engine to read soundbanks and streamed audio files. 如果还没有 I/O 管理器,也可以将其用于所有游戏 I/O。同样,如果您编写自定义源插件,也可以访问 Stream Manager。
高级 Stream Manager API 说明 一节中详细地解释了它的 API。You may skip this chapter if you don't use it directly as a client, and only integrate Wwise I/O into your game by implementing the low-level I/O hooks.
以下是一些基本概念。The Stream Manager manages abstract streams of data of two different types: standard streams and automatic streams.
Stream Manager 是线程安全的,但只有一个线程可以占用指定流。
主要接口 AK::IAkStreamMgr 可以随时通过调用 AK::IAkStreamMgr::Get() 来访问。随后您将可以创建和使用流对象。
以下章节提供有关流播放的更多详情: